Skip to content

Commit

Permalink
chop patch (#1095)
Browse files Browse the repository at this point in the history
  • Loading branch information
ddkohler committed Aug 4, 2022
1 parent 66b7d73 commit 49501c4
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion WrightTools/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.4.5
3.4.6
2 changes: 1 addition & 1 deletion WrightTools/data/_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions tests/data/chop.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 49501c4

Please sign in to comment.