allensdk.brain_observatory.session_api_utils module¶
- class allensdk.brain_observatory.session_api_utils.ParamsMixin(ignore: set = {'api'})[source]¶
Bases:
object
This mixin adds parameter management functionality to the class it is mixed into.
This mixin expects that the class it is mixed into will have an __init__ with type annotated parameters. It also expects for the class to have semi-private attributes of the __init__ type annotated parameters.
Example:
SomeClassWhereParamManagementIsDesired(ParamsMixin):
# Managed params should be typed (with simple types if possible)! def __init__(self, param_to_ignore, a_param_1: int, a_param_2: float,
b_param_1: list):
# Parameters can be ignored by the mixin super().__init__(ignore={‘param_to_ignore’})
# Pay attention to the naming scheme! self._a_param_1 = a_param_1 self._a_param_2 = a_param_2 self._b_param_1 = b_param_1
…
After being mixed in, methods like ‘get_params’, ‘set_params’, ‘needs_data_refresh’, and ‘clear_updated_params’ will be available.
- clear_updated_params(data_params: set)[source]¶
This method clears ‘updated params’ whose data have been updated
- allensdk.brain_observatory.session_api_utils.is_equal(a: Any, b: Any) bool [source]¶
Function to deal with checking if two variables of possibly mixed types have the same value.
- allensdk.brain_observatory.session_api_utils.sessions_are_equal(A, B, reraise=False, ignore_keys: Dict[str, Set[str]] | None = None, skip_fields: Iterable | None = None, test_methods=False) bool [source]¶
Check if two Session objects are equal (have same property and get method values).
- Parameters:
- ASession A
The first session to compare
- BSession B
The second session to compare
- reraisebool, optional
Whether to reraise when encountering an Assertion or AttributeError, by default False
- ignore_keys
Set of keys to ignore for property/method. Should be given as {property/method name: {field_to_ignore, …}, …}
- test_methods
Whether to test get methods
- skip_fields
Do not compare these fields
- Returns:
- bool
Whether the two sessions are equal to one another.