Skip to content

Commit

Permalink
Replace distutils with packaging for version parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjala committed Mar 21, 2024
1 parent 493c409 commit 8f50278
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 14 deletions.
10 changes: 6 additions & 4 deletions h5pyd/_hl/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1775,7 +1775,7 @@ def write_dset_tl(self, args):
Thread-local method to write to a single dataset
"""
dset = args[0]
idx = args[1]
# idx = args[1]
write_args = args[2]
write_vals = args[3]
try:
Expand All @@ -1785,7 +1785,7 @@ def write_dset_tl(self, args):
return

def __getitem__(self, args):
"""
"""
Read the same slice from each of the datasets
managed by this MultiManager.
"""
Expand Down Expand Up @@ -1824,7 +1824,8 @@ def __getitem__(self, args):
# TODO: Handle the case where some or all datasets share an HTTPConn object

with ThreadPoolExecutor(max_workers=self.max_workers) as executor:
read_futures = [executor.submit(self.read_dset_tl, (self.datasets[i], i, args)) for i in range(len(self.datasets))]
read_futures = [executor.submit(self.read_dset_tl,
(self.datasets[i], i, args)) for i in range(len(self.datasets))]
ret_data = [None] * len(self.datasets)

for future in as_completed(read_futures):
Expand Down Expand Up @@ -1878,7 +1879,8 @@ def __setitem__(self, args, vals):
next_port = low_port

with ThreadPoolExecutor(max_workers=self.max_workers) as executor:
write_futures = [executor.submit(self.write_dset_tl, (self.datasets[i], i, args, vals[i])) for i in range(len(self.datasets))]
write_futures = [executor.submit(self.write_dset_tl,
(self.datasets[i], i, args, vals[i])) for i in range(len(self.datasets))]

for future in as_completed(write_futures):
try:
Expand Down
2 changes: 1 addition & 1 deletion h5pyd/_hl/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ def __getitem__(self, name):
endpoint = self.id.http_conn.endpoint
username = self.id.http_conn.username
password = self.id.http_conn.password
f = File(external_domain, endpoint=endpoint, username=username, password=password, mode='r')
f = File(external_domain, endpoint=endpoint, username=username, password=password, mode='r')
except IOError:
# unable to find external link
raise KeyError("Unable to open file: " + link_json['h5domain'])
Expand Down
6 changes: 3 additions & 3 deletions h5pyd/_hl/selections.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ def __getitem__(self, args):
# raise TypeError(f'Illegal coordinate index "{arg}" must be a list of integers')

if x < 0 or x >= length:
raise IndexError(f"Index ({arg}) out of range (0-{length-1})")
raise IndexError(f"Index ({arg}) out of range (0-{length - 1})")
if prev is not None and x <= prev:
raise TypeError("Indexing elements must be in increasing order")
prev = x
Expand All @@ -528,7 +528,7 @@ def __getitem__(self, args):
select_type = H5S_SELLECT_FANCY
elif isinstance(arg, int):
if arg < 0 or arg >= length:
raise IndexError(f"Index ({arg}) out of range (0-{length-1})")
raise IndexError(f"Index ({arg}) out of range (0-{length - 1})")
slices.append(arg)
elif isinstance(arg, type(Ellipsis)):
slices.append(slice(0, length, 1))
Expand Down Expand Up @@ -659,7 +659,7 @@ def _translate_int(exp, length):
exp = length + exp

if not 0 <= exp < length:
raise IndexError(f"Index ({exp}) out of range (0-{length-1})")
raise IndexError(f"Index ({exp}) out of range (0-{length - 1})")

return exp, 1, 1

Expand Down
10 changes: 5 additions & 5 deletions h5pyd/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@

from __future__ import absolute_import

from distutils.version import StrictVersion as _sv
from packaging.version import Version, parse
import sys
import numpy

version = "0.18.0"

hdf5_version = "REST"

_exp = _sv(version)
_exp = parse(version)

version_tuple = _exp.version + (
("".join(str(x) for x in _exp.prerelease),)
if _exp.prerelease is not None
version_tuple = _exp._version + (
("".join(str(x) for x in _exp.pre),)
if _exp.is_prerelease
else ("",)
)

Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"requests_unixsocket",
"pytz",
"pyjwt",
"packaging"
# "cryptography",
],
setup_requires=["pkgconfig"],
Expand Down
2 changes: 1 addition & 1 deletion test/hl/test_vlentype.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def test_create_vlen_dset(self):
e1 = ret_val[1]
self.assertTrue(isinstance(e1, np.ndarray))
self.assertEqual(e1.shape, (0,))

# create numpy object array
e0 = np.array([1, 2, 3], dtype='uint16')
e1 = np.array([1, 2, 3, 4], dtype='uint16')
Expand Down

0 comments on commit 8f50278

Please sign in to comment.