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

remove_duplicates() without in_place = True causes signature_value to be not updated after write. #179

Merged
merged 3 commits into from
Jun 14, 2024

Conversation

btasdelen
Copy link
Collaborator

Due to the copy of Sequence object being made when in_place=False, assignments to the self in write() function is done to the copy, not the original. As a result, those values are not assigned after the call returns. AFAIK, only signature only these three lines are effected:

self.signature_type = "md5"
self.signature_file = "text"
self.signature_value = md5

As a dummy workaround, I just passed in_place=True to the remove_duplicates(), but I think that is not what we want, as it will modify the Sequence object, is that true? In that case, my suggestion is to rename the copy, instead of assigning it to self, and still assigning signatures to self to keep old behavior. I can make that commit if you can confirm this is the desired behavior.

@btasdelen btasdelen requested a review from FrankZijlstra June 13, 2024 00:31
@btasdelen btasdelen changed the title remove_duplicates() without in_place = True causes signature_value to be not updated after write. remove_duplicates() without in_place = True causes signature_value to be not updated after write. Jun 13, 2024
@FrankZijlstra
Copy link
Collaborator

Specifying in_place=True will end up rounding values in the sequence libraries, which I think is undesirable. Renaming the copy is probably the desired behaviour, though it will be storing the hash for the sequence with duplicate events removed (i.e. not exactly the same object as where the values would then be stored).
Perhaps a related question, what is the purpose of those signature values being stored in the object? In both pypulseq and pulseq I only see it ever being written, never accessed. It might make more sense to have it as a return value for the write function?

@btasdelen
Copy link
Collaborator Author

In our workflow, we use the signature to name a metadata file so that correct metadata can be automatically picked and used in the reconstruction.

Returning signature also works. Behavior change bothers me a bit, but I don't think many people are using signatures, it should be ok. I will make the change and commit.

@btasdelen
Copy link
Collaborator Author

@FrankZijlstra I made the changes, feel free to merge if everything looks good.

@aTrotier
Copy link

aTrotier commented Jun 13, 2024 via email

@btasdelen
Copy link
Collaborator Author

On a second thought, considering @aTrotier and our use cases and potential uses, it makes sense that one does not need the Sequence object's signature, but the written file's signature anyway. To keep backward compatibility and not break anyone's code, I think it is best to assign the signature to the original class, and also return from the write function.

However, I am not a fan of write function having a side effect as it is not a class method, so I will add the assignment to the Sequence.write() function. I will document this behavior.

@FrankZijlstra FrankZijlstra merged commit 45f18a8 into imr-framework:dev Jun 14, 2024
4 checks passed
@schuenke schuenke mentioned this pull request Jun 20, 2024
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