Skip to main content

This package provides a pure-Python way to create, inspect, and validate .ndtbl files without depending on the C++ binaries.

Project description

ndtbl

License: MIT codecov PyPI Python

Pure-Python tools for reading, writing, inspecting, and generating .ndtbl files without depending on the C++ binaries.

The package is useful when you want to:

  • inspect an existing table on a machine without the C++ toolchain
  • generate small synthetic tables for tests, examples, and development
  • query one concrete grid point from the command line
  • read or write .ndtbl files directly from Python or NumPy workflows

🔧 Features

  • Read .ndtbl metadata or full payloads
  • Write .ndtbl files compatible with the current C++ implementation
  • Inspect files from the command line with metadata and sample values
  • Query one point in a table by zero-based grid indices
  • Generate small predefined linear tables for development workflows

⚙️ Installation

Install from the package directory:

python -m pip install .

Or install from PyPI:

python -m pip install ndtbl

For development:

python -m pip install -v -e .[lint,tests]

🐍 Python API

The core API revolves around FieldGroup, UniformAxis, read_group, and write_group.

import numpy as np

from ndtbl import FieldGroup, UniformAxis, read_group, write_group

group = FieldGroup(
    axes=(UniformAxis(0.0, 1.0, 3), UniformAxis(10.0, 20.0, 2)),
    field_names=("A", "B"),
    values=np.array(
        [
            [[1.0, 10.0], [2.0, 20.0]],
            [[3.0, 30.0], [4.0, 40.0]],
            [[5.0, 50.0], [6.0, 60.0]],
        ],
        dtype=np.float64,
    ),
)

write_group("example.ndtbl", group)

loaded = read_group("example.ndtbl")
print(loaded.field_names)
print(loaded.values[1, 0, :])

The values array shape is axis_0 x axis_1 x ... x field.

💻 CLI

The package installs one executable, ndtbl, with three subcommands:

  • inspect prints metadata and a configurable number of sample values
  • query prints the field values at one point addressed by zero-based indices
  • generate creates a simple synthetic table with linear fields

Show the top-level help:

ndtbl --help

inspect

Inspect an existing file:

ndtbl inspect example.ndtbl

inspect prints an ASCII-art header by default after the file is read successfully. Suppress it when needed:

ndtbl inspect example.ndtbl --no-banner

Limit the number of printed sample points:

ndtbl inspect example.ndtbl --samples 3

query

Query one point in the table using zero-based indices in axis order:

ndtbl query example.ndtbl 1 0

Print metadata before the queried values:

ndtbl query --metadata example.ndtbl 1 0

For a 3D table, provide three indices:

ndtbl query example-3d.ndtbl 1 2 0

generate

Generate a small linear table:

ndtbl generate output.ndtbl \
  --axis 0 1 3 \
  --axis 10 20 2 \
  --field-linear A 1.0 2.0 0.0 \
  --field-linear B 5.0 0.0 -1.0

Use float32 output instead of the default float64:

ndtbl generate output.ndtbl \
  --axis 0 1 3 \
  --field-linear A 1.0 2.0 \
  --dtype float32

Raise or lower the generation safety limit:

ndtbl generate output.ndtbl \
  --axis 0 1 100 \
  --axis 0 1 100 \
  --field-linear A 0.0 1.0 1.0 \
  --max-size-mib 32

--field-linear expects NAME OFFSET C0 [C1 ...], with one coefficient per axis in storage order.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ndtbl-0.1.0.tar.gz (17.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ndtbl-0.1.0-py3-none-any.whl (14.7 kB view details)

Uploaded Python 3

File details

Details for the file ndtbl-0.1.0.tar.gz.

File metadata

  • Download URL: ndtbl-0.1.0.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.4 {"installer":{"name":"uv","version":"0.11.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for ndtbl-0.1.0.tar.gz
Algorithm Hash digest
SHA256 42a9e425d59b6ad3c57ce3e1be46699ef71dc44bb1dd02022e231645de8d18db
MD5 d2bb45a04314815f114aac7760301708
BLAKE2b-256 97b99b74906adb26f9a2944685a558f63eb814140e9dee418aab493a41805a20

See more details on using hashes here.

File details

Details for the file ndtbl-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ndtbl-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.4 {"installer":{"name":"uv","version":"0.11.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for ndtbl-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d706cab2ca131a311e30e159a515ff6adf0428b15b9d3ff20cb77bfe31458b65
MD5 0d0298cd4d96ccedebca881d8ec10459
BLAKE2b-256 409855fdd7624732d37ef68f66bdaec7bd8c6b437880bbc14436388092e21907

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page