Skip to content

Commit

Permalink
Fixed a bug in named_arrays.interp() where the resulting axes were …
Browse files Browse the repository at this point in the history
…not being set correctly. (#88)
  • Loading branch information
byrdie authored Nov 2, 2024
1 parent d28eb53 commit 09ccd0a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion named_arrays/_scalars/scalar_named_array_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def interp(
right=right_index,
period=period_index,
),
axes=x.axes,
axes=x_index.axes,
)

return result
Expand Down
7 changes: 5 additions & 2 deletions named_arrays/_scalars/scalars.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,8 +781,11 @@ def __post_init__(self: Self):
self.axes = tuple()
if isinstance(self.axes, str):
self.axes = (self.axes, )
if getattr(self.ndarray, 'ndim', 0) != len(self.axes):
raise ValueError('The number of axis names must match the number of dimensions.')
if getattr(self.ndarray, 'ndim', 0) != len(self.axes): # pragma: nocover
raise ValueError(
f'The number of axis names, {self.axes}, '
f'must match the number of dimensions, {np.ndim(self.ndarray)}.'
)
if len(self.axes) != len(set(self.axes)):
raise ValueError(f'Each axis name must be unique, got {self.axes}.')

Expand Down

0 comments on commit 09ccd0a

Please sign in to comment.