sierra.core.utils#
Miscellaneous bits used in mutiple places but that don't fit anywhere else.
Attributes#
Explictly specify that the type of file being opened is UTF-8, which is should |
Classes#
Representation of a 2D or 3D section/chunk/volume of the arena. |
|
Rectified Linear Unit (ReLU) activation function. |
|
Sigmoid activation function. |
Functions#
|
Apply a generated expdef modifictions to an experiment definition. |
|
Fill missing cells in a dataframe according to the specified fill policy. |
|
Create a directory idempotently. |
|
Calculate which experiments to include in a calculation for something. |
|
Get the range of experiments to run/do stuff with. SUPER USEFUL. |
|
Calculate the path to the template input file in the batch experiment root. |
|
Get the # agents used for a specific Experiment. |
|
Determine axis in a bivariate batch criteria is the primary axis. |
|
Check if a path exists, trying multiple times. |
|
After applying expdef modifications, pickle changes for later retrieval. |
Module Contents#
- class sierra.core.utils.ArenaExtent(dims: sierra.core.vector.Vector3D, origin: sierra.core.vector.Vector3D = Vector3D.ZERO)[source]#
Representation of a 2D or 3D section/chunk/volume of the arena.
- static from_corners(ll: sierra.core.vector.Vector3D, ur: sierra.core.vector.Vector3D) ArenaExtent[source]#
Initialize an extent via LL and UR corners.
As opposed to an origin and a set of dimensions.
- class sierra.core.utils.ReLu(x: float)[source]#
Rectified Linear Unit (ReLU) activation function.
(1)#\[\begin{aligned} f(x) = max(0,x) &= x \textit{if} x > 0 &= 0 \textit{else} \end{aligned}\]
- class sierra.core.utils.Sigmoid(x: float)[source]#
Sigmoid activation function.
(2)#\[f(x) = \frac{1}{1+e^{-x}}\]
- sierra.core.utils.apply_to_expdef(var, exp_def: sierra.core.experiment.definition.BaseExpDef) tuple[sierra.core.experiment.definition.ElementRmList | None, sierra.core.experiment.definition.ElementAddList | None, sierra.core.experiment.definition.AttrChangeSet | None][source]#
Apply a generated expdef modifictions to an experiment definition.
In this order:
Remove existing expdef elements
Add new expdef elements
Change existing expdef element attributes
- sierra.core.utils.df_fill(df: polars.DataFrame, policy: str) polars.DataFrame[source]#
Fill missing cells in a dataframe according to the specified fill policy.
- sierra.core.utils.dir_create_checked(path: pathlib.Path | str, exist_ok: bool) None[source]#
Create a directory idempotently.
If the directory exists and it shouldn't, raise an error.
- sierra.core.utils.exp_include_filter(inc_spec: str | None, target: list, n_exps: int)[source]#
Calculate which experiments to include in a calculation for something.
Take a input list of experiment numbers to include, and returns the sublist specified by the inc_spec (of the form [x:y]). inc_spec is an absolute specification; if a given performance measure excludes exp0 then that case is handled internally so that array/list shapes work out when generating graphs if this function is used consistently everywhere.
- sierra.core.utils.exp_range_calc(exp_range: str, root_dir: pathlib.Path, dirnames: list[str]) sierra.core.types.PathList[source]#
Get the range of experiments to run/do stuff with. SUPER USEFUL.
- sierra.core.utils.exp_template_path(cmdopts: sierra.core.types.Cmdopts, batch_input_root: pathlib.Path, dirname: str) pathlib.Path[source]#
Calculate the path to the template input file in the batch experiment root.
The file at this path will be Used as the de-facto template for generating per-run input files.
- sierra.core.utils.get_n_agents(main_config: sierra.core.types.YAMLDict, cmdopts: sierra.core.types.Cmdopts, exp_input_root: pathlib.Path, exp_def: sierra.core.experiment.definition.BaseExpDef) int | None[source]#
Get the # agents used for a specific Experiment.
- sierra.core.utils.get_primary_axis(criteria, primary_axis_bc: list, cmdopts: sierra.core.types.Cmdopts) int[source]#
Determine axis in a bivariate batch criteria is the primary axis.
This is obtained on a per-query basis depending on the query context, or can be overriden on the cmdline.
- sierra.core.utils.path_exists(path: pathlib.Path | str) bool[source]#
Check if a path exists, trying multiple times.
This is necessary for working on HPC systems where if a given directory/filesystem is under heavy pressure the first check or two might time out as the FS goes and executes the query over the network.
- sierra.core.utils.pickle_modifications(adds: sierra.core.experiment.definition.ElementAddList | None, chgs: sierra.core.experiment.definition.AttrChangeSet | None, path: pathlib.Path) None[source]#
After applying expdef modifications, pickle changes for later retrieval.
- sierra.core.utils.utf8open#
Explictly specify that the type of file being opened is UTF-8, which is should be for almost everything in SIERRA.