diff --git a/arf.py b/arf.py index 27f1fa9..fb0c416 100644 --- a/arf.py +++ b/arf.py @@ -53,7 +53,7 @@ def open_file(name, mode=None, driver=None, libver=None, userblock_size=None, ** """ import os import sys - from distutils.version import StrictVersion + from packaging.version import Version from h5py import File, h5p @@ -77,11 +77,11 @@ def open_file(name, mode=None, driver=None, libver=None, userblock_size=None, ** fp = File(name, mode=mode, driver=driver, libver=libver, **kwargs) else: posargs = [] - if StrictVersion(h5py_version) >= StrictVersion("2.9"): + if Version(h5py_version) >= Version("2.9"): posargs += ["rdcc_nslots", "rdcc_nbytes", "rdcc_w0"] - if StrictVersion(h5py_version) >= StrictVersion("3.5"): + if Version(h5py_version) >= Version("3.5"): posargs += ["locking", "page_buf_size", "min_meta_keep", "min_raw_keep"] - if StrictVersion(h5py_version) >= StrictVersion("3.7"): + if Version(h5py_version) >= Version("3.7"): # integer is needed kwargs.update( { @@ -89,7 +89,7 @@ def open_file(name, mode=None, driver=None, libver=None, userblock_size=None, ** for arg in ["alignment_threshold", "alignment_interval"] } ) - if StrictVersion(h5py_version) >= StrictVersion("3.8"): + if Version(h5py_version) >= Version("3.8"): posargs += ["meta_block_size"] kwargs.update({arg: kwargs.get(arg, None) for arg in posargs}) fapl = _files.make_fapl(driver, libver, **kwargs) @@ -279,7 +279,7 @@ def check_file_version(file): Returns the version for the file """ - from distutils.version import StrictVersion as Version + from packaging.version import Version try: ver = file.attrs.get("arf_version", None) diff --git a/setup.cfg b/setup.cfg index 7361234..092c7a0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -35,4 +35,9 @@ setup_requires = install_requires = numpy<2 h5py>=2.8,!=3.3.* + packaging >= 23.0 test_suite = tests + +[options.extras_require] +test = + pytest >= 7.0 diff --git a/tests/test_arf.py b/tests/test_arf.py index 17b8fe6..83c0da3 100644 --- a/tests/test_arf.py +++ b/tests/test_arf.py @@ -2,7 +2,7 @@ import time import unittest -from distutils import version +from packaging import version import numpy as nx from h5py.version import version as h5py_version @@ -30,7 +30,7 @@ ), dict( name="neural", - data=(randn(100000) * 2 ** 16).astype("h"), + data=(randn(100000) * 2**16).astype("h"), sampling_rate=20000, datatype=arf.DataTypes.EXTRAC_HP, compression=9, @@ -117,7 +117,7 @@ def test00_create_entries(self): N = 5 for i in range(N): yield self.create_entry, entry_base % i - self.assertEqual(len(self.fp), N) + assert len(self.fp) == N def test01_create_existing_entry(self): with self.assertRaises(ValueError): @@ -135,7 +135,7 @@ def test04_create_bad_dataset(self): self.create_dataset(self.entry, dset) def test05_set_attributes(self): - """ tests the set_attributes convenience function """ + """tests the set_attributes convenience function""" arf.set_attributes(self.entry, mystr="myvalue", myint=5000) self.assertEqual(self.entry.attrs["myint"], 5000) self.assertEqual(self.entry.attrs["mystr"], "myvalue") @@ -170,7 +170,7 @@ def test09_append_to_table(self): @unittest.skipIf( - version.StrictVersion(h5py_version) < version.StrictVersion("2.2"), + version.Version(h5py_version) < version.Version("2.2"), "not supported on h5py < 2.2", ) class TestArfNavigation(unittest.TestCase):