Skip to content

Commit d0cdc41

Browse files
author
Mateusz Kopeć
committed
- Support numpy < 2 and >= 2 versions
1 parent 2eeaca4 commit d0cdc41

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

histogrammar/util.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

0 commit comments

Comments
 (0)