Skip to content

Commit

Permalink
Support numpy 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ajelenak committed Aug 4, 2024
1 parent c56250c commit e2c26a5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ keywords = ["json", "hdf5", "multidimensional array", "data", "datacube"]
requires-python = ">=3.8"
dependencies = [
"h5py >=3.10",
"numpy >=1.20,<2.0.0",
"numpy >= 2.0",
"jsonschema >=4.4.0",
"tomli; python_version<'3.11'",
"numpy >=1.20,<2.0.0; python_version='3.8'",
]
dynamic = ["version"]

Expand Down
8 changes: 1 addition & 7 deletions src/h5json/hdf5db.py
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,7 @@ def getAttributeItemByObj(self, obj, name, includeData=True):
return None

# get the attribute!
attrObj = h5py.h5a.open(obj.id, np.string_(name))
attrObj = h5py.h5a.open(obj.id, np.bytes_(name))
attr = None

item = {"name": name}
Expand Down Expand Up @@ -1578,7 +1578,6 @@ def getDataValue(self, typeItem, value, dimension=0, dims=None):
if isinstance(value, (np.ndarray, np.generic)):
value = value.tolist() # convert numpy object to list
if typeClass == "H5T_COMPOUND":

if type(value) not in (list, tuple):
msg = "Unexpected type for compound value"
self.log.error(msg)
Expand Down Expand Up @@ -1645,7 +1644,6 @@ def getRefValue(self, typeItem: dict, value: list):
out = None
typeClass = typeItem["class"]
if typeClass == "H5T_COMPOUND":

if not isinstance(value, (list, tuple)):
msg = f"Unexpected type for compound value: {type(value)}"
self.log.error(msg)
Expand Down Expand Up @@ -1702,7 +1700,6 @@ def getRefValue(self, typeItem: dict, value: list):
"""

def toNumPyValue(self, typeItem, src, des):

typeClass = "H5T_INTEGER" # default to int type
if type(typeItem) is dict:
typeClass = typeItem["class"]
Expand Down Expand Up @@ -1763,7 +1760,6 @@ def toNumPyValue(self, typeItem, src, des):
"""

def toNumPyArray(self, rank, typeItem, src, des):

if rank == 0:
msg = "unexpected rank value"
self.log.error(msg)
Expand Down Expand Up @@ -2681,7 +2677,6 @@ def setDatasetValuesByPointSelection(self, obj_uuid, data, points, format="json"
# data = converted_data

if format == "json":

try:
i = 0
for point in points:
Expand Down Expand Up @@ -3373,7 +3368,6 @@ def unlinkObjectItem(self, parentGrp, tgtObj, link_name):
if linkClass == "HardLink":
obj = parentGrp[link_name]
if tgtObj is None or obj == tgtObj:

numlinks = self.getNumLinksToObject(obj)
if numlinks == 1:
# last link to this object - convert to anonymous object by
Expand Down

0 comments on commit e2c26a5

Please sign in to comment.