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

np.int removed from numpy causes error for hopfield_dynamics.pattern_tools.py #25

Open
mwatts15 opened this issue Jul 14, 2023 · 0 comments

Comments

@mwatts15
Copy link

In executing the create_checkerboard function and a couple others, you'd get an error like the one below rather than having the expected pattern returned. This is due to removal of a previously deprecated attribute .int from numpy. Replacing it with builtin int as suggested resolves the issue.

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[1], line 11
      9 factory = pattern_tools.PatternFactory(pattern_size, pattern_size)
     10 # create a checkerboard pattern and add it to the pattern list
---> 11 checkerboard = factory.create_checkerboard()
     12 pattern_list = [checkerboard]
     14 # add random patterns to the list

File ~/work/neuronal-dynamics/bmnn/lib/python3.11/site-packages/neurodynex3/hopfield_network/pattern_tools.py:116, in PatternFactory.create_checkerboard(self)
    110 def create_checkerboard(self):
    111     """
    112     creates a checkerboard pattern of size (pattern_length x pattern_width)
    113     Returns:
    114         checkerboard pattern
    115     """
--> 116     pw = np.ones(self.pattern_length, np.int)
    117     # set every second value to -1
    118     pw[1::2] = -1

File ~/work/neuronal-dynamics/bmnn/lib/python3.11/site-packages/numpy/__init__.py:313, in __getattr__(attr)
    308     warnings.warn(
    309         f"In the future `np.{attr}` will be defined as the "
    310         "corresponding NumPy scalar.", FutureWarning, stacklevel=2)
    312 if attr in __former_attrs__:
--> 313     raise AttributeError(__former_attrs__[attr])
    315 if attr == 'testing':
    316     import numpy.testing as testing

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
mwatts15 added a commit to mwatts15/neuronaldynamics-exercises that referenced this issue Jul 14, 2023
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

1 participant