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 Volume.arraydata because it does not round-trip to the correct Volume shape #93

Open
ylep opened this issue Feb 10, 2023 · 1 comment

Comments

@ylep
Copy link
Member

ylep commented Feb 10, 2023

The Volume.arraydata() function is used by many scripts, both in our distributed code and in user scripts. However, this is the incorrect function to use, people should use numpy.asarray or volume.np instead.

Scripts that use Volume -> arraydata() -> NumPy Array -> Volume used to work by sheer chance because of a bug in aims.Volume, but that bug is now fixed and thus user scripts needs to be fixed (see #92 for details).

I propose to drop support for arraydata() entirely, making it raise an exception telling people to fix their code and use numpy.asarray or volume.np instead. If some specific use-cases need its functionality, we can make it available under another name (e.g. raw_internal_array or something similar).

We also need to fix the code that we distribute: I counted 487 uses of arraydata in Python code in the cea distro on the 5.1 branch:

$ ack -ch --python --ignore-dir=5.0 --ignore-dir=master '\barraydata\b'
487
ylep added a commit that referenced this issue Feb 13, 2023
Actually we would need to raise a (more visible) RuntimeWarning, because the
behaviour of arraydata() has already changed, and DeprecationWarnings are
invisible by default... but we are goinrg to remove arraydata() or make it
raise an exception, so this is good enough for now.

See #93
@ylep ylep changed the title Get rid of Volume.arraydata Remove Volume.arraydata because it does not round-trip to the correct Volume shape Feb 13, 2023
@ylep
Copy link
Member Author

ylep commented Feb 13, 2023

OK I agree to make arraydata() obsolete.
The method also exists in vectors and textures (1D arrays), and is harmless there and identical to asarray(), so there are certainly less than 501 "dangerous" uses of arraydata() on volumes, but I also agree that we should deprecate it there too.

Originally posted by @denisri in #92 (comment)

ylep added a commit that referenced this issue Feb 17, 2023
ylep added a commit that referenced this issue Mar 10, 2023
denisri added a commit to brainvisa/anatomist-gpl that referenced this issue Jan 12, 2024
denisri added a commit to brainvisa/brainvisa_freesurfer that referenced this issue Jan 12, 2024
denisri added a commit to brainvisa/sulci-nonfree that referenced this issue Jan 12, 2024
denisri added a commit to brainvisa/morphologist-gpl that referenced this issue Jan 12, 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

No branches or pull requests

1 participant