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

ParameterSpace can't initialize if n_pars=2 and values are not 1d (assumes boundaries) #170

Open
caglorithm opened this issue Jun 28, 2021 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@caglorithm
Copy link
Member

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

@caglorithm caglorithm added the bug Something isn't working label Jun 28, 2021
@caglorithm caglorithm self-assigned this Jul 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant