Skip to content

Commit 8b8202f

Browse files
committed
FIX: Try again [build wheels]
1 parent eb29943 commit 8b8202f

File tree

3 files changed

+32
-14
lines changed

3 files changed

+32
-14
lines changed

nitime/tests/test_timeseries.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -916,20 +916,20 @@ def test_index_int64():
916916
assert repr(b[0]) == repr(b[np.int32(0)])
917917

918918

919-
def test_timearray_math_functions():
919+
@pytest.mark.parametrize('f', ['min', 'max', 'mean', 'ptp', 'sum'])
920+
@pytest.mark.parametrize('tu', ['s', 'ms', 'ps', 'D'])
921+
def test_timearray_math_functions(f, tu):
920922
"Calling TimeArray.min() .max(), mean() should return TimeArrays"
921923
a = np.arange(2, 11)
922-
for f in ['min', 'max', 'mean', 'ptp', 'sum']:
923-
for tu in ['s', 'ms', 'ps', 'D']:
924-
b = ts.TimeArray(a, time_unit=tu)
925-
npt.assert_(getattr(b, f)().__class__ == ts.TimeArray)
926-
npt.assert_(getattr(b, f)().time_unit == b.time_unit)
927-
# comparison with unitless should convert to the TimeArray's units
928-
if f == "ptp":
929-
want = np.ptp(a) # ndarray.ptp removed in 2.0
930-
else:
931-
want = getattr(a, f)()
932-
npt.assert_(getattr(b, f)() == want)
924+
b = ts.TimeArray(a, time_unit=tu)
925+
if f == "ptp" and ts._NP_2:
926+
with pytest.raises(AttributeError, match='`ptp` was removed'):
927+
a.ptp() # ndarray.ptp removed in 2.0
928+
return
929+
npt.assert_(getattr(b, f)().__class__ == ts.TimeArray)
930+
npt.assert_(getattr(b, f)().time_unit == b.time_unit)
931+
# comparison with unitless should convert to the TimeArray's units
932+
npt.assert_(getattr(b, f)() == getattr(a, f)())
933933

934934

935935
def test_timearray_var_prod():

nitime/timeseries.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@
3333
# Our own
3434
from nitime import descriptors as desc
3535

36+
try:
37+
_NP_2 = int(np.__version__.split(".")[0]) >= 2
38+
except Exception:
39+
_NP_2 = True
40+
3641
#-----------------------------------------------------------------------------
3742
# Module globals
3843
#-----------------------------------------------------------------------------
@@ -112,7 +117,9 @@ def __new__(cls, data, time_unit=None, copy=True):
112117
which are SI units of time. Default: 's'
113118
114119
copy : bool, optional
115-
Whether to create this instance by copy of a
120+
Whether to create this instance by copy of a. If False,
121+
a copy will not be forced but might still be required depending
122+
on the data array.
116123
117124
Note
118125
----
@@ -309,7 +316,12 @@ def mean(self, *args, **kwargs):
309316
return ret
310317

311318
def ptp(self, *args, **kwargs):
312-
ret = TimeArray(np.ptp(self, *args, **kwargs),
319+
if _NP_2:
320+
raise AttributeError(
321+
"`ptp` was removed from the ndarray class in NumPy 2.0. "
322+
"Use np.ptp(arr, ...) instead."
323+
)
324+
ret = TimeArray(np.ndarray.ptp(self, *args, **kwargs),
313325
time_unit=base_unit)
314326
ret.convert_unit(self.time_unit)
315327
return ret

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ skip = "pp* cp38-*_aarch64 cp38-musllinux_*"
6262
# don't bother unless someone asks
6363
archs = ["native"]
6464

65+
test-requires = [
66+
"pytest",
67+
"pytest-cov",
68+
]
69+
test-command = "pytest {project}/tests"
70+
6571
[tool.cibuildwheel.linux]
6672
archs = ["x86_64", "aarch64"]
6773

0 commit comments

Comments
 (0)