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

Protect axis attribute for uniform data axes #3121

Open
jlaehne opened this issue Mar 31, 2023 · 0 comments · May be fixed by #3031
Open

Protect axis attribute for uniform data axes #3121

jlaehne opened this issue Mar 31, 2023 · 0 comments · May be fixed by #3031

Comments

@jlaehne
Copy link
Contributor

jlaehne commented Mar 31, 2023

Describe the bug

Currently, the axis attribute of uniform data axes can be changed (after initialization of the axis), though it should be defined by offset and scale only. Instead, it should be a protected attribute that can be changed only if offset and scale are changed, but not directly by user input. An example is that users not understanding the difference between DataAxis and UniformDataAxis, might actually change an axis to a non-uniform one just by providing the axis array without converting the axes type, which can lead to problems in a later analysis.

Would be solved by #3031

To Reproduce

Steps to reproduce the behavior:

S=hs.signals.Signal1D(np.arange(100))
S.axes_manager[0].axis = np.ones(100)

S.axes_manager and S.axes_manager[0].axis are now in contradiction to each other.

Expected behavior

Throw an error when trying to manually change the axis vector for a uniform or functional data axis.

Python environement:

  • HyperSpy version: 1.7.4
  • Python version: 3.11
@jlaehne jlaehne linked a pull request Mar 31, 2023 that will close this issue
3 tasks
@jlaehne jlaehne linked a pull request Mar 31, 2023 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant