neurolib icon indicating copy to clipboard operation
neurolib copied to clipboard

parameters.getRandom() fails if parameters are not 1d

Open caglorithm opened this issue 4 years ago • 0 comments

from neurolib.utils.parameterSpace import ParameterSpace
shape = 4
pars = [np.random.rand(shape, shape) for i in range(10)]
parameters = ParameterSpace({"p": pars})
parameters.getRandom()

Returns

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-32-1b6c4906dd1f> in <module>
----> 1 parameters.getRandom()

~/Documents/PhD/projects/neurolib/neurolib/utils/parameterSpace.py in getRandom(self, safe)
     97         else:
     98             for key, value in self.parameters.items():
---> 99                 randomPar[key] = np.random.choice(value)
    100         return randomPar
    101 

mtrand.pyx in numpy.random.mtrand.RandomState.choice()

ValueError: a must be 1-dimensional

Needs fix.

caglorithm avatar Jun 28 '21 09:06 caglorithm