Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: small fixes to make unit tests pass for numpy<2 and pandas<2 #66

Merged
merged 3 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 \
mbaak marked this conversation as resolved.
Show resolved Hide resolved
self.nanflow == other.nanflow and numeq(self.origin, other.origin)

def __ne__(self, other):
Expand Down
11 changes: 4 additions & 7 deletions histogrammar/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,19 @@


# Resources lookup file for histogrammar

import pathlib
from pkg_resources import resource_filename
import histogrammar as hg
from importlib import resources


# data files that are shipped with histogrammar.
_DATA = {
_.name: _
for _ in pathlib.Path(resource_filename(hg.__name__, "test_data")).glob("*")
for _ in resources.files("histogrammar.test_data").iterdir()
mbaak marked this conversation as resolved.
Show resolved Hide resolved
}

# Tutorial notebooks
_NOTEBOOK = {
_.name: _
for _ in pathlib.Path(resource_filename(hg.__name__, "notebooks")).glob("*.ipynb")
p.name: p
for p in resources.files("histogrammar.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
Loading