Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: module 'numpy' has no attribute 'int'. np.int was a deprecated alias for the builtin int #14

Open
bpsut opened this issue May 11, 2023 · 1 comment

Comments

@bpsut
Copy link

bpsut commented May 11, 2023

I was trying to run this sir.fit(X, Y) and ran into the above issue with numpy 1.24

It looks like an easy fix to swap line 119 of base.py to one of the following:
slice_indicator = np.ones(y.shape[0], dtype=int)
slice_indicator = np.ones(y.shape[0], dtype=int32)
slice_indicator = np.ones(y.shape[0], dtype=int64)

Full AttributeError:

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
@rafe-sh
Copy link

rafe-sh commented Dec 24, 2023

Based on the provided information, it appears that you encountered an issue with the numpy module when using the sir.fit(X, Y) line of code. The error message suggests that the module does not have an attribute called int. This issue is related to a deprecation in numpy version 1.20 where aliases for built-in types, such as np.int, were deprecated.

To fix this issue, you can swap line 119 of the base.py file with one of the following options:

slice_indicator = np.ones(y.shape[0], dtype=int)
slice_indicator = np.ones(y.shape[0], dtype=np.int32)
slice_indicator = np.ones(y.shape[0], dtype=np.int64)

The first option uses the built-in int type, which is recommended. The second and third options specify the precision by using np.int32 or np.int64 respectively.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants