-
Notifications
You must be signed in to change notification settings - Fork 28
Description
Describe the bug
When runing tox -e unit-tests
for newer version of Python and NumPy the following error is displayed
AttributeError: 'numpy.ndarray' object has no attribute 'tostring'
This is because the method has been deprecated since NumPy 1.19.0
https://numpy.org/doc/2.1/reference/generated/numpy.ndarray.tostring.html
To reproduce
- run
tox -e unit-tests
for numpy >= 1.19.0 and Python >= 3.9 - where the method
tostring()
is called the corresponding test will fail withAttributeError: 'numpy.ndarray' object has no attribute 'tostring'
Expected behavior
All tests should pass with no issue
Line 370 in simulator.py should use tobytes()
not tostring()
Screenshots or logs
Please see the failure here https://github.com/amazon-braket/amazon-braket-default-simulator-python/actions/runs/15591371868/job/43914410256?pr=285
System information
The error was spotted upon creating PR 285
Additional context
the issue is in simulator.py
line 370 return str(hash(str(observable.matrix.tostring())))
The issue can be addressed as part of PR 285 by substituting tostring
with tobytes