Special tuples

class deker.types.public.classes.IndexLabels(labels)

Bases: tuple, SelfLoggerMixin

IndexLabels is an overloaded tuple providing a mapping of label-values to their Dimension indexes.

It provides direct and reversed ordered mappings of dimension’s values names (labels) to their position in the axis flat array (indexes).

Labels shall be a sequence of unique values within the full scope of the passed Dimension. Valid Labels are list or tuple of unique strings or floats:

["name1", "name2", ..., "nameN"] | (0.2, 0.1, 0.4, 0.3, ..., -256.78963)
Parameters

labels (Optional[Labels]) – list or tuple of unique strings or floats

Return type

IndexLabels

index_to_name(idx)

Get label name by its index.

Parameters

idx (int) – label index

Return type

Optional[Union[str, int, float]]

name_to_index(name)

Get label index by its name.

Parameters

name (Union[str, int, float]) – label name

Return type

Optional[int]

property first: Union[str, int, float]

Get first label.

property last: Union[str, int, float]

Get last label.

class deker.types.public.classes.Scale(start_value, step, name=None)

Bases: NamedTuple

NamedTuple with a description of a dimension regular scale.

For example we describe dimensions for the Earth’s latitude and longitude grades:

dims = [
        DimensionSchema(name="y", size=721),
        DimensionSchema(name="x", size=1440),
    ]

Such description may exist, but it’s not quite sufficient. We can provide more information for the grid:

dims = [
            DimensionSchema(
                name="y",
                size=721,
                scale=Scale(start_value=90, step=-0.25, name="lat")
            ),
            DimensionSchema(
                name="x",
                size=1440,
                scale=Scale(start_value=-180, step=0.25, name="lon")
            ),
        ]

This extra information permits us provide fancy indexing by lat/lon coordinates in degrees:

EarthGridArray[1, 1] == EarthGridArray[89.75, -179.75]
Parameters
  • start_value (float) – scale real start point

  • step (float) – scale values step (may be positive or negative)

  • name (Optional[str]) – optional scale name (latitude, longitude or whatever)

name: Optional[str]

Alias for field number 2

start_value: float

Alias for field number 0

step: float

Alias for field number 1

class deker.types.public.classes.StorageSize(bytes, human)

Bases: NamedTuple

Namedtuple for storage size with bytes and human representation.

Parameters
  • bytes (int) –

  • human (str) –

bytes: int

Alias for field number 0

human: str

Alias for field number 1