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

fix complex rebin and add complex test #2789

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions hyperspy/misc/array_tools.py
Expand Up @@ -310,12 +310,12 @@ def _linear_bin(dat, scale, crop=True):
"Re-adjust your scale values or run code with "
"crop=False to avoid this error."
)
# Set up the result np.array to have a new axis[0] size for after
# cropping.
result = np.zeros((dim,) + dat.shape[1:])
# Make sure that native endian is used
if not dat.dtype.isnative:
dat = dat.astype(dat.dtype.type)
# Set up the result np.array to have a new axis[0] size for after
# cropping.
result = np.zeros((dim,) + dat.shape[1:], dtype=dat.dtype)
# Carry out binning over axis[0]
_linear_bin_loop(result=result, data=dat, scale=s)
# Swap axis[0] back to the original axis location.
Expand Down
4 changes: 2 additions & 2 deletions hyperspy/tests/signals/test_linear_rebin.py
Expand Up @@ -25,7 +25,7 @@

class TestLinearRebin:

@pytest.mark.parametrize('dtype', ['<u2', 'u2', '>u2', '<f4', 'f4', '>f4'])
@pytest.mark.parametrize('dtype', ['<u2', 'u2', '>u2', '<f4', 'f4', '>f4', 'c8'])
def test_linear_downsize(self, dtype):
spectrum = EDSTEMSpectrum(np.ones([3, 5, 1], dtype=dtype))
scale = (1.5, 2.5, 1)
Expand All @@ -36,7 +36,7 @@ def test_linear_downsize(self, dtype):
res = spectrum.rebin(scale=scale, crop=False)
np.testing.assert_allclose(res.data.sum(), spectrum.data.sum())

@pytest.mark.parametrize('dtype', ['<u2', 'u2', '>u2', '<f4', 'f4', '>f4'])
@pytest.mark.parametrize('dtype', ['<u2', 'u2', '>u2', '<f4', 'f4', '>f4', 'c8'])
def test_linear_upsize(self, dtype):
spectrum = EDSTEMSpectrum(np.ones([4, 5, 10], dtype=dtype))
scale = [0.3, 0.2, 0.5]
Expand Down
1 change: 1 addition & 0 deletions upcoming_changes/2789.bugfix.rst
@@ -0,0 +1 @@
ComplexSignals can now be rebinned without error