rail.plotting.dataset_holder module

class rail.plotting.dataset_holder.DatasetSplitMode(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Choose how to split datasets within a project

by_algo = 2
by_flavor = 1
no_split = 0
class rail.plotting.dataset_holder.RailDatasetHolder(**kwargs)[source]

Bases: Configurable, DynamicClass

Base class for extracting data from a RailProject

The resolve method will return the wrapped dataset

Sub-classes should implement

a class member: extractor_inputs: a dict [str, type]

that specifies the inputs that the sub-classes expect, this is used the check the kwargs that are passed to the _get_data() function

a class member: output_type: type[RailDataset]

that specifies the output dataset type

A function: get_extractor_inputs(self) -> dict[str, Any]

The resolves anything for the call to _get_data from the configuration parameters. For example, loading the underlying project if needed.

A function: _get_data(self,**kwargs: Any) -> dict[str, Any]:

That actually gets the data. It does not need to do the checking that the correct kwargs have been given.

A class method: generate_dataset_dict()

that will find all the datasets that the extractor can extract

Parameters:

kwargs (Any)

property data: dict[str, Any] | None

Return the RailDatasetHolder data

extractor_inputs: dict = {}
classmethod generate_dataset_dict(**kwargs)[source]

Create a dict of the datasets that this extractor can extract

Return type:

tuple[list[RailProjectHolder], list[RailDatasetHolder], list[RailDatasetListHolder]]

Returns:

  • list[RailProjectHolder] – Underlying RailProjects

  • list[RailDatasetHolder] – Extracted datasets

  • list[RailDatasetListHolder] – Extracted dataset lists

Parameters:

kwargs (dict[str, Any])

get_extractor_inputs()[source]

Resolve the inputs needed to get the data from the configuration paramters.

For example, load RailProject configurations, resolve the set of requested interpolants, etc…

Return type:

dict[str, Any]

output_type

alias of RailDataset

resolve()[source]

Extract and return the data in question

Return type:

dict[str, Any]

set_data(the_data)[source]

Set the data in this holder

Return type:

None

Parameters:

the_data (dict[str, Any] | None)

sub_classes: dict[str, type[DynamicClass]] = {'RailCatTruthAndMagntiduesDataHolder': <class 'rail.plotting.cat_data_holders.RailCatTruthAndMagntiduesDataHolder'>, 'RailDatasetHolder': <class 'rail.plotting.dataset_holder.RailDatasetHolder'>}
to_yaml_dict()[source]

Create a yaml-convertable dict for this object

Return type:

dict[str, dict[str, Any]]

yaml_tag: str = 'Dataset'
class rail.plotting.dataset_holder.RailDatasetListHolder(**kwargs)[source]

Bases: Configurable

Class to wrap a list of consistent RailDatasetHolders

i.e., all of the RailDatasetHolders should return the same type of dataets, meaning that they should all contain the same columns.

The resolve method will return the list of RailDatasetHolders

Parameters:

kwargs (Any)

config_options: dict[str, StageParameter] = {'dataset_class': Parameter(Type of data expected by plotters on this list, type: <class 'str'>, default: None [required]), 'datasets': Parameter(List of datasets to include, type: <class 'list'>, default: [] [optional]), 'name': Parameter(Dataset name, type: <class 'str'>, default: None [required])}
resolve(dataset_factory)[source]

Get all the associated RailDatasetHolder objects

Return type:

list[RailDatasetHolder]

Parameters:

dataset_factory (RailDatasetFactory)

Paramters

dataset_factory:

Factory used to make the dataset_holders.

returns:

Requested datasets

rtype:

list[RailDatasetHolder]

Notes

This will enforce that each dataset_holders expects the compatible dataset_types

yaml_tag: str = 'DatasetList'
class rail.plotting.dataset_holder.RailProjectHolder(**kwargs)[source]

Bases: Configurable

Class to wrap a RailProject

This is just the path to the yaml file that define the project

The resolve method will create a RailProject object by reading that file

Parameters:

kwargs (Any)

config_options: dict[str, StageParameter] = {'name': Parameter(Dataset name, type: <class 'str'>, default: None [required]), 'yaml_file': Parameter(path to project yaml file, type: <class 'str'>, default: None [required])}
resolve()[source]

Read the associated yaml file and create a RailProject

Return type:

RailProject

yaml_tag: str = 'Project'