Cells

class tinyolap.cell.Cell

A Cell is an immutable pointer to a data cell in a cube. Cell objects can be used to navigate through data space. In addition, they can be directly used in mathematical calculations, as they (almost) behave like a ‘float’ value.

Note

Cell objects are also used for the internal rules engine of TinyOlap. They are perfect for being handed in to function and methods, as shown in the code fragment below.

from tinyolap.database import Database
from tinyolap.cell import Cell

# setup a new database
cell = cube.create_cell()
value = cell.value
idx_address = cell.idx_address  # returns a list e.g. ["member of dim1", "member of dim2" ...]
cell.move("dim1", move.NEXT)  # move.NEXT
BYPASS_RULES = <object object>

Indicates that the rules functions wants to bypass all rules and get the underlying base_level or aggregated value from the cube.

CONTINUE = <object object>

Indicates that either subsequent rules should continue and do the calculation work or that the cell value, either from a base-level or an aggregated cell, form the underlying cube should be used.

ERROR = <object object>

Indicates that the rules functions run into an error. Such errors will be pushed up to initially calling cell request.

NONE = <object object>

Indicates that rules function was not able return a proper result (why ever).

alter(*args) tinyolap.cell.Cell

Creates a modified deep copy of a Cell object.

Parameters

args

One or more modifiers (member names) for at least one dimension of the cube. Member names can be in one of the ƒfollowing formats:

{member} e.g.: clone = c.alter(“Mar”, …) {cube_name:member} e.g.: clone = c.alter(“months:Mar”, …) {dimension_index:member} e.g.: clone = c.alter(“1:Mar”, …)

If multiple modifiers for a single dimension are defined, then the last of those will be used.

Returns

A new Cell object.

member(dimension_and_or_member_name: str) tinyolap.member.Member

Create a new Member object from the Cell’s current context. This can be either the current member of a specific dimension, if called with a dimension name, e.g., c.member("months") . Or it can be already a modified member of a dimension, if called with a member name, e.g., c.member("months:Jul") .

Parameters

dimension_and_or_member_name – Name of the dimension and or member to be returned.

cell = cube.cell("2022", "Jan", "North", "Sales")
jan = c.member("months")
jul = c.member("months:Jul")
jul = c.member("1:Aug")  # 'months' is the second dimension of the cube, so zero-based index is 1.
Returns

A new Member object.

property numeric_value: float

Reads the numeric value of the current cell idx_address from the underlying cube.

property value

Reads the value of the current cell idx_address from the underlying cube.