diff --git a/CHANGELOG.md b/CHANGELOG.md index cc750e84..011bf2f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/). ## [Unreleased] +## [3.4.6] + +### Fixed + +- `Data.chop` : fixed bug where chop did not succeed if axes did not span data ndim + ## [3.4.5] ### Added @@ -329,7 +335,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/). ### Added - initial release -[Unreleased]: https://github.com/wright-group/WrightTools/-/compare/3.4.4...master +[Unreleased]: https://github.com/wright-group/WrightTools/-/compare/3.4.6...master +[3.4.6]: https://github.com/wright-group/WrightTools/compare/3.4.5...3.4.6 [3.4.5]: https://github.com/wright-group/WrightTools/compare/3.4.4...3.4.5 [3.4.4]: https://github.com/wright-group/WrightTools/compare/3.4.3...3.4.4 [3.4.3]: https://github.com/wright-group/WrightTools/compare/3.4.2...3.4.3 diff --git a/WrightTools/VERSION b/WrightTools/VERSION index 4f5e6973..1cf82530 100644 --- a/WrightTools/VERSION +++ b/WrightTools/VERSION @@ -1 +1 @@ -3.4.5 +3.4.6 diff --git a/WrightTools/data/_data.py b/WrightTools/data/_data.py index 105a0d32..662c68af 100644 --- a/WrightTools/data/_data.py +++ b/WrightTools/data/_data.py @@ -482,7 +482,7 @@ def _at_to_slice(self, **at) -> np.array: for k in at.keys(): if k not in self.axis_names: raise ValueError(f"Axis identifier {k} not in Axes: {self.axis_names}") - idx = np.array([slice(None)] * len(self._axes)) + idx = np.array([slice(None)] * len(self.shape)) for axis, point in at.items(): point, units = point destination_units = self._axes[self.axis_names.index(axis)].units diff --git a/tests/data/chop.py b/tests/data/chop.py index af3d0f6d..e01c0238 100755 --- a/tests/data/chop.py +++ b/tests/data/chop.py @@ -186,12 +186,32 @@ def test_rmd_axis_full_shape(): assert c[0].shape == (6, 3) +def test_non_spanning_axes(): + """axes do not span shape of data""" + + x = np.arange(6) + + d = wt.Data(name="test") + d.create_variable("x", values=x[:, None, None]) + d.create_variable("y", values=x[None, ::2, None]) + d.create_variable("z", values=x[None, None, ::3]) + d.transform("x", "y") + + c = d.chop(1) + assert c[0].axis_names == ("y",) + assert c[0].shape == d.shape[1:] + + d.close() + c.close() + + # --- run ----------------------------------------------------------------------------------------- if __name__ == "__main__": test_transformed() test_axes_order() + test_non_spanning_axes() test_2D_to_1D() test_3D_to_1D() test_3D_to_1D_at()