Skip to content

Commit f0b9f72

Browse files
authored
Merge pull request #65 from mkopec87/fix/failing-tests-and-numpy-update
Support Numpy >= 2.0.0 and Pandas >= 2.0.0
2 parents 50b76a5 + d0cdc41 commit f0b9f72

File tree

11 files changed

+316
-314
lines changed

11 files changed

+316
-314
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,6 @@ ENV/
9595

9696
# Rope project settings
9797
.ropeproject
98+
99+
# tests output files
100+
histogrammar/notebooks/*.json

CHANGES.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@
22
Release notes
33
=============
44

5+
Version 1.0.34, Dec 2024
6+
------------------------
7+
* Fix typo in build pipeline Python versions config list.
8+
* Fix error in SparselyBin __eq__ method.
9+
* Fix test utility corner case error (test_numpy.twosigfigs function).
10+
* Fix error in test context manager for pandas which prevented execution of tests.
11+
* Fix error in expected bin count in test_numpy.test_n_bins test.
12+
* Prevent logging zero execution time TestNumpy class.
13+
14+
* Remove Python 3.8 environment from build pipeline.
15+
* Support numpy >= 2.0.0 (np.string_ -> np.bytes_, np.unicode_ -> np.str_).
16+
* Remove uses of pd.util.testing.makeMixedDataFrame not available in pandas >= 2.0.0.
17+
* Switch from 'pkg_resources' to 'importlib' module for resolving package files.
18+
* Switch from 'distutils.spawn' to 'shutil.which' for finding nvcc command.
19+
20+
* Remove unused test_gpu.twosigfigs function.
21+
* Refactor tests with Numpy() and Pandas() context managers to use single 'with' statement.
22+
523
Version 1.0.33, Dec 2022
624
------------------------
725
* fix of get_sub_hist() when Bin histogram is filled only with nans.

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ PyCUDA is available, they can also be filled from Numpy arrays by JIT-compiling
2020

2121
This Python implementation of histogrammar been tested to guarantee compatibility with its Scala implementation.
2222

23-
Latest Python release: v1.0.33 (Dec 2022).
24-
Latest update: Dec 2023.
23+
Latest Python release: v1.0.34 (Dec 2024).
24+
Latest update: Dec 2024.
2525

2626
Announcements
2727
=============

histogrammar/dfinterface/filling_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def normalize_dtype(dtype):
4949
# this converts pandas types, such as pd.Int64, into numpy types
5050
dtype = type(dtype.type())
5151
dtype = np.dtype(dtype).type
52-
if dtype in {np.str_, np.string_}:
52+
if dtype in {np.str_, np.bytes_}:
5353
dtype = np.dtype(str).type
5454
# MB 20210404: nb.object_ is kept an object -> uses to_string(). str uses only_str()
5555
except BaseException:
@@ -116,7 +116,7 @@ def only_str(val):
116116
elif isinstance(val, pd.Series):
117117
# at this point, data type of pd.series has already been inferred as *to be* 'string'
118118
dtype = np.dtype(val.dtype).type
119-
return val.values if dtype in [str, np.str_, np.string_] else val.astype(str).values
119+
return val.values if dtype in [str, np.str_, np.bytes_] else val.astype(str).values
120120
elif hasattr(val, "__iter__"):
121121
return np.asarray([s if isinstance(s, str) else "None" for s in val])
122122
return "None"

histogrammar/util.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import histogrammar.pycparser.c_ast
2323

24-
# Definitions for python 2/3 compatability
24+
# Definitions for python 2/3 compatibility
2525
if sys.version_info[0] > 2:
2626
basestring = str
2727
xrange = range
@@ -312,13 +312,15 @@ def function(datum):
312312
if numpy is not None:
313313
context["numpy"] = numpy
314314
context["np"] = numpy
315+
major = int(numpy.__version__.split('.')[0])
316+
npcore = numpy._core if major > 1 else numpy.core
315317

316318
# if the datum is a dict, override the namespace with its dict keys
317319
if isinstance(datum, dict): # if it's a dict
318320
context.update(datum) # use its items as variables
319321

320322
# if the datum is a Numpy record array, override the namespace with its field names
321-
elif numpy is not None and isinstance(datum, numpy.core.records.recarray):
323+
elif numpy is not None and isinstance(datum, npcore.records.recarray):
322324
context.update(dict((n, datum[n]) for n in datum.dtype.names))
323325

324326
# if the datum is a Pandas DataFrame, override the namespace with its column names
@@ -584,7 +586,7 @@ def get_datatype(hist, itr=0):
584586
keys = list(hist.bins.keys())
585587
dt = type(keys[0]) if len(keys) > 0 else str
586588
dt = np.dtype(dt).type
587-
if (dt is np.str_) or (dt is np.string_) or (dt is np.object_):
589+
if (dt is np.str_) or (dt is np.bytes_) or (dt is np.object_):
588590
dt = str
589591
datatype = [dt]
590592
else:

histogrammar/version.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import re
44

55
name = "histogrammar"
6-
__version__ = "1.0.33"
7-
version = "1.0.33"
8-
full_version = "1.0.33"
6+
__version__ = "1.0.34"
7+
version = "1.0.34"
8+
full_version = "1.0.34"
99
release = True
1010

1111
version_info = tuple(re.split(r"[-\.]", __version__))

requirements-test.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ jupyter_client>=5.2.3
44
ipykernel>=5.1.3
55
pre-commit>=2.9.0
66
matplotlib
7-
pandas<2.0.0
7+
pandas

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
numpy<2.0.0
1+
numpy
22
tqdm
33
joblib>=0.14.0

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
MAJOR = 1
2424
REVISION = 0
25-
PATCH = 33
25+
PATCH = 34
2626
DEV = False
2727
# NOTE: also update version at: README.rst and update CHANGES.rst
2828

tests/test_gpu.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,6 @@ def runNumpy(self, aggregator, expected):
109109
self.assertEqual(aggregator.toImmutable(), duplicate.toImmutable())
110110
self.assertEqual(aggregator, duplicate)
111111

112-
def twosigfigs(self, number):
113-
return round(number, 1 - int(math.floor(math.log10(number))))
114-
115112
def compare(self, name, hgpu, hpy, pydata, debug=False):
116113
sys.stderr.write(name + "\n")
117114

0 commit comments

Comments
 (0)