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>=3.0.0

For pandas DataFrame support:

pip install vcti-fieldset[dataframe]>=3.0.0

For binding vcti-datanode DataNodes as fields:

pip install vcti-fieldset[datanode]>=3.0.0

In pyproject.toml dependencies

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

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

Download files

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

Source Distribution

vcti_fieldset-3.0.0.tar.gz (55.3 kB view details)

Uploaded Source

Built Distribution

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

vcti_fieldset-3.0.0-py3-none-any.whl (41.7 kB view details)

Uploaded Python 3

File details

Details for the file vcti_fieldset-3.0.0.tar.gz.

File metadata

  • Download URL: vcti_fieldset-3.0.0.tar.gz
  • Upload date:
  • Size: 55.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for vcti_fieldset-3.0.0.tar.gz
Algorithm Hash digest
SHA256 f028048342c561b22ba35cc152fbb4ff4355edf32763b7a55e2fb6bfee863efc
MD5 941c4a9b7eea03d1c8a3a53808f5de23
BLAKE2b-256 4e85c96ec21b71a27d3b5f6b342e43385b5acea7b085f21195ccba4d9442e33c

See more details on using hashes here.

Provenance

The following attestation bundles were made for vcti_fieldset-3.0.0.tar.gz:

Publisher: release.yml on vcollab/vcti-python-fieldset

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vcti_fieldset-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: vcti_fieldset-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 41.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for vcti_fieldset-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d4ac7ddd99e3efbb959a406e6f9721ec0b0851840268de92f0e47a37cdb7dd17
MD5 a24e72f639ea32f7e7383e733f9a98f4
BLAKE2b-256 5a493700d802ac89728f04aeeb8451e5b88c150895dee4428bbb455b67b3bf9b

See more details on using hashes here.

Provenance

The following attestation bundles were made for vcti_fieldset-3.0.0-py3-none-any.whl:

Publisher: release.yml on vcollab/vcti-python-fieldset

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

3.0.0 This release

2 files

2.0.0

2 files

1.4.0

2 files

1.3.2

2 files

1.0.0

2 files

Supported by

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