Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions coordax/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,8 +691,8 @@ def _validate_matching_coords(
"""Validate that given coordinates are all found on this field."""
axes = []
for part in dims_or_coords:
if isinstance(part, Coordinate) and not isinstance(part, DummyAxis):
axes.extend(part.axes)
if isinstance(part, Coordinate):
axes.extend([c for c in part.axes if not isinstance(c, DummyAxis)])

for c in axes:
[dim] = c.dims
Expand Down
31 changes: 26 additions & 5 deletions coordax/fields_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,30 @@ def test_field_repr(self):
full_unwrap=False,
should_raise_on_untag=False,
),
dict(
testcase_name='composed_dummy_axis',
array=np.arange(4 * 5).reshape(4, 5),
tags=('x', 'y'),
untags=(
coordax.coords.compose(
coordax.DummyAxis('x', 4), coordax.DummyAxis('y', 5)
),
),
full_unwrap=True,
should_raise_on_untag=False,
),
dict(
testcase_name='composed_dummy_axis_missing',
array=np.arange(4 * 5).reshape(4, 5),
tags=('x', 'y'),
untags=(
coordax.coords.compose(
coordax.DummyAxis('x', 4), coordax.DummyAxis('missing', 5)
),
),
full_unwrap=False,
should_raise_on_untag=True,
),
)
def test_tag_then_untag_by(
self,
Expand Down Expand Up @@ -731,9 +755,7 @@ def test_get_coordinate(self):
)
with self.subTest('default'):
actual = coordax.get_coordinate(field)
expected = coordax.coords.compose(
*[axes[d] for d in ['x', 'y', 'z']]
)
expected = coordax.coords.compose(*[axes[d] for d in ['x', 'y', 'z']])
self.assertEqual(actual, expected)

with self.subTest('with_positional_dims'):
Expand Down Expand Up @@ -952,8 +974,7 @@ def test_sel_raises_on_unused_indexer(self):
y = coordax.LabeledAxis('y', np.array([100, 200, 300]))
field = coordax.field(jnp.zeros((2, 3)), x, y)
with self.assertRaisesRegex(
ValueError,
re.escape("Indexers {'z'} were not processed")
ValueError, re.escape("Indexers {'z'} were not processed")
):
field.sel(z=slice(0, 20), x=10)

Expand Down
Loading