Skip to content

Installation#

math-spec needs Python 3.12 or above. Nothing is published yet, so install it from git:

pip install git+https://github.com/energy-models/math-spec

To develop against a clone instead, follow contributing.

Editor completion and offline checking#

The YAML keys ship as a JSON Schema, schema/math-spec.schema.json. An editor reads it for key completion, and a job with no Python reads it for a structure check.

Map the schema in VS Code#

Install the Red Hat YAML extension, then map the schema per workspace:

// .vscode/settings.json
"yaml.schemas": { "https://raw.githubusercontent.com/energy-models/math-spec/main/schema/math-spec.schema.json": ["*.model.yaml"] }

or per file, with a modeline on its first line:

# yaml-language-server: $schema=https://raw.githubusercontent.com/energy-models/math-spec/main/schema/math-spec.schema.json

Check a file without Python#

For a pre-commit hook or a non-Python CI job:

uvx check-jsonschema --schemafile https://raw.githubusercontent.com/energy-models/math-spec/main/schema/math-spec.schema.json model.yaml

The schema validates structure only. The math inside expression: and where: is checked by to_spec.