Skip to content

Commit

Permalink
FIX: Try again [build wheels]
Browse files Browse the repository at this point in the history
  • Loading branch information
larsoner committed Jun 12, 2024
1 parent eb29943 commit 8b8202f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 14 deletions.
24 changes: 12 additions & 12 deletions nitime/tests/test_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -916,20 +916,20 @@ def test_index_int64():
assert repr(b[0]) == repr(b[np.int32(0)])


def test_timearray_math_functions():
@pytest.mark.parametrize('f', ['min', 'max', 'mean', 'ptp', 'sum'])
@pytest.mark.parametrize('tu', ['s', 'ms', 'ps', 'D'])
def test_timearray_math_functions(f, tu):
"Calling TimeArray.min() .max(), mean() should return TimeArrays"
a = np.arange(2, 11)
for f in ['min', 'max', 'mean', 'ptp', 'sum']:
for tu in ['s', 'ms', 'ps', 'D']:
b = ts.TimeArray(a, time_unit=tu)
npt.assert_(getattr(b, f)().__class__ == ts.TimeArray)
npt.assert_(getattr(b, f)().time_unit == b.time_unit)
# comparison with unitless should convert to the TimeArray's units
if f == "ptp":
want = np.ptp(a) # ndarray.ptp removed in 2.0
else:
want = getattr(a, f)()
npt.assert_(getattr(b, f)() == want)
b = ts.TimeArray(a, time_unit=tu)
if f == "ptp" and ts._NP_2:
with pytest.raises(AttributeError, match='`ptp` was removed'):
a.ptp() # ndarray.ptp removed in 2.0
return
npt.assert_(getattr(b, f)().__class__ == ts.TimeArray)
npt.assert_(getattr(b, f)().time_unit == b.time_unit)
# comparison with unitless should convert to the TimeArray's units
npt.assert_(getattr(b, f)() == getattr(a, f)())


def test_timearray_var_prod():
Expand Down
16 changes: 14 additions & 2 deletions nitime/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
# Our own
from nitime import descriptors as desc

try:
_NP_2 = int(np.__version__.split(".")[0]) >= 2
except Exception:
_NP_2 = True

#-----------------------------------------------------------------------------
# Module globals
#-----------------------------------------------------------------------------
Expand Down Expand Up @@ -112,7 +117,9 @@ def __new__(cls, data, time_unit=None, copy=True):
which are SI units of time. Default: 's'
copy : bool, optional
Whether to create this instance by copy of a
Whether to create this instance by copy of a. If False,
a copy will not be forced but might still be required depending
on the data array.
Note
----
Expand Down Expand Up @@ -309,7 +316,12 @@ def mean(self, *args, **kwargs):
return ret

def ptp(self, *args, **kwargs):
ret = TimeArray(np.ptp(self, *args, **kwargs),
if _NP_2:
raise AttributeError(
"`ptp` was removed from the ndarray class in NumPy 2.0. "
"Use np.ptp(arr, ...) instead."
)
ret = TimeArray(np.ndarray.ptp(self, *args, **kwargs),
time_unit=base_unit)
ret.convert_unit(self.time_unit)
return ret
Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ skip = "pp* cp38-*_aarch64 cp38-musllinux_*"
# don't bother unless someone asks
archs = ["native"]

test-requires = [
"pytest",
"pytest-cov",
]
test-command = "pytest {project}/tests"

[tool.cibuildwheel.linux]
archs = ["x86_64", "aarch64"]

Expand Down

0 comments on commit 8b8202f

Please sign in to comment.