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
(self, data_params: set)[source]¶ This method clears ‘updated params’ whose data have been updated
-
-
allensdk.brain_observatory.session_api_utils.
compare_session_fields
(x1: Any, x2: Any, err_msg='')[source]¶ Helper function to compare if two fields (attributes) from a Session object are equal to one another.
Parameters: - x1 : Any
The field from the first session to compare
- x2 : Any
The corresponding field from the second session to compare
- err_msg : str, optional
The error message to display if two compared fields do not equal one another, by default “” (an empty string)
-
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) → bool[source]¶ Check if two Session objects are equal (have same methods and attributes).
Parameters: - A : Session A
The first session to compare
- B : Session B
The second session to compare
- reraise : bool, optional
Whether to reraise when encountering an Assertion or AttributeError, by default False
Returns: - bool
Whether the two sessions are equal to one another.