Design#

The repository follows the same organisation as onnx-light.

data_cube/
    cube_core/      C++ library lib_data_cube (no Python dependency)
        value.h     scalars (Value), column types, timestamps
        column.h    typed columns with missing values
        table.h     named columns, CSV reader, group by
        frame.h     result of a view, multi-level indices on both axes
        data_cube.h DataCube, ViewDef
        stats.h     breaking_last_point, mann_kendall
    cube_py/        nanobind extension _cubepy
    data_cube.py    Python API (pandas in, pandas out)
    cube_plot.py    plots added to the Excel export
unittests/
    cc/             C++ unit tests (googletest)
    python/         Python unit tests
examples/           standalone C++ examples
fuzz/               libFuzzer harnesses

Data model#

A data_cube::Column stores one type among int64, float64, string and datetime (nanoseconds since the epoch). Floats use NaN as missing values, the other types keep a validity mask. Appending a value which does not fit promotes the column (int64 + float64 gives float64, anything with a string gives a string). A data_cube::Table is a list of named columns. A data_cube::Frame is the equivalent of a pandas.DataFrame with a pandas.MultiIndex on both axes, every level is stored as a column.

Loading#

data_cube::DataCube::load():

  1. adds the missing columns defined by fill_missing to every piece and concatenates them,

  2. selects time, keys, values, ignored columns with the filters (a filter is a regular expression if it contains one of "^.*+{}),

  3. converts the time column into timestamps,

  4. removes duplicated rows (recent=true) or raises an exception,

  5. applies the formulas,

  6. counts the distinct values of every key (used to remove keys with a unique value from a view),

  7. replaces all dates by the last one if keep_last_date is true.

Views#

data_cube::DataCube::view() follows these steps: optional fix of keys changing over time, optional aggregation over key_agg, removal of keys with a unique value, ordering of column levels, removal of rows with only missing values, pivot (key_index gives the rows, the other keys give the columns, the first column level is METRICS), and finally the sort of both axes.

Quality checks#

Besides the unit tests (ci_core.yml), the following workflows run daily when a commit landed on main during the last 24 hours, or on demand:

  • cq_fuzz.yml: builds the libFuzzer harnesses of folder fuzz with Clang, AddressSanitizer and UndefinedBehaviorSanitizer, and runs every one of them (also on every pull request modifying the C++ library),

  • cq_asan_ubsan.yml: C++ and Python unit tests on a build instrumented with AddressSanitizer and UndefinedBehaviorSanitizer,

  • cq_hardening.yml: unit tests with the OpenSSF compiler hardening flags (-DDATA_CUBE_HARDENING=ON) on Linux (gcc, clang), macOS and Windows,

  • cq_pixi.yml: builds and tests in the pixi environment defined by pixi.toml,

  • cq_sbom.yml: validates the CycloneDX software bill of materials sbom.cdx.json,

  • cq_scorecard.yml: OpenSSF Scorecard analysis (weekly).

Dependabot updates the GitHub actions and the Python dependencies every month.