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.bool deprecated in Numpy >= 1.20 #189

Open
xchoo opened this issue Jun 30, 2023 · 0 comments
Open

np.bool deprecated in Numpy >= 1.20 #189

xchoo opened this issue Jun 30, 2023 · 0 comments

Comments

@xchoo
Copy link
Member

xchoo commented Jun 30, 2023

When using NengoOCL with Numpy >= 1.20, the following error can occur:

Traceback (most recent call last):
  File "run_spaun.py", line 748, in <module>
    sim = nengo_ocl.Simulator(model, dt=cfg.sim_dt, context=ctx,
  File "/home/xchoo/miniconda3/envs/spaun/lib/python3.8/site-packages/nengo_ocl/simulator.py", line 363, in __init__
    plans.extend(self._plan_op_group(op_type, op_list))
  File "/home/xchoo/miniconda3/envs/spaun/lib/python3.8/site-packages/nengo_ocl/simulator.py", line 742, in _plan_op_group
    return getattr(self, "_plan_" + op_type.__name__)(ops)
  File "/home/xchoo/miniconda3/envs/spaun/lib/python3.8/site-packages/nengo_ocl/simulator.py", line 867, in _plan_Copy
    if any(dupl(i) for i in xinds) or any(dupl(i) for i in yinds):
  File "/home/xchoo/miniconda3/envs/spaun/lib/python3.8/site-packages/nengo_ocl/simulator.py", line 867, in <genexpr>
    if any(dupl(i) for i in xinds) or any(dupl(i) for i in yinds):
  File "/home/xchoo/miniconda3/envs/spaun/lib/python3.8/site-packages/nengo_ocl/simulator.py", line 864, in <lambda>
    and not (isinstance(s, np.ndarray) and s.dtype == np.bool)
  File "/home/xchoo/miniconda3/envs/spaun/lib/python3.8/site-packages/numpy/__init__.py", line 305, in __getattr__
    raise AttributeError(__former_attrs__[attr])
AttributeError: module 'numpy' has no attribute 'bool'.
`np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.
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

Changing np.bool to bool seems to rectify this issue with no (apparent) side-effects.

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

No branches or pull requests

1 participant