sierra.core.utils
Miscellaneous bits used in mutiple places but that don’t fit anywhere else.
dir_create_checked()
: Create a directory idempotently.path_exists()
: Check if a path exists, trying multiple times.get_primary_axis()
: Determine axis in a bivariate batch criteria is the primary axis.exp_range_calc()
: Get the range of experiments to run/do stuff with. SUPER USEFUL.exp_include_filter()
: Calculate which experiments to include in a calculation for something.apply_to_expdef()
: Apply a generated XML modifictions to an experiment definition.pickle_modifications()
: After applying XML modifications, pickle changes for later retrieval.exp_template_path()
: Calculate the path to the template input file in the batch experiment root.get_n_robots()
: Get the # robots used for a specific Experiment.df_fill()
: Fill missing cells in a dataframe according to the specified fill policy.
- sierra.core.utils.dir_create_checked(path: Union[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.path_exists(path: Union[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.get_primary_axis(criteria, primary_axis_bc: List, cmdopts: Dict[str, Any]) 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.exp_range_calc(cmdopts: Dict[str, Any], root_dir: Path, criteria) List[Path] [source]
Get the range of experiments to run/do stuff with. SUPER USEFUL.
- sierra.core.utils.exp_include_filter(inc_spec: Optional[str], 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.apply_to_expdef(var, exp_def: XMLExpDef) Tuple[Optional[TagRmList], Optional[TagAddList], Optional[AttrChangeSet]] [source]
Apply a generated XML modifictions to an experiment definition.
In this order:
Remove existing XML tags
Add new XML tags
Change existing XML attributes
- sierra.core.utils.pickle_modifications(adds: Optional[TagAddList], chgs: Optional[AttrChangeSet], path: Path) None [source]
After applying XML modifications, pickle changes for later retrieval.
- sierra.core.utils.exp_template_path(cmdopts: Dict[str, Any], batch_input_root: Path, dirname: str) 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_robots(main_config: Dict[str, Any], cmdopts: Dict[str, Any], exp_input_root: Path, exp_def: XMLExpDef) int [source]
Get the # robots used for a specific Experiment.
- sierra.core.utils.df_fill(df: DataFrame, policy: str) DataFrame [source]
Fill missing cells in a dataframe according to the specified fill policy.
ArenaExtent
: Representation of a 2D or 3D section/chunk/volume of the arena.Sigmoid
: Sigmoid activation function.ReLu
: Rectified Linear Unit (ReLU) activation function.
- class sierra.core.utils.ArenaExtent(dims: Vector3D, origin: Vector3D = (0, 0, 0))[source]
Representation of a 2D or 3D section/chunk/volume of the arena.
Inheritance
- __dict__ = mappingproxy({'__module__': 'sierra.core.utils', '__doc__': 'Representation of a 2D or 3D section/chunk/volume of the arena.', 'from_corners': <staticmethod object>, '__init__': <function ArenaExtent.__init__>, 'contains': <function ArenaExtent.contains>, 'area': <function ArenaExtent.area>, 'xsize': <function ArenaExtent.xsize>, 'ysize': <function ArenaExtent.ysize>, 'zsize': <function ArenaExtent.zsize>, 'origin': <function ArenaExtent.origin>, '__str__': <function ArenaExtent.__str__>, '__dict__': <attribute '__dict__' of 'ArenaExtent' objects>, '__weakref__': <attribute '__weakref__' of 'ArenaExtent' objects>, '__annotations__': {}})
- __doc__ = 'Representation of a 2D or 3D section/chunk/volume of the arena.'
- __module__ = 'sierra.core.utils'
- __weakref__
list of weak references to the object (if defined)
- static from_corners(ll: Vector3D, ur: 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.Sigmoid(x: float)[source]
Sigmoid activation function.
(1)\[f(x) =\]rac{1}{1+e^{-x}}
Inheritance
- __dict__ = mappingproxy({'__module__': 'sierra.core.utils', '__doc__': '\n Sigmoid activation function.\n\n .. math::\n f(x) = \x0crac{1}{1+e^{-x}}\n\n ', '__init__': <function Sigmoid.__init__>, '__call__': <function Sigmoid.__call__>, '__dict__': <attribute '__dict__' of 'Sigmoid' objects>, '__weakref__': <attribute '__weakref__' of 'Sigmoid' objects>, '__annotations__': {}})
- __doc__ = '\n Sigmoid activation function.\n\n .. math::\n f(x) = \x0crac{1}{1+e^{-x}}\n\n '
- __module__ = 'sierra.core.utils'
- __weakref__
list of weak references to the object (if defined)
- class sierra.core.utils.ReLu(x: float)[source]
Rectified Linear Unit (ReLU) activation function.
(2)\[\begin{aligned} f(x) = max(0,x) &= x \textit{if} x > 0 &= 0 \textit{else} \end{aligned}\]Inheritance
- __dict__ = mappingproxy({'__module__': 'sierra.core.utils', '__doc__': '\n Rectified Linear Unit (ReLU) activation function.\n\n .. math::\n\n \\begin{aligned}\n f(x) = max(0,x) &= x \\textit{if} x > 0\n &= 0 \\textit{else}\n \\end{aligned}\n ', '__init__': <function ReLu.__init__>, '__call__': <function ReLu.__call__>, '__dict__': <attribute '__dict__' of 'ReLu' objects>, '__weakref__': <attribute '__weakref__' of 'ReLu' objects>, '__annotations__': {}})
- __doc__ = '\n Rectified Linear Unit (ReLU) activation function.\n\n .. math::\n\n \\begin{aligned}\n f(x) = max(0,x) &= x \\textit{if} x > 0\n &= 0 \\textit{else}\n \\end{aligned}\n '
- __module__ = 'sierra.core.utils'
- __weakref__
list of weak references to the object (if defined)
- 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.
functools.partial(<built-in function open>, encoding='UTF-8')