From 09ccd0aeb31acae626041808a7a182ef21626b4b Mon Sep 17 00:00:00 2001 From: Roy Smart Date: Fri, 1 Nov 2024 18:54:53 -0600 Subject: [PATCH] Fixed a bug in `named_arrays.interp()` where the resulting axes were not being set correctly. (#88) --- named_arrays/_scalars/scalar_named_array_functions.py | 2 +- named_arrays/_scalars/scalars.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/named_arrays/_scalars/scalar_named_array_functions.py b/named_arrays/_scalars/scalar_named_array_functions.py index 8796434..ac122b9 100644 --- a/named_arrays/_scalars/scalar_named_array_functions.py +++ b/named_arrays/_scalars/scalar_named_array_functions.py @@ -241,7 +241,7 @@ def interp( right=right_index, period=period_index, ), - axes=x.axes, + axes=x_index.axes, ) return result diff --git a/named_arrays/_scalars/scalars.py b/named_arrays/_scalars/scalars.py index 19d9a40..8625c87 100644 --- a/named_arrays/_scalars/scalars.py +++ b/named_arrays/_scalars/scalars.py @@ -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}.')