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>=2.0.0
For pandas DataFrame support:
pip install vcti-fieldset[dataframe]>=2.0.0
For binding vcti-datanode DataNodes as fields:
pip install vcti-fieldset[datanode]>=2.0.0
In pyproject.toml dependencies
dependencies = [
"vcti-fieldset>=2.0.0",
]
# or, with DataFrame support:
dependencies = [
"vcti-fieldset[dataframe]>=2.0.0",
]
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 an array |
names |
All field and expression names |
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 (>=1.0.0) — ObjectCache for expression results
- vcti-properties (>=1.0.0) — scoped metadata store
Optional
- pandas (>=2.0) — required for
to_dataframe(), install viavcti-fieldset[dataframe]
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vcti_fieldset-2.0.0.tar.gz.
File metadata
- Download URL: vcti_fieldset-2.0.0.tar.gz
- Upload date:
- Size: 46.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82dc72be92e7d4087288906e57bc28f0bfc6d29072a65d43565b6a6728fdc1a7
|
|
| MD5 |
48a4c16b4342aa7746e039ba315b7d12
|
|
| BLAKE2b-256 |
a8fbbed7e2a1103ee33875791f443c2148e4779ea79a825cc4e77f6d56c59943
|
Provenance
The following attestation bundles were made for vcti_fieldset-2.0.0.tar.gz:
Publisher:
publish.yml on vcollab/vcti-python-fieldset
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vcti_fieldset-2.0.0.tar.gz -
Subject digest:
82dc72be92e7d4087288906e57bc28f0bfc6d29072a65d43565b6a6728fdc1a7 - Sigstore transparency entry: 2071661000
- Sigstore integration time:
-
Permalink:
vcollab/vcti-python-fieldset@685a86b2073cff9eaf2c519436819bd471a7952a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/vcollab
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@685a86b2073cff9eaf2c519436819bd471a7952a -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file vcti_fieldset-2.0.0-py3-none-any.whl.
File metadata
- Download URL: vcti_fieldset-2.0.0-py3-none-any.whl
- Upload date:
- Size: 37.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee1e584a724152332fab28b4b4d5385394f4de4da7177b51a0d20121399a5d14
|
|
| MD5 |
1374d9d4ac22e451443f6dba97db292c
|
|
| BLAKE2b-256 |
dc4b8cd7fdb867d89f04df1dde6740ef0094fcbfb4cf89a144a06db356b5b8ce
|
Provenance
The following attestation bundles were made for vcti_fieldset-2.0.0-py3-none-any.whl:
Publisher:
publish.yml on vcollab/vcti-python-fieldset
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vcti_fieldset-2.0.0-py3-none-any.whl -
Subject digest:
ee1e584a724152332fab28b4b4d5385394f4de4da7177b51a0d20121399a5d14 - Sigstore transparency entry: 2071661021
- Sigstore integration time:
-
Permalink:
vcollab/vcti-python-fieldset@685a86b2073cff9eaf2c519436819bd471a7952a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/vcollab
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@685a86b2073cff9eaf2c519436819bd471a7952a -
Trigger Event:
workflow_dispatch
-
Statement type: