canonicalize_document
Stable function · Other
Tier: stable · Kind: function · Topic: Other
| Julia | TypeScript | Python | Rust | Go |
|---|---|---|---|---|
canonicalize_document | canonicalizeDocument | canonicalize_document | canonicalize_document | CanonicalizeDocument |
Julia
canonicalize_document(doc::AbstractDict)
canonicalize_document(doc::AbstractDict) -> OrderedDict{String, Any}
The document-level canonical step: every units string of a decoded document
(the JSON object to_json writes and load_document reads, e.g. from
JSON3.read) takes the canonical unit spelling (esm-spec §4.8.2, Lean
Esm.Units.canon).
That is every units and default_units string of a variable, species,
parameter, coordinate or const node, wherever it sits: nested subsystems,
template bodies, tests, coupling entries. Free-form objects (metadata,
x_esd, attrs, config, reader_options) are not touched, and neither are
the keys of name-keyed maps. A const node whose units spell 1 loses them: a
scalar one becomes the bare literal, an array one a const without units.
The input is not mutated, key order is kept, and nothing else changes.
TypeScript
function canonicalizeDocument<T>(doc: T): T
The document-level canonical step: every units string of a document takes
the canonical unit spelling (esm-spec §4.8.2, Lean Esm.Units.canon).
That is every units and default_units string of a variable, species,
parameter, coordinate or const node, wherever it sits: nested subsystems,
template bodies, tests, coupling entries. Free-form objects (metadata,
x_esd, attrs, config, reader_options) are not touched, and neither
are the keys of name-keyed maps. A const node whose units spell 1 loses
them: a scalar one becomes the bare literal, an array one a const without
units. Takes the decoded JSON document (an EsmFile is one); the input is
not mutated and nothing else changes.
Python
canonicalize_document(doc: Any) -> Any
The document-level canonical step: every units string of a decoded
document (the JSON object to_json writes and load_document reads)
takes the canonical unit spelling (esm-spec §4.8.2, Lean
Esm.Units.canon).
That is every units and default_units string of a variable,
species, parameter, coordinate or const node, wherever it sits:
nested subsystems, template bodies, tests, coupling entries. Free-form
objects (metadata, x_esd, attrs, config,
reader_options) are not touched, and neither are the keys of
name-keyed maps. A const node whose units spell 1 loses them: a
scalar one becomes the bare literal, an array one a const without
units. The input is not mutated; nothing else changes.
Rust
pub fn canonicalize_document(doc: &Value) -> Value
The document-level canonical step: every units string of a decoded document
(the JSON value to_json writes and load_document reads) takes the
canonical unit spelling (esm-spec §4.8.2, Lean Esm.Units.canon).
That is every units and default_units string of a variable, species,
parameter, coordinate or const node, wherever it sits: nested subsystems,
template bodies, tests, coupling entries. Free-form objects (metadata,
x_esd, attrs, config, reader_options) are not touched, and neither
are the keys of name-keyed maps. A const node whose units spell 1 loses
them: a scalar one becomes the bare literal, an array one a const without
units. Nothing else changes.
Go
func CanonicalizeDocument(doc any) any
CanonicalizeDocument is the document-level canonical step: every units string of a decoded document (the JSON value ToJSON writes and LoadDocument reads, as produced by encoding/json into any) takes the canonical unit spelling (esm-spec §4.8.2, Lean Esm.Units.canon).
That is every units and default_units string of a variable, species, parameter, coordinate or const node, wherever it sits: nested subsystems, template bodies, tests, coupling entries. Free-form objects (metadata, x_esd, attrs, config, reader_options) are not touched, and neither are the keys of name-keyed maps. A const node whose units spell 1 loses them: a scalar one becomes the bare literal, an array one a const without units. The input is not mutated and nothing else changes.