Factory
This module contains functions to create and manage objects.
FUNCTION | DESCRIPTION |
---|---|
create |
Create object of class with arguments and keyword arguments |
create_from_config |
Create object of class with dictionary |
dict_to_named_tuple |
Creating named tuple from dictionary |
dict_to_simple_namespace |
Convert dictionary to SimpleNamespace |
get_class |
Retrieve the relevant class from the sub-package |
get_imported_modules |
Get all imported modules |
get_method_names |
Get the names of the methods in Callable object (Class/Instance) |
get_plans |
Get available configurations |
get_setup |
Load setup from files and return as NamedTuple or Platform |
load_parts |
Load all parts of compound tools from configuration |
load_setup_from_files |
Load and initialise setup |
parse_configs |
Decode dictionary of configuration details to get tuples and numpy.ndarray |
zip_kwargs_to_dict |
Checks and zips multiple keyword arguments of lists into dictionary |
Documentation last updated: 2025-06-11
Part
create
Create object of class with arguments and keyword arguments
PARAMETER | DESCRIPTION |
---|---|
obj
|
target class
TYPE:
|
args
|
arguments for class. Defaults to tuple().
TYPE:
|
kwargs
|
keyword arguments for class. Defaults to dict().
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
object
|
object of target class
TYPE:
|
create_from_config
Create object of class with dictionary
PARAMETER | DESCRIPTION |
---|---|
config
|
dictionary of arguments
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
object
|
object of target class
TYPE:
|
dict_to_named_tuple
Creating named tuple from dictionary
PARAMETER | DESCRIPTION |
---|---|
d
|
dictionary to be transformed
TYPE:
|
tuple_name
|
name of new namedtuple type. Defaults to 'Setup'.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
tuple
|
named tuple from dictionary
TYPE:
|
dict_to_simple_namespace
Convert dictionary to SimpleNamespace
PARAMETER | DESCRIPTION |
---|---|
d
|
dictionary to be transformed
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
SimpleNamespace
|
SimpleNamespace object
TYPE:
|
get_class
Retrieve the relevant class from the sub-package
PARAMETER | DESCRIPTION |
---|---|
module_name
|
name of the module using dot notation
TYPE:
|
class_name
|
name of the class
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Type
|
target Class
TYPE:
|
get_imported_modules
Get all imported modules
PARAMETER | DESCRIPTION |
---|---|
interested_modules
|
interested module(s). Defaults to None.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
dict
|
dictionary of imported modules
TYPE:
|
get_method_names
Get the names of the methods in Callable object (Class/Instance)
PARAMETER | DESCRIPTION |
---|---|
obj
|
object of interest
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[str]
|
list[str]: list of method names |
get_plans
Get available configurations
PARAMETER | DESCRIPTION |
---|---|
configs
|
dictionary of configurations
TYPE:
|
registry
|
dictionary of addresses. Defaults to None.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
dict
|
dictionary of available configurations
TYPE:
|
get_setup
get_setup(
config_file: Path | str,
registry_file: Path | str | None = None,
platform_type: Type | None = None,
silent_fail: bool = False,
) -> tuple | Any
Load setup from files and return as NamedTuple or Platform
PARAMETER | DESCRIPTION |
---|---|
config_file
|
config filename
TYPE:
|
registry_file
|
registry filename. Defaults to None.
TYPE:
|
platform_type
|
target platform type. Defaults to None.
TYPE:
|
silent_fail
|
whether to let setup errors through without raising an exception. Defualts to False.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
tuple | Any
|
tuple|Any: named tuple or Platform object |
load_parts
Load all parts of compound tools from configuration
PARAMETER | DESCRIPTION |
---|---|
configs
|
dictionary of configuration parameters
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
dict
|
dictionary of part tools
TYPE:
|
load_setup_from_files
load_setup_from_files(
config_file: Path | str,
registry_file: Path | str | None = None,
create_tuple: bool = True,
) -> dict | tuple
Load and initialise setup
PARAMETER | DESCRIPTION |
---|---|
config_file
|
config filename
TYPE:
|
registry_file
|
registry filename. Defaults to None.
TYPE:
|
create_tuple
|
whether to return a named tuple, if not returns dictionary. Defaults to True.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
dict | tuple
|
dict|tuple: dictionary or named tuple of setup objects |
parse_configs
Decode dictionary of configuration details to get tuples and numpy.ndarray
PARAMETER | DESCRIPTION |
---|---|
configs
|
dictionary of configuration details
TYPE:
|
addresses
|
dictionary of registered addresses. Defaults to None.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
dict
|
dictionary of configuration details
TYPE:
|
zip_kwargs_to_dict
Checks and zips multiple keyword arguments of lists into dictionary
PARAMETER | DESCRIPTION |
---|---|
primary_key
|
primary keyword to be used as key
TYPE:
|
kwargs
|
{keyword, list of values} pairs
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
dict
|
dictionary of (primary keyword, kwargs)
TYPE:
|
RAISES | DESCRIPTION |
---|---|
AssertionError
|
Ensure the lengths of inputs are the same |