Closed mhvwerts closed 9 months ago
A potential fix might be to use the array method .item()
without any arguments, which should return a scalar from a single-element array.
https://numpy.org/doc/stable/reference/generated/numpy.ndarray.item.html
I just checked it with the new numpy
. It happens only with 1D arrays, when the array has only a single item. The easiest way is to index into a, b, and c as a[0]
, b[0]
, and c[0]
.
Indeed, that gives the same result as the item()
method, if I am correct.
The advantage of .item()
(without arguments) is that it will raise an error if the array somehow would not have a single item. This should not happen, of course, but it may be a good protection against programming errors that would otherwise go unnoticed and lead to unexpected results.
Just pushed the changes directly to Main (will create a pull request next time; just tired now :-)). The test did not create any warnings on my machine with the new version of numpy
.
It works for me as well. Great work. Many thanks.
I needed to install a new Python stack and one of the effects is that I now have numpy version 1.26.2 (I still use Python 3.9). When running a quick
pytest
to see if my installation was OK for continuing to work, I discovered quite a list of newDeprecationWarnings
.I do not have time to look into this further now. I record some of the warnings here, so that we fix them in some near future.