dtcwt icon indicating copy to clipboard operation
dtcwt copied to clipboard

fix:deprecated numpy type

Open zar3bski opened this issue 2 years ago • 7 comments

Stacktrace motivating this PR

I experienced the following issue while using dtcwt.Transform1d.forward

  File "/home/zar3bski/Documents/Code/data/wavaetro/wavaestro/loader.py", line 29, in load_initial_dataset
    vecs_t = transform.forward(signal, nlevels=5)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/zar3bski/.cache/pypoetry/virtualenvs/wavaetro--xUrs-Fb-py3.11/lib/python3.11/site-packages/dtcwt/numpy/transform1d.py", line 86, in forward
    Hi = colfilter(X, h1o)
         ^^^^^^^^^^^^^^^^^
  File "/home/zar3bski/.cache/pypoetry/virtualenvs/wavaetro--xUrs-Fb-py3.11/lib/python3.11/site-packages/dtcwt/numpy/lowlevel.py", line 74, in colfilter
    xe = reflect(np.arange(-m2, r+m2, dtype=np.int), -0.5, r-0.5)
                                            ^^^^^^
  File "/home/zar3bski/.cache/pypoetry/virtualenvs/wavaetro--xUrs-Fb-py3.11/lib/python3.11/site-packages/numpy/__init__.py", line 313, in __getattr__
    raise AttributeError(__former_attrs__[attr])
AttributeError: module 'numpy' has no attribute 'int'.
`np.int` was a deprecated alias for the builtin `int`. To avoid this error in existing code, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations. Did you mean: 'inf'?

Environment

  • dtcwt 0.12.0
  • numpy 1.25.0
  • Python 3.11.2

Precision required?

I went with int64, not sure whether this is an overkill for the current need

zar3bski avatar Jul 03 '23 13:07 zar3bski

@rjw57 rjw57 I fixed the tests. There is one failing but I do not quite get the reason:

test_registration.py::test_estimatereg - ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (3,) + inhomogeneous part.

zar3bski avatar Jul 11 '23 09:07 zar3bski

@rjw57 - Just drawing attention to this as I've been having the same issue.

Also, @zar3bski: Is there value in using np.int64 or np.int32 over the native python int? [useful thread]

john-but-actually-jon avatar Jul 19 '23 08:07 john-but-actually-jon

@rjw57 - Just drawing attention to this as I've been having the same issue.

Also, @zar3bski: Is there value in using np.int64 or np.int32 over the native python int? [useful thread]

Yes, because numpy arrays relies on these specific types for memory allocation rather than Python built in types

zar3bski avatar Jul 19 '23 08:07 zar3bski

@rjw57 Any plan to merge this soon? This is needed to make dtcwt work with new versions of numpy :)

mrava87 avatar Oct 07 '23 17:10 mrava87

Hello, @xir4n and I are encountering the same problem as others. It would be good to merge this and release a new version of dtcwt on PyPI, so that current versions of NumPy (and Python itself) can be supported.

lostanlen avatar Feb 14 '24 08:02 lostanlen

Hello everyone, with permission from @rjw57, we have forked this repository with @xir4n and have merged this pull request. Our fork lives here: https://github.com/xir4n/dtcwt.git and supports current versions of NumPy and Python.

lostanlen avatar Feb 19 '24 15:02 lostanlen

Hello everyone, with permission from @rjw57, we have forked this repository with @xir4n and have merged this pull request.

I've asked @lostanlen and @xir4n for their PyPI usernames so they can upload a release there too.

rjw57 avatar Feb 19 '24 16:02 rjw57