scikit-learn-contrib / py-earth

A Python implementation of Jerome Friedman's Multivariate Adaptive Regression Splines
http://contrib.scikit-learn.org/py-earth/
BSD 3-Clause "New" or "Revised" License
455 stars 121 forks source link

Py-earth and numpy 1.25 #227

Open pgr123 opened 11 months ago

pgr123 commented 11 months ago

I update numpy to the 1.25.1 version and now I got an error with py-earth (np.int is deprecated ...). Does anyone try to use py-earth with numpy 1.25.1 and/or know how to modify the code to avoid the error ? Thank you very much. Have a good day.

pgr123 commented 11 months ago

Here is the error I get when I try the example plot_v_function.py with numpy 1.25.1 :

Traceback (most recent call last):
  File "/home/pascal/Bureau/plot_v_function.py", line 12, in <module>
    from pyearth import Earth
  File "/usr/lib/python3/dist-packages/pyearth/__init__.py", line 6, in <module>
    from .earth import Earth
  File "/usr/lib/python3/dist-packages/pyearth/earth.py", line 1, in <module>
    from ._forward import ForwardPasser
  File "pyearth/_forward.pyx", line 1, in init pyearth._forward
  File "pyearth/_basis.pyx", line 12, in init pyearth._basis
  File "pyearth/_types.pyx", line 3, in init pyearth._types
  File "/home/pascal/.local/lib/python3.10/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

Can someone help me ? What can I do ? Thank you.

MJuddBooth commented 10 months ago

Try my new pull request. It works for me.

pgr123 commented 10 months ago

Thank you, I'll try it. Have a good weekend.