neml2.user_tensors

Native [Tensors] block types.

Exposes PythonTensor (HIT type = Python) for inline Python expressions and the CSV<Type> family used by the verification test suite to load reference snapshots from on-disk CSV files.

class neml2.user_tensors.CSVSR2[source]

Bases: _CSVTensorBase

Load 6 columns from CSV as an SR2 with shape (N, 6).

Column-name suffix order matches the C++ VTestTimeSeries<SR2> / Mandel slot convention: var_xx, var_yy, var_zz, var_yz, var_xz, var_xy. Values are stacked verbatim – .vtest files declare Mandel convention so the on-disk columns already carry the sqrt(2) scaling on shear slots.

TYPE_NAME: ClassVar[str] = 'CSVSR2'
WRAPPER

alias of SR2

class neml2.user_tensors.CSVScalar[source]

Bases: _CSVTensorBase

Load a single column from CSV as a Scalar with shape (N,).

TYPE_NAME: ClassVar[str] = 'CSVScalar'
WRAPPER

alias of Scalar

class neml2.user_tensors.CSVVec[source]

Bases: _CSVTensorBase

Load 3 columns from CSV as a Vec with shape (N, 3).

TYPE_NAME: ClassVar[str] = 'CSVVec'
WRAPPER

alias of Vec

class neml2.user_tensors.CSVWR2[source]

Bases: _CSVTensorBase

Load 3 columns from CSV as a WR2 (skew) with shape (N, 3).

Column-name suffix order mirrors the C++ VTestTimeSeries<WR2> call: var_zy, var_xz, var_yx. WR2 has no Mandel scaling – values are stacked verbatim.

TYPE_NAME: ClassVar[str] = 'CSVWR2'
WRAPPER

alias of WR2

class neml2.user_tensors.PythonTensor[source]

Bases: object

Tensor built from an inline Python expression.

The expr option is evaluated in a namespace pre-populated with torch, every public name from neml2.types (Scalar, SR2, SSR4, free functions), math, and np (numpy, if importable). Cross-references to other [Tensors] entries resolve by bare identifier: writing base is equivalent to tensor('base'), which avoids HIT’s restriction on nested quotes.

The expression’s value (torch.Tensor or a TensorWrapper subclass) is returned verbatim; the call site (typically neml2.model.Model.declare_typed_parameter() mode 2) is responsible for wrapping a raw tensor into a typed wrapper if needed.

SECTION: ClassVar[str] = 'Tensors'
classmethod from_hit(node, factory)[source]
Parameters:
  • node (nmhit.Node)

  • factory (_NativeInputFile)

Return type:

Any

hit = <neml2.schema.HitSchema object>