Skip to content

Commit

Permalink
return as float32 to save memory
Browse files Browse the repository at this point in the history
  • Loading branch information
rettigl committed Jan 26, 2025
1 parent 38513cb commit 1050b1d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/specsanalyzer/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def convert_image(
},
dims=conversion_parameters["dims"],
attrs={"conversion_parameters": conversion_parameters},
)
).astype(np.float32)

# Handle cropping based on parameters stored in correction dictionary
crop = kwds.pop("crop", self._config.get("crop", False))
Expand Down
8 changes: 4 additions & 4 deletions tests/test_specsscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def test_conversion_3d():
path=data_dir,
iterations=np.s_[0:2],
)
np.testing.assert_allclose(res_xarray, res_xarray2)
np.testing.assert_allclose(res_xarray, res_xarray2, rtol=1e-6)

with pytest.raises(IndexError):
sps.load_scan(
Expand Down Expand Up @@ -259,15 +259,15 @@ def test_fft_tool():
apply_fft_filter=False,
)

np.testing.assert_almost_equal(res_xarray.data.sum(), 62145561928.15108, decimal=3)
np.testing.assert_allclose(res_xarray.data.sum(), 62145556000.0)

res_xarray = sps.load_scan(
scan=3610,
path=data_dir,
fft_filter_peaks=fft_filter_peaks,
apply_fft_filter=True,
)
np.testing.assert_almost_equal(res_xarray.data.sum(), 62197237155.50347, decimal=3)
np.testing.assert_allclose(res_xarray.data.sum(), 62197240000.0)

sps.fft_tool(
amplitude=1,
Expand All @@ -279,7 +279,7 @@ def test_fft_tool():
)
assert sps.spa.config["fft_filter_peaks"] == fft_filter_peaks
res_xarray = sps.load_scan(scan=3610, path=data_dir, apply_fft_filter=True)
np.testing.assert_almost_equal(res_xarray.data.sum(), 62197237155.50347, decimal=3)
np.testing.assert_allclose(res_xarray.data.sum(), 62197240000.0)


def test_conversion_and_save_to_nexus():
Expand Down

0 comments on commit 1050b1d

Please sign in to comment.