neurolib
neurolib copied to clipboard
ParameterSpace can't initialize if n_pars=2 and values are not 1d (assumes boundaries)
from neurolib.utils.parameterSpace import ParameterSpace
shape = 2
n_pars = 2
pars = [np.random.rand(shape, shape) for i in range(n_pars)]
parameters = ParameterSpace({"p": pars})
Returns
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-34-8e5c938267d2> in <module>
----> 1 parameters = ParameterSpace({"p": pars})
~/Documents/PhD/projects/neurolib/neurolib/utils/parameterSpace.py in __init__(self, parameters, parameterValues, kind, allow_star_notation)
36 parameters, dict
37 ), "Parameters must be a dict, if no values are given in `parameterValues`"
---> 38 processedParameters = self._processParameterDict(parameters)
39 else:
40 # check if all names are strings
~/Documents/PhD/projects/neurolib/neurolib/utils/parameterSpace.py in _processParameterDict(self, parameters)
180 if self.kind == "bound":
181 # check the boundaries
--> 182 self._validate_param_bounds(list(parameters.values()))
183
184 # set all parameters as attributes for easy access
~/Documents/PhD/projects/neurolib/neurolib/utils/parameterSpace.py in _validate_param_bounds(self, param_bounds)
142 # check every single parameter bound
143 for single_bound in param_bounds:
--> 144 self._validate_single_bound(single_bound)
145
146 def _processParameterDict(self, parameters):
~/Documents/PhD/projects/neurolib/neurolib/utils/parameterSpace.py in _validate_single_bound(single_bound)
129 ), "An error occured while validating the ParameterSpace of kind 'bound': Only two bounds (min and max) are allowed"
130 assert (
--> 131 single_bound[1] > single_bound[0]
132 ), "An error occured while validating the ParameterSpace of kind 'bound': Minimum parameter value can't be larger than the maximum!"
133
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Works for n_pars = 3
. ParameterSpace
assumes boundaries which it shouldn't