wtclarke / pymapvbvd

Python port of mapVBVD
MIT License
44 stars 25 forks source link

Conversion of an array with ndim > 0 to a scalar is deprecated #42

Closed musicinmybrain closed 9 months ago

musicinmybrain commented 1 year ago
python3.11 -m venv _e
. _e/bin/activate
pip install -e .[tests]
python -m pytest
================================ warnings summary ================================
tests/test_flags.py: 6 warnings
tests/test_read.py: 4 warnings
tests/test_svs.py: 2 warnings
  /home/ben/src/forks/pymapvbvd/mapvbvd/mapVBVD.py:343: DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)
    measOffset[k] = np.fromfile(fid, dtype=np.uint64, count=1, offset=0)

tests/test_flags.py: 6 warnings
tests/test_read.py: 4 warnings
tests/test_svs.py: 2 warnings
  /home/ben/src/forks/pymapvbvd/mapvbvd/mapVBVD.py:344: DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)
    measLength[k] = np.fromfile(fid, dtype=np.uint64, count=1, offset=0)

tests/test_flags.py::test_flagRemoveOS
tests/test_flags.py::test_flagIgnoreSeg_flagDoAverage
tests/test_flags.py::test_flagSkipToFirstLine
tests/test_read.py::test_gre
tests/test_read.py::test_epi
tests/test_svs.py::test_ve
  /home/ben/src/forks/pymapvbvd/mapvbvd/mapVBVD.py:125: DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)
    ulDMALength = float(tmp)

tests/test_flags.py: 6 warnings
tests/test_read.py: 4 warnings
tests/test_slicing.py: 1 warning
tests/test_svs.py: 3 warnings
  /home/ben/src/forks/pymapvbvd/mapvbvd/mapVBVD.py:111: DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)
    ulDMALength = float(tmp)

The easiest way to fix the DeprecationWarning is to use the numpy.ndarray.item() method whenever you need to get the scalar from a single-element array. PR to follow.