Source code for icclim._core.model.logical_link

"""Contain the LogicalLink class and registry."""

from __future__ import annotations

import dataclasses
from functools import reduce
from typing import TYPE_CHECKING, Callable

import numpy as np

from icclim._core.model.registry import Registry

if TYPE_CHECKING:
    from xarray import DataArray


@dataclasses.dataclass




[docs] class LogicalLinkRegistry(Registry[LogicalLink]): """Registry for LogicalLink objects.""" _item_class = LogicalLink LOGICAL_OR = LogicalLink( name="or", standard_name="OR", long_name="OR", short_name="OR", compute=lambda data_list: reduce(np.logical_or, data_list), ) LOGICAL_AND = LogicalLink( name="and", standard_name="AND", long_name="AND", short_name="AND", compute=lambda data_list: reduce(np.logical_and, data_list), )