diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f8f2c60..4e10c0e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - python: [3.8, 3.9, 3.10,13, 3.11, 3.12] + python: ['3.9', '3.10', '3.11', '3.12'] runs-on: ${{ matrix.os }} steps: diff --git a/histogrammar/notebooks/__init__.py b/histogrammar/notebooks/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/histogrammar/primitives/sparselybin.py b/histogrammar/primitives/sparselybin.py index e3f1c7f..4c2f227 100644 --- a/histogrammar/primitives/sparselybin.py +++ b/histogrammar/primitives/sparselybin.py @@ -657,7 +657,7 @@ def __repr__(self): def __eq__(self, other): return isinstance(other, SparselyBin) and numeq(self.binWidth, other.binWidth) and \ - self.quantity == other.quantity and numeq(self.entries, other.entries) and self.bins == other.bins and \ + self.quantity == other.quantity and numeq(self.entries, other.entries) and sorted(self.bins) == sorted(other.bins) and \ self.nanflow == other.nanflow and numeq(self.origin, other.origin) def __ne__(self, other): diff --git a/histogrammar/resources.py b/histogrammar/resources.py index b347116..2c67cf2 100644 --- a/histogrammar/resources.py +++ b/histogrammar/resources.py @@ -19,22 +19,20 @@ # Resources lookup file for histogrammar - -import pathlib -from pkg_resources import resource_filename -import histogrammar as hg +from importlib import resources +from histogrammar import test_data, notebooks # data files that are shipped with histogrammar. _DATA = { _.name: _ - for _ in pathlib.Path(resource_filename(hg.__name__, "test_data")).glob("*") + for _ in resources.files(test_data).iterdir() } # Tutorial notebooks _NOTEBOOK = { - _.name: _ - for _ in pathlib.Path(resource_filename(hg.__name__, "notebooks")).glob("*.ipynb") + p.name: p + for p in resources.files(notebooks).iterdir() if p.suffix == ".ipynb" } # Resource types diff --git a/histogrammar/test_data/__init__.py b/histogrammar/test_data/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/requirements-test.txt b/requirements-test.txt index 9272284..3dbc8db 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -4,4 +4,4 @@ jupyter_client>=5.2.3 ipykernel>=5.1.3 pre-commit>=2.9.0 matplotlib -pandas \ No newline at end of file +pandas<2.0.0 diff --git a/requirements.txt b/requirements.txt index 28d93ce..100320e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -numpy>=1.18.0 +numpy<2.0.0 tqdm joblib>=0.14.0 diff --git a/tests/test_gpu.py b/tests/test_gpu.py index 55800d2..e624111 100644 --- a/tests/test_gpu.py +++ b/tests/test_gpu.py @@ -16,10 +16,10 @@ import json import math +import shutil import subprocess import sys import unittest -from distutils import spawn from histogrammar.defs import Factory from histogrammar.primitives.average import Average @@ -54,7 +54,7 @@ class TestGPU(unittest.TestCase): except ImportError: numpy = None - nvcc = spawn.find_executable("nvcc") + nvcc = shutil.which("nvcc") def runTest(self): self.testCount() diff --git a/tests/test_numpy.py b/tests/test_numpy.py index 54f80cf..8d57f19 100644 --- a/tests/test_numpy.py +++ b/tests/test_numpy.py @@ -236,6 +236,9 @@ def compare(self, name, hnp, npdata, hpy, pydata): startTime = time.time() hnp.fill.numpy(npdata) numpyTime = time.time() - startTime + # protect against zero time. + numpyTime = max(numpyTime, 1e-10) + if pydata.dtype != numpy.unicode_: for key in npdata: @@ -261,6 +264,8 @@ def compare(self, name, hnp, npdata, hpy, pydata): d = float(d) hpy.fill(d) pyTime = time.time() - startTime + # protect against zero time. + pyTime = max(pyTime, 1e-10) for h in [hpy2, hpy3, hpy3]: for d in pydata: