Skip to content

Commit eb67626

Browse files
authored
Add support for numpy 2, update all deps (#1139)
1 parent 62edbe4 commit eb67626

File tree

10 files changed

+41
-30
lines changed

10 files changed

+41
-30
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Enhancements
66
- Warn when unexpected keys are present in specs. @rly [#1134](https://github.com/hdmf-dev/hdmf/pull/1134)
77
- Support appending to zarr arrays. @mavaylon1 [#1136](https://github.com/hdmf-dev/hdmf/pull/1136)
8+
- Add support for numpy 2. @rly [#1139](https://github.com/hdmf-dev/hdmf/pull/1139)
89

910
### Bug fixes
1011
- Fix iterator increment causing an extra +1 added after the end of completion. @CodyCBakerPhD [#1128](https://github.com/hdmf-dev/hdmf/pull/1128)

environment-ros3.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ channels:
55
- defaults
66
dependencies:
77
- python==3.12
8-
- h5py==3.10.0
9-
- matplotlib==3.8.0
10-
- numpy==1.26.0
11-
- pandas==2.1.2
8+
- h5py==3.11.0
9+
- matplotlib==3.8.4
10+
- numpy==2.0.0
11+
- pandas==2.2.2
1212
- python-dateutil==2.8.2
13-
- pytest==7.4.3
14-
- pytest-cov==4.1.0
13+
- pytest==8.1.2 # regression introduced in pytest 8.2.*, will be fixed in 8.3.0
14+
- pytest-cov==5.0.0
1515
- setuptools

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ classifiers = [
3232
dependencies = [
3333
"h5py>=2.10",
3434
"jsonschema>=2.6.0",
35-
'numpy>=1.18, <2.0', # pin below 2.0 until HDMF supports numpy 2.0
35+
'numpy>=1.18',
3636
"pandas>=1.0.5",
3737
"ruamel.yaml>=0.16",
3838
"scipy>=1.4",

requirements-dev.txt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
# compute coverage, and create test environments. note that depending on the version of python installed, different
33
# versions of requirements may be installed due to package incompatibilities.
44
#
5-
black==24.3.0
6-
codespell==2.2.6
7-
coverage==7.3.2
8-
pre-commit==3.5.0
9-
pytest==7.4.3
10-
pytest-cov==4.1.0
5+
black==24.4.2
6+
codespell==2.3.0
7+
coverage==7.5.4
8+
pre-commit==3.7.1; python_version >= "3.9"
9+
pre-commit==3.5.0; python_version < "3.9"
10+
pytest==8.1.2 # regression introduced in pytest 8.2.*, will be fixed in 8.3.0
11+
pytest-cov==5.0.0
1112
python-dateutil==2.8.2
12-
ruff==0.1.3
13-
tox==4.11.3
13+
ruff==0.5.0
14+
tox==4.15.1

requirements-opt.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# pinned dependencies that are optional. used to reproduce an entire development environment to use HDMF
2-
tqdm==4.66.3
3-
zarr==2.17.1
4-
linkml-runtime==1.7.4; python_version >= "3.9"
2+
tqdm==4.66.4
3+
zarr==2.18.2
4+
linkml-runtime==1.7.7; python_version >= "3.9"
55
schemasheets==0.2.1; python_version >= "3.9"
6-
oaklib==0.5.32; python_version >= "3.9"
6+
oaklib==0.6.10; python_version >= "3.9"

requirements.txt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# pinned dependencies to reproduce an entire development environment to use HDMF
2-
h5py==3.10.0
2+
h5py==3.11.0
33
importlib-resources==6.1.0; python_version < "3.9" # TODO: remove when minimum python version is 3.9
4-
jsonschema==4.19.1
5-
numpy==1.26.1
6-
pandas==2.1.2
4+
jsonschema==4.22.0
5+
numpy==1.26.4 # TODO: numpy 2.0.0 is supported by hdmf but incompatible with pandas and scipy
6+
pandas==2.2.2; python_version >= "3.9"
7+
pandas==2.1.2; python_version < "3.8" # TODO: remove when minimum python version is 3.9
78
ruamel.yaml==0.18.2
8-
scipy==1.11.3
9+
scipy==1.14.0; python_version >= "3.10"
10+
scipy==1.11.3; python_version < "3.10"

src/hdmf/build/objectmapper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ def __check_edgecases(cls, spec, value, spec_dtype): # noqa: C901
299299
cls.__check_convert_numeric(value.dtype.type)
300300
if np.issubdtype(value.dtype, np.str_):
301301
ret_dtype = 'utf8'
302-
elif np.issubdtype(value.dtype, np.string_):
302+
elif np.issubdtype(value.dtype, np.bytes_):
303303
ret_dtype = 'ascii'
304304
elif np.issubdtype(value.dtype, np.dtype('O')):
305305
# Only variable-length strings should ever appear as generic objects.

src/hdmf/common/table.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def __eq__(self, other):
235235
if isinstance(search_ids, int):
236236
search_ids = [search_ids]
237237
# Find all matching locations
238-
return np.in1d(self.data, search_ids).nonzero()[0]
238+
return np.isin(self.data, search_ids).nonzero()[0]
239239

240240
def _validate_new_data(self, data):
241241
# NOTE this may not cover all the many AbstractDataChunkIterator edge cases

tests/unit/test_io_hdf5.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,10 @@ def __assert_helper(self, a, b):
121121
# if strings, convert before comparing
122122
if b_array:
123123
if b_sub.dtype.char in ('S', 'U'):
124-
a_sub = [np.string_(s) for s in a_sub]
124+
a_sub = [np.bytes_(s) for s in a_sub]
125125
else:
126126
if a_sub.dtype.char in ('S', 'U'):
127-
b_sub = [np.string_(s) for s in b_sub]
127+
b_sub = [np.bytes_(s) for s in b_sub]
128128
equal = np.array_equal(a_sub, b_sub)
129129
else:
130130
equal = a_sub == b_sub

tests/unit/utils_test/test_docval.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -736,8 +736,12 @@ def method(self, **kwargs):
736736
self.assertEqual(method(self, np.uint(1)), np.uint(1))
737737
self.assertEqual(method(self, np.uint(2)), np.uint(2))
738738

739+
# the string rep of uint changes from numpy 1 to 2 ("1" to "np.uint64(1)"), so do not hardcode the string
740+
uint_str1 = np.uint(1).__repr__()
741+
uint_str2 = np.uint(2).__repr__()
742+
739743
msg = ("TestDocValidator.test_enum_uint.<locals>.method: "
740-
"forbidden value for 'arg1' (got 3, expected (1, 2))")
744+
"forbidden value for 'arg1' (got 3, expected (%s, %s))" % (uint_str1, uint_str2))
741745
with self.assertRaisesWith(ValueError, msg):
742746
method(self, np.uint(3))
743747

@@ -767,8 +771,11 @@ def method(self, **kwargs):
767771
self.assertEqual(method(self, 'true'), 'true')
768772
self.assertEqual(method(self, np.uint(1)), np.uint(1))
769773

774+
# the string rep of uint changes from numpy 1 to 2 ("1" to "np.uint64(1)"), so do not hardcode the string
775+
uint_str = np.uint(1).__repr__()
776+
770777
msg = ("TestDocValidator.test_enum_bool_mixed.<locals>.method: "
771-
"forbidden value for 'arg1' (got 0, expected (True, 1, 1.0, 'true', 1))")
778+
"forbidden value for 'arg1' (got 0, expected (True, 1, 1.0, 'true', %s))" % uint_str)
772779
with self.assertRaisesWith(ValueError, msg):
773780
method(self, 0)
774781

0 commit comments

Comments
 (0)