You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The elements of a NumPy array of dtype=bool actually have type np.bool and not type bool. Using such elements in any place where Nengo expects a boolean (i.e., nengo.params.BoolParam) results in a validation error.
I expect this to create an ensemble with normalize_encoders=False, since a np.bool behaves like a normal Python bool (even though np.bool is not an instance of bool).
Error message and logs
False
...
~/anaconda3/envs/gyrus/lib/python3.8/site-packages/nengo/ensemble.py in __init__(self, n_neurons, dimensions, radius, encoders, intercepts, max_rates, eval_points, n_eval_points, neuron_type, gain, bias, noise, normalize_encoders, label, seed)
171 self.neuron_type = neuron_type
172 self.noise = noise
--> 173 self.normalize_encoders = normalize_encoders
174
175 def __getitem__(self, key):
~/anaconda3/envs/gyrus/lib/python3.8/site-packages/nengo/base.py in __setattr__(self, name, val)
106 SyntaxWarning,
107 )
--> 108 super().__setattr__(name, val)
109
110 def __str__(self):
~/anaconda3/envs/gyrus/lib/python3.8/site-packages/nengo/config.py in __setattr__(self, name, val)
482 except ValidationError as e:
483 exc_info = sys.exc_info()
--> 484 raise exc_info[1].with_traceback(None) from e
485 else:
486 super().__setattr__(name, val)
ValidationError: Ensemble.normalize_encoders: Must be of type 'bool' (got type 'bool_').
Versions
OS: Ubuntu
Python: Anaconda Python 3.8
Nengo: nengo==3.1.0
Other: numpy==1.17.4
Additional context
This sort of thing can happen when putting Nengo code inside of np.vectorize calls, which will convert bool arguments into np.bool. For example, this raises the same validation error:
Describe the bug
The elements of a NumPy array of
dtype=bool
actually have typenp.bool
and not typebool
. Using such elements in any place where Nengo expects a boolean (i.e.,nengo.params.BoolParam
) results in a validation error.To reproduce
A minimal code snippet to reproduce the behavior:
Expected behavior
I expect this to create an ensemble with
normalize_encoders=False
, since anp.bool
behaves like a normal Pythonbool
(even thoughnp.bool
is not an instance ofbool
).Error message and logs
Versions
nengo==3.1.0
numpy==1.17.4
Additional context
This sort of thing can happen when putting Nengo code inside of
np.vectorize
calls, which will convertbool
arguments intonp.bool
. For example, this raises the same validation error:This issue was found in connection with nengo/nengo-gyrus#5.
The text was updated successfully, but these errors were encountered: