Skip to content

Commit c122f9e

Browse files
author
Mateusz Kopeć
committed
- Update np.unicode_ -> np.str_
- Sort json keys for assertion error message
1 parent 6832729 commit c122f9e

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

CHANGES.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Release notes
44

55
Version 1.0.34, Dec 2024
66
------------------------
7-
* Support numpy >= 2.0.0 (np.string_ -> np.bytes_).
7+
* Support numpy >= 2.0.0 (np.string_ -> np.bytes_, np.unicode_ -> np.str_).
88
* Fix test utility corner case error (test_numpy.twosigfigs function).
99
* Fix typo in build pipeline Python versions config list.
1010
* Fix 4 failing tests of SparselyBin.

histogrammar/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ def function(datum):
318318
context.update(datum) # use its items as variables
319319

320320
# 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):
321+
elif numpy is not None and isinstance(datum, numpy._core.records.recarray):
322322
context.update(dict((n, datum[n]) for n in datum.dtype.names))
323323

324324
# if the datum is a Pandas DataFrame, override the namespace with its column names

tests/test_numpy.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def compare(self, name, hnp, npdata, hpy, pydata):
239239
hnp.fill.numpy(npdata)
240240
numpyTime = time.time() - startTime
241241

242-
if pydata.dtype != numpy.unicode_:
242+
if pydata.dtype != numpy.str_:
243243
for key in npdata:
244244
diff = (npdata[key] != npdata2[key]) & numpy.bitwise_not(
245245
numpy.isnan(npdata[key])) & numpy.bitwise_not(numpy.isnan(npdata2[key]))
@@ -257,7 +257,7 @@ def compare(self, name, hnp, npdata, hpy, pydata):
257257

258258
startTime = time.time()
259259
for d in pydata:
260-
if isinstance(d, numpy.unicode_):
260+
if isinstance(d, numpy.str_):
261261
d = str(d)
262262
else:
263263
d = float(d)
@@ -266,7 +266,7 @@ def compare(self, name, hnp, npdata, hpy, pydata):
266266

267267
for h in [hpy2, hpy3, hpy3]:
268268
for d in pydata:
269-
if isinstance(d, numpy.unicode_):
269+
if isinstance(d, numpy.str_):
270270
d = str(d)
271271
else:
272272
d = float(d)
@@ -278,8 +278,8 @@ def compare(self, name, hnp, npdata, hpy, pydata):
278278
assert (hpy + hpy.zero()) == hpy2
279279
assert (hpy.zero() + hpy) == hpy2
280280

281-
hnpj = json.dumps(hnp.toJson())
282-
hpyj = json.dumps(hpy.toJson())
281+
hnpj = json.dumps(hnp.toJson(), sort_keys=True)
282+
hpyj = json.dumps(hpy.toJson(), sort_keys=True)
283283

284284
if Factory.fromJson(hnp.toJson()) != Factory.fromJson(hpy.toJson()):
285285
raise AssertionError("\n numpy: {0}\npython: {1}".format(hnpj, hpyj))

0 commit comments

Comments
 (0)