Skip to content

Commit

Permalink
fix: hash_root_file AttributeError: no field named 'to_numpy' (#1129)
Browse files Browse the repository at this point in the history
With my installation
```
ROOT_HASH_CHECKS=on pytest
```
fails with errors like
```
FAILED src/Examples/Python/tests/test_examples.py::test_particle_gun - AttributeError: no field named 'to_numpy'
/cvmfs/sft.cern.ch/lcg/views/LCG_101/x86_64-centos7-gcc11-opt/lib/python3.9/site-packages/awkward/highlevel.py:1123: AttributeError
```
I'm using `LCG_101` which has Python 3.9 and `awkward` 1.0.2. It seems that `obj.to_numpy()` is not supported in this version, but `awkward.to_numpy(obj)` is.

Can someone advise whether this is likely OK for other installations?
  • Loading branch information
timadye committed Jan 7, 2022
1 parent a8b0393 commit 4c3ddcf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Examples/Python/tests/helpers/hash_root.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ def hash_root_file(path: Path, ordering_invariant: bool = True) -> str:
for obj in row:
if isinstance(obj, ak.highlevel.Array):
if obj.ndim == 1:
h.update(obj.to_numpy().tobytes())
h.update(ak.to_numpy(obj).tobytes())
else:
arr = ak.flatten(obj, axis=None).to_numpy()
arr = ak.to_numpy(ak.flatten(obj, axis=None))
h.update(arr.tobytes())
else:
h.update(np.array([obj]).tobytes())
Expand Down

0 comments on commit 4c3ddcf

Please sign in to comment.