Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implements move_to #83

Merged
merged 3 commits into from
Nov 5, 2022
Merged

Implements move_to #83

merged 3 commits into from
Nov 5, 2022

Conversation

hbcarlos
Copy link
Contributor

Hi @Waidhoferj.

I noticed the move feature had not yet been implemented here in the python bindings. I trying to implement it since we need it for JupyterLab.

Can you take a look at this? It is the first time I have looked at y-rs and y-py, and the first time I used rust, so I'm unsure if I'm implementing it correctly.

I'm keeping the PR as a draft because I want to implement move_range_to in the same PR, but first, I would like you to take a look at the move_to function in case I'm doing something wrong.

@hbcarlos hbcarlos marked this pull request as draft October 25, 2022 08:28
Copy link
Collaborator

@Waidhoferj Waidhoferj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @hbcarlos, thanks for adding move functionality! This looks good so far. Let me know if you have any questions about the codebase.

@Horusiath could you double check this?

src/y_array.rs Outdated
SharedType::Integrated(v) => Ok(v.move_to(txn, source, target)),
SharedType::Prelim(v) if source < v.len() as u32 && target < v.len() as u32 => {
if source < 0 as u32 || target < 0 as u32 {
Err::<PyIndexError, ()>(());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Err::<PyIndexError, ()>(());
Err(PyIndexError::default_message())

Including a default message or specifically referencing whether source or target is out of bounds would be helpful.

@hbcarlos hbcarlos marked this pull request as ready for review October 29, 2022 13:31
@hbcarlos
Copy link
Contributor Author

Hey @Waidhoferj! Thank you so much for the help!

I added a new commit with your suggestion and the implementation of move_range_to.

@Waidhoferj
Copy link
Collaborator

Hi @hbcarlos, looks good! Could you add test cases covering these functions to test_y_array.py?

@hbcarlos
Copy link
Contributor Author

hbcarlos commented Nov 2, 2022

I added some tests in my last commit.

Copy link
Collaborator

@Waidhoferj Waidhoferj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests look great! Feel free to merge.

@hbcarlos
Copy link
Contributor Author

hbcarlos commented Nov 5, 2022

Thanks, @Waidhoferj! I don't have maintainer rights, I can not merge it.

@davidbrochart davidbrochart merged commit 1f5892f into y-crdt:main Nov 5, 2022
@hbcarlos hbcarlos deleted the move branch November 5, 2022 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants