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

Add save_any function to image_io #51

Merged
merged 3 commits into from
Mar 15, 2024
Merged

Add save_any function to image_io #51

merged 3 commits into from
Mar 15, 2024

Conversation

K-Meech
Copy link
Contributor

@K-Meech K-Meech commented Mar 14, 2024

Closes #50

This PR:

  • Moves save_any from test_image_io into the image_io module (removing support for txt files)
  • Changes text file writing into a fixture inside test_image_io
  • Moves to using load_any() wherever possible in test_image_io
  • Removes test_load_img_sequence_from_txt and test_nrrd_io, that are already covered by test_load_any_txt and test_save_and_load_any
  • Adds in a few extra assertions for scaling / correct file number in test_image_io

Copy link
Member

@alessandrofelder alessandrofelder left a comment

Choose a reason for hiding this comment

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

Thanks @K-Meech - one tiny comment.
Looking good 🎉 feel free to merge after considering it!

# Shuffle paths in the text file into a random order
with open(txt_path, "r+") as f:
tiff_paths = f.read().splitlines()
random.Random(4).shuffle(tiff_paths)
Copy link
Member

Choose a reason for hiding this comment

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

Should we generalise this to something like

Suggested change
random.Random(4).shuffle(tiff_paths)
random.Random(len(tiff_paths)).shuffle(tiff_paths)

or specify in the docstring that the function only shuffles the first four paths?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@alessandrofelder this is actually the random seed, it just happened to be equal to the number of paths in this case! I set this to ensure we're getting the same result each time, and avoid the cases where it might shuffle the paths back into the correct order accidentally.

Copy link
Member

Choose a reason for hiding this comment

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

Ha sorry! All good then, thanks!

@alessandrofelder alessandrofelder merged commit d336fc5 into main Mar 15, 2024
10 checks passed
@alessandrofelder alessandrofelder deleted the add_save_any branch March 15, 2024 10:39
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.

Add a save_any function to image_io
2 participants