BlueBrain / BluePyOpt

Blue Brain Python Optimisation Library
https://bluepyopt.readthedocs.io/en/latest/
Other
198 stars 96 forks source link

cell_model.py is not trowing error if wrong dist_type is used #479

Open robban80 opened 10 months ago

robban80 commented 10 months ago

I suppose this is not a clear error, but it makes the code sensitive to user derived errors.

If I would use the l5pc example and change some parameters so that dist_type is neither 'uniform' nor 'exp', then def create_parameters(), lines 107-111 would happily use the scaler of the previous parameter without trowing an error (unless it happens to be the first parameter, then the scaler would not be defined which would case an error).

This could easily be avoided by raising an exception if the dist_type is something not allowed. E.g:

            if param_config['dist_type'] == 'uniform':
                scaler = ephys.parameterscalers.NrnSegmentLinearScaler()
            elif param_config['dist_type'] == 'exp':
                scaler = ephys.parameterscalers.NrnSegmentSomaDistanceScaler(
                    distribution=param_config['dist'])
            else:
                raise Exception( '"dist_type" ERROR!\n dist_type can not be "{}",\n\t use: uniform or exp'.format(param_config['dist_type']))