Skip to content

global_arm_transform_params

Classes:

Name Description
GlobalARMTransformParams

Classes#

GlobalARMTransformParams #

Bases: BaseModel

Methods:

Name Description
default_pattern
select_parameters

Attributes:

Name Type Description
alignment Dict[Pattern, Dict[str, Literal['LEFT', 'RIGHT', 'CENTER']]]
dim_range Dict[Pattern, Dict[str, str]]
width Dict[Pattern, Dict[str, str]]

Attributes#

alignment instance-attribute #
alignment: Dict[
    Pattern, Dict[str, Literal["LEFT", "RIGHT", "CENTER"]]
]
dim_range class-attribute instance-attribute #
dim_range: Dict[Pattern, Dict[str, str]] = Field(
    ..., alias="range"
)
width instance-attribute #
width: Dict[Pattern, Dict[str, str]]

Functions#

default_pattern #
default_pattern(
    d: Dict[Any, Any]
) -> Dict[Pattern[str], Dict[str, str]]
Source code in tsdat/io/retrievers/global_arm_transform_params.py
@validator("alignment", "dim_range", "width", pre=True)
def default_pattern(cls, d: Dict[Any, Any]) -> Dict[Pattern[str], Dict[str, str]]:
    if not d:
        return {}
    pattern_dict: Dict[Pattern[str], Dict[str, str]] = defaultdict(dict)
    for k, v in d.items():
        if isinstance(v, dict):
            pattern_dict[re.compile(k)] = v
        else:
            pattern_dict[re.compile(r".*")][k] = v
    return pattern_dict
select_parameters #
select_parameters(
    input_key: str,
) -> Dict[str, Dict[str, Any]]
Source code in tsdat/io/retrievers/global_arm_transform_params.py
def select_parameters(self, input_key: str) -> Dict[str, Dict[str, Any]]:
    selected_params: Dict[str, Dict[str, Any]] = {
        "alignment": {},
        "range": {},
        "width": {},
    }
    for pattern, params in self.alignment.items():
        if pattern.match(input_key) is not None:
            selected_params["alignment"] = params.copy()
            break

    for pattern, params in self.dim_range.items():
        if pattern.match(input_key) is not None:
            selected_params["range"] = params.copy()
            break

    for pattern, params in self.width.items():
        if pattern.match(input_key) is not None:
            selected_params["width"] = params.copy()
            break

    return selected_params