chacana¶
The top-level chacana module exposes the public API.
chacana
¶
Chacana -- a tensor calculus DSL with static type checking.
GlobalContext(manifolds: dict[str, ManifoldDecl] = dict(), tensors: dict[str, TensorDecl] = dict(), active_metric: str | None = None, strategy: dict[str, object] = dict(), sparsity: dict[str, SparsityDecl] = dict(), perturbations: dict[str, PerturbationDecl] = dict())
dataclass
¶
ChacanaParseError
¶
Bases: ChacanaError
Raised when the input expression cannot be parsed.
ChacanaTypeError
¶
Bases: ChacanaError
Raised when type checking fails (index mismatch, rank error, etc.).
parse(expr: str, *, context: GlobalContext | None = None) -> dict[str, Any]
¶
Parse a tensor expression and optionally type-check it.
Applies Unicode NFC normalization and rejects out-of-scope characters before parsing. Also rejects nested symmetrization after parsing.
Returns a MathJSON-style dict (ValidationToken.to_dict()).
Source code in src/chacana/__init__.py
check(token: ValidationToken, ctx: GlobalContext | None = None) -> ValidationToken
¶
Run all type checks on a ValidationToken. Returns the token if valid.
Source code in src/chacana/checker.py
load_context(source: str | Path) -> GlobalContext
¶
Load a GlobalContext from a TOML file path or string.
Prefer :func:load_context_file or :func:load_context_string for
unambiguous loading.