Utils

Exploration Functions

Module containing factory functions for parameter exploration

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:
  • parameter_dict – Dictionary containing parameter names as keys and iterables of data to explore.
  • combined_parameters

    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

Module containing utility functions to compare 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 :-)

pypet.utils.comparisons.parameters_equal(a, b)[source]

Compares two parameter instances

Checks full name, data, and ranges. Does not consider the comment.

Returns:True or False
Raises:ValueError if both inputs are no parameter instances
pypet.utils.comparisons.results_equal(a, b)[source]

Compares two result instances

Checks full name and all data. Does not consider the comment.

Returns:True or False
Raises:ValueError if both inputs are no result instances