Skip to main content

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.0

For pandas DataFrame support:

pip install vcti-fieldset[dataframe]>=4.0.0

For binding vcti-datanode DataNodes as fields:

pip install vcti-fieldset[datanode]>=4.0.0

In pyproject.toml dependencies

dependencies = [
    "vcti-fieldset>=4.0.0",
]

# or, with DataFrame support:
dependencies = [
    "vcti-fieldset[dataframe]>=4.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 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

Optional

  • pandas (>=2.0) — required for to_dataframe(), install via vcti-fieldset[dataframe]

Metadata

Release files for vcti-fieldset 4.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vcti-fieldset 4.0.0
File Size Uploaded
vcti_fieldset-4.0.0.tar.gz 73.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for vcti-fieldset 4.0.0
File Interpreter ABI Platform
vcti_fieldset-4.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 121.4 kB

Release files / vcti_fieldset-4.0.0.tar.gz

Download URL vcti_fieldset-4.0.0.tar.gz
Size 73.0 kB
Tags Source
SHA-256 checksum
How to use checksums
67989fc2eb56eba502c2ed802bc44876bcd1e52cec58b75ad57348d2eec0d587
BLAKE2b-256 checksum
How to use checksums
ef303886183f74c3ac5866287cd0109ca7d890f6822e90fd1d719cbe150e71f6
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

Release files / vcti_fieldset-4.0.0-py3-none-any.whl

Download URL vcti_fieldset-4.0.0-py3-none-any.whl
Size 48.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
04ae962a3ee2c09cefce19c43e5a5b827b972a775358b783b06028f4da7724c5
BLAKE2b-256 checksum
How to use checksums
fbf10929e388ba3e4a8b0f87ad6ade10c172de36f6b0edd8bf15a42a3e5e0233
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

Release history Release notifications | RSS feed

4.0.1

2 release files

This release

4.0.0 This release

2 release files

3.0.0

2 release files

2.0.0

2 release files

1.4.0

2 release files

1.3.2

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page