superneuromat.util#
Utility functions for SuperNeuroMAT.
- superneuromat.util.getenvbool(key: str, default: bool | None | str | Any = None, force_bool: Literal[False] = False) Any [source]#
- superneuromat.util.getenvbool(key: str, default: bool | None | str = None, force_bool: Literal[False] = False) bool | str
- superneuromat.util.getenvbool(key: str, default: bool | None = None, force_bool: Literal[True] = True) bool
Get the value of an environment variable and attempt to cast to bool, or return a default.
- Parameters:
- Returns:
The value of the environment variable, or the default value if the environment variable is not set.
- Return type:
- Raises:
ValueError – If the environment variable is not a bool and force_bool is
True
, or if you setforce_bool=True
and a non-bool value fordefault
- superneuromat.util.is_intlike(x)[source]#
Returns
True
ifx
is equivalent to an integer.- Raises:
ValueError – If
x
cannot be coerced to an integer.
- superneuromat.util.pretty_spike_train(spike_train: list[list[bool]] | list[ndarray] | ndarray, max_steps: int | None = 11, max_neurons: int | None = 28, use_unicode: bool | Any = True)[source]#
Prints the spike train.
- Parameters:
spike_train (list[list[bool]] | list[np.ndarray] | np.ndarray) – The spike train to show.
max_steps (int | None, optional) – Limits the number of steps which will be included. If limited, only a total of
max_steps
first and last steps will be included.max_neurons (int | None, optional) – Limits the number of neurons which will be included. If limited, only a total of
max_neurons
first and last neurons will be included.use_unicode (bool, default=True) – If
True
, use unicode characters to represent spikes. Otherwise fallback to ascii characters.
- superneuromat.util.print_spike_train(spike_train, max_steps=None, max_neurons=None, use_unicode=True)[source]#
Prints the spike train.
- Parameters:
spike_train (list[list[bool]] | list[np.ndarray] | np.ndarray) – The spike train to print.
max_steps (int | None, optional) – Limits the number of steps which will be printed. If limited, only a total of
max_steps
first and last steps will be printed.max_neurons (int | None, optional) – Limits the number of neurons which will be printed. If limited, only a total of
max_neurons
first and last neurons will be printed.use_unicode (bool, default=True) – If
True
, use unicode characters to represent spikes. Otherwise fallback to ascii characters.
Functions
|
Cast float and raise a custom error |
|
Get the value of an environment variable or return a default. |
Get the value of an environment variable and attempt to cast to bool, or return a default. |
|
|
Cast int and raise a ValueError if x is not an int or int-like. |
|
Returns |
|
Returns |
|
Prints the spike train. |
|
Prints the spike train. |