Skip to content

Commit

Permalink
Merge pull request #66 from histogrammar/fix_unit_tests
Browse files Browse the repository at this point in the history
FIX: small fixes to make unit tests pass for numpy<2 and pandas<2
  • Loading branch information
mbaak authored Dec 9, 2024
2 parents 2a70935 + 0abadbb commit 50b76a5
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion histogrammar/primitives/sparselybin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
12 changes: 5 additions & 7 deletions histogrammar/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ jupyter_client>=5.2.3
ipykernel>=5.1.3
pre-commit>=2.9.0
matplotlib
pandas
pandas<2.0.0
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
numpy>=1.18.0
numpy<2.0.0
tqdm
joblib>=0.14.0
4 changes: 2 additions & 2 deletions tests/test_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
5 changes: 5 additions & 0 deletions tests/test_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit 50b76a5

Please sign in to comment.