Dimensions

class deker.dimensions.Dimension(name, size, labels=None, scale=None, **kwargs)

Bases: SelfLoggerMixin, BaseDimension

Dimension of a grid axes or any other series except time (for time series use TimeDimension).

May be used for defining the majority of parameters which may be stored in an array. You can use labels or scale parameter to create a mapping of some names or values to the dimension indexes.

Parameters
  • name (str) – dimension unique name (e.g. “length”)

  • size (int) – dimension cells quantity

  • labels (Optional[Union[Tuple[Union[str, int, float], ...], List[Union[str, int, float]]]]) –

    ordered mapping of dimension values names to their indexes

    ["name1", "name2", ..., "nameN"]
    ("float1", "float2", ..., "floatN")
    

  • scale (Optional[dict]) – a description of dimension regular scale; default None

  • kwargs (Any) –

__len__()

Get Dimension size.

Return type

int

property as_dict: dict

Serialize Dimension into dict.

property labels: Optional[IndexLabels]

Get Dimension labels.

property name: str

Get Dimension name.

property scale: Optional[Scale]

Get Dimension regular scale.

property size: int

Get Dimension size.

property step: int

Get Dimension step.

class deker.dimensions.TimeDimension(name, size, start_value, step)

Bases: SelfLoggerMixin, BaseDimension

Special dimension for time series.

Parameters
  • name (str) – dimension name (e.g. “time”)

  • size (int) – dimension cells quantity

  • start_value (datetime) – time mark of the first cell (index 0) in dimension

  • step (timedelta) – a datetime.timedelta step of TimeDimension series within the grid

Note

start_value shall be:
  • either datetime.datetime object with explicit timezone

  • or datetime.isoformat() with explicit timezone

  • or a reference to an array attribute name which shall start with $ (attribute name shall be defined without prefix “$”):

    custom_attributes(
        {"my_start_value": datetime.datetime(2023, 1, 1, 0, tzinfo=timezone.utc),
        }
    
    TimeDimension(start_value: "$my_start_value", ...)
    
__len__()

Get TimeDimension size.

Return type

int

property as_dict: dict

Serialize TimeDimension into dict.

property name: str

Get TimeDimension name.

property size: int

Get TimeDimension size.

property start_value: Union[datetime, str]

Get TimeDimension start value.

property step: timedelta

Get TimeDimension step.