Field Set
A lightweight container for named columnar fields with lazy NumExpr expressions, scoped metadata, and pluggable field sources.
Overview
FieldSet holds named, row-aligned columnar fields and computed expressions over
them. Each field is obtained through a field source — an eager in-memory numpy
array by default, or a lazy provider such as a computed array, a memory-mapped
file, or a vcti-datanode DataNode —
so large or deferred data is loaded only when it is actually read. Expressions
like "strain = stress / youngs_modulus" are parsed and evaluated lazily via
NumExpr and cached, avoiding intermediate arrays. Row operations —
fs.rows().where(...).sort_by(...).head(...).select() — filter, sort, slice, and
group rows lazily into a new FieldSet, folding the chain into one index instead
of copying a table per step. Scoped metadata keeps system settings (components)
and user attributes (units, labels) in separate namespaces,
and an optional [dataframe] extra exports to pandas with MultiIndex columns.
The required core stays small (numpy, numexpr, vcti-cache); heavier integrations
are optional extras.
Installation
pip install vcti-fieldset>=4.0.1
For pandas DataFrame support:
pip install vcti-fieldset[dataframe]>=4.0.1
For binding vcti-datanode DataNodes as fields:
pip install vcti-fieldset[datanode]>=4.0.1
In pyproject.toml dependencies
dependencies = [
"vcti-fieldset>=4.0.1",
]
# or, with DataFrame support:
dependencies = [
"vcti-fieldset[dataframe]>=4.0.1",
]
Quick Start
A FieldSet coordinates three subsystems, each reached as a named part —
fs.fields, fs.expressions, fs.properties:
import numpy as np
from vcti.fieldset import FieldSet
# Create from named arrays
fs = FieldSet(
stress=np.array([100.0, 200.0, 150.0]),
displacement=np.array([0.1, 0.2, 0.15]),
)
# fs.expressions — lazy computed columns (NumExpr)
fs.expressions.add("strain = stress / 200000")
fs.get_values("strain") # array([0.0005, 0.001, 0.00075]) (fs[name] resolves field OR expression)
# fs.properties — scoped metadata (user attributes + system settings)
fs.properties.set("units", "MPa", field="stress")
fs.properties.set("units", "mm", field="displacement")
# fs.fields — the stored fields
fs.fields.add_data(temperature=np.array([300.0, 350.0, 325.0]))
fs.fields.names # ['stress', 'displacement', 'temperature']
# Row operations — filter/sort/slice rows into a new FieldSet
high = fs.rows().where("stress > 120").sort_by("stress", descending=True).select()
high["stress"] # array([200., 150.])
# Projection — select/rename/cast columns (and freeze expressions) into a new FieldSet
out = fs.project().select("stress", "strain").rename({"stress": "sxx"}).build()
out.names # ['sxx', 'strain']
Serialization and DataFrame export are free functions (they emit a foreign artifact — a file, a DataFrame — so they live in their modules, not on the class):
from vcti.fieldset import to_npz, from_npz
from vcti.fieldset.dataframe import to_dataframe # requires the [dataframe] extra
to_npz(fs, "results.npz")
fs = from_npz("results.npz") # a factory — returns a new FieldSet
df = to_dataframe(fs) # pandas DataFrame with (field, component) columns
Core API
A FieldSet is a coordinator over three subsystems plus unified access and the two FieldSet→FieldSet builders.
On the FieldSet itself
| Member | Description |
|---|---|
fields |
The stored fields — see below |
expressions |
The expression engine — see below |
properties |
Scoped metadata — see below |
get_values(name) / fs[name] |
Resolve a field or expression to a read-only array |
names |
All field and expression names |
field_meta(name) |
A field's shape/dtype without materialising it (None for an expression) |
rows() |
Deferred row-op builder: .where().sort_by().head().slice().select() / .group_by() |
project() |
Deferred column-op builder: .select().drop().rename().cast().freeze().filter().build() |
shape |
(rows, fields + expressions) |
name in fs / for name in fs |
Membership / iteration over all names |
copy.copy(fs) / copy.deepcopy(fs) |
Shallow / deep copy |
fs.fields
| Method | Description |
|---|---|
add_data(*args, **kwargs) |
Add structured or named arrays (atomic) |
add(name, source) |
Add a field from a FieldSource (e.g. a lazy provider) |
remove(name) |
Remove a stored field |
names |
Stored field names |
memory_usage |
Total bytes of stored field arrays |
fs.expressions
| Method | Description |
|---|---|
add(expr) |
Register a lazy expression (e.g., "c = a + b") |
remove(name) / evaluate(name) |
Remove / evaluate an expression |
pin(name) / unpin(name) |
Pin an expression result in cache (or release it) |
metrics |
Cache hit/miss and evaluation-time metrics |
fs.properties
Scoped metadata via get / set (and the get_components / set_components
shortcuts). System settings use the SystemProperty vocabulary; user attributes
are free-form strings; either can be per-field or dataset-wide:
fs.properties.set("units", "MPa", field="stress") # user attribute, per field
fs.properties.set("units", "MPa") # dataset-wide (field=None)
Free functions (import from their module)
| Function | Description |
|---|---|
to_npz(fs, path) |
Save fields, metadata, expressions to .npz + JSON sidecar |
from_npz(path) |
Load a .npz (+ sidecar) into a new FieldSet |
dataframe.to_dataframe(fs, fields=None) |
pandas DataFrame (requires [dataframe]) |
datanode.from_datanodes(...) / to_datanodes(fs) |
DataNode binding (requires [datanode]) |
Storage is backed by vcti-properties
(a scoped PropertyStore); FieldSet does not re-export its key-mapper classes —
import them from vcti.properties if you need them directly.
Dependencies
- numpy (>=1.24)
- numexpr (>=2.8)
- vcti-cache (>=2.0.0,<3.0.0) — ObjectCache for expression results
- vcti-properties (>=1.0.0,<2.0.0) — scoped metadata store
The vcti-* dependencies carry upper bounds: they are versioned together and a
major release changes contracts this package implements against. numpy and
numexpr are intentionally left unbounded — see
Dependencies and extensibility.
Optional
- pandas (>=2.0) — required for
to_dataframe(), install viavcti-fieldset[dataframe]
Documentation
| If you want to… | Read |
|---|---|
| Get started using the package | Quick Start above |
| See practical, real-world usage | docs/patterns.md |
| Understand the architecture and design decisions | docs/design.md |
| Navigate and understand the source | docs/source-guide.md |
| Extend the library — custom sources, validators, cache policies | docs/extending.md |
Metadata
Release files for vcti-fieldset 4.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| vcti_fieldset-4.0.1.tar.gz | 73.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| vcti_fieldset-4.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 122.4 kB
Release files / vcti_fieldset-4.0.1.tar.gz
| Download URL | vcti_fieldset-4.0.1.tar.gz |
|---|---|
| Size | 73.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
246eb92a31ac2c349206468c824aaa98eb392bf90f8efb4912c40e889c901c49
|
|
BLAKE2b-256 checksum How to use checksums |
79fe1cbd78f99bafe1e2af7dd6d229e1e00b6a2878185a4a2589e7b7b434f216
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 6, 2026.
Transparency logRelease files / vcti_fieldset-4.0.1-py3-none-any.whl
| Download URL | vcti_fieldset-4.0.1-py3-none-any.whl |
|---|---|
| Size | 48.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0cdd09487f92685d438511b7ebaa8e7a3b8214cfb6f0c90633f02dab09802e67
|
|
BLAKE2b-256 checksum How to use checksums |
9c5cf034323524e1db660d092cc997b3793e6e0d54c7291a1670366ca3b93ae0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 6, 2026.
Transparency log