-
Notifications
You must be signed in to change notification settings - Fork 207
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
Axes sizes should always match signal shape #2692
Comments
Another example from March 26, 2021 3:40 PM, note the size of the navigation dimensions. import hyperspy.api as hs
import numpy as np
data = np.zeros((63, 51, 400, 975))
ax1 = {'size' : 63}
ax2 = {'size' : 51}
ax3 = {'size' : 400}
ax4 = {'size' : 975}
s = hs.signals.Signal2D(data, axes=[ax2, ax1, ax3, ax4])
s
# <Signal2D, title: , dimensions: (63, 51|975, 400)>
s.isig[1:2, 3:4]
# <Signal2D, title: , dimensions: (51, 63|1, 1)> |
Hello Thomas, |
Well that is what #2399 is about initially. Allowing to define axes through a |
Are you still planning to make a PR? |
We should ensure that the axes
size
and the number of axes provided to a signal, actually matches the data shape.Note that there are a lot of new features coming in #2399.
While one could theoretically provide flexible-size (following signal shape) to
UniformDataAxis
andFunctionalDataAxis
,DataAxis
requires a fixed-length array. I think it is better that we for now expect thesize
attribute to match the signal shape when an axis is passed to a signal, and then we can consider a more flexible approach in the future.As an example of where this can go wrong, currently the following does not raise any errors:
Should be as simple as looping through the axes, and comparing its
size
withs.data.shape[ax.index_in_array]
, as well as checking the number of axes vslen(data.shape)
.I will make a PR to #2399.
The text was updated successfully, but these errors were encountered: