Utils¶
Exploration Functions¶
Created on 24.05.2013
- pypet.utils.explore.cartesian_product(parameter_dict, combined_parameters=())[source]¶
Generates a Cartesian product of the input parameter dictionary.
For example:
>>> print cartesian_product({'param1':[1,2,3], 'param2':[42.0, 52.5]}) {'param1':[1,1,2,2,3,3],'param2': [42.0,52.5,42.0,52.5,42.0,52.5]}
Parameters: - param_dict – Dictionary containing parameter names as keys and iterables of data to explore.
- combined_parameter_list –
Tuple of tuples. Defines the order of the parameters and parameters that are linked together. If an inner tuple contains only a single item, you can spare the inner tuple brackets.
For example:
>>> print cartesian_product( {'param1': [42.0, 52.5], 'param2':['a', 'b'], 'param3' : [1,2,3]}, ('param3',('param1', 'param2'))) {param3':[1,1,2,2,3,3],'param1' : [42.0,52.5,42.0,52.5,42.0,52.5], 'param2':['a','b','a','b','a','b']}
Returns: Dictionary with cartesian product lists.
General Equality Function and Comparisons of Parameters and Results¶
- pypet.utils.comparisons.nested_equal(a, b)[source]¶
Compares two objects recursively by their elements, also handling numpy objects.
Assumes hashable items are not mutable in a way that affects equality. Based on the suggestion from HERE, thanks again Lauritz V. Thaulow :-)