Version: latest (v0.13.0)

canonicalize_document

Stable function · Other

Tier: stable · Kind: function · Topic: Other

JuliaTypeScriptPythonRustGo
canonicalize_documentcanonicalizeDocumentcanonicalize_documentcanonicalize_documentCanonicalizeDocument

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 respelled, 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 deprecated ops are rewritten (esm-spec §4.2): a neg node with one argument becomes unary -, a pow node with two becomes ^, and a broadcast of neg with one argument maps -. Every number, free-form objects included, takes its canonical form (CONFORMANCE §5.5.3.1): an integral value in Int64 is an integer (2.0 is 2, -0.0 is 0). The input is not mutated, key order is kept, and nothing else changes. These are the rules of Lean Adapter.Doc.spellRules and Adapter.Doc.conv.

Source

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 respelled, 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 deprecated ops are rewritten (esm-spec §4.2): a neg node with one argument becomes unary -, a pow node with two becomes ^, and a broadcast of neg with one argument maps -. Every number, free-form objects included, takes its canonical form (CONFORMANCE §5.5.3.1): a NumericLiteral whose value is integral and in Int64 is an int literal (2.0 is 2), any other a float literal, and -0 is 0; a plain number already holds the nearest binary64 of its token. Takes the decoded JSON document (an EsmFile is one; plain numbers or the tagged literals of losslessJsonParse); the input is not mutated and nothing else changes. These are the rules of Lean Adapter.Doc.spellRules and Adapter.Doc.conv.

Source

Python

canonicalize_document(doc: Any) -> Any

The document-level canonical step (esm-spec §4.8.2): every units string of a decoded document (the JSON object to_json writes and load_document reads) takes the canonical unit spelling (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 respelled, 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 deprecated ops are rewritten (esm-spec §4.2): a neg node with one argument becomes unary -, a pow node with two becomes ^, and a broadcast of neg with one argument maps -. Every number, free-form objects included, takes its canonical form (CONFORMANCE §5.5.3.1): an integral value in Int64 is an integer (2.0 is 2). The input is not mutated; nothing else changes. These are the rules of Lean Adapter.Doc.spellRules and Adapter.Doc.conv.

Source

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 respelled, 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 deprecated operators are rewritten (esm-spec §4.2): a neg node with one argument becomes unary -, a pow node with two becomes ^, and a broadcast of neg with one argument maps -. Every number, free-form objects included, takes its canonical form (CONFORMANCE §5.5.3.1): an integral value in Int64 is an integer (0.0 is 0). Nothing else changes. These are the rules of Lean Adapter.Doc.spellRules (the spelling rules) and Adapter.Doc.conv (the numbers).

Source · Rust docs

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 respelled, 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 deprecated ops are rewritten (esm-spec §4.2): a neg node with one argument becomes unary -, a pow node with two becomes ^, and a broadcast of neg with one argument maps -. Every number, free-form objects included, takes its canonical form (CONFORMANCE §5.5.3.1): an integral value in Int64 is an int64 (2.0 is 2, -0.0 is 0), any other finite value a float64. A json.Number (a decoder with UseNumber) that is an integer token in Int64 is that int64 exactly, past 2^53 too; any other token is read as the nearest float64. The input is not mutated and nothing else changes. These are the rules of Lean Adapter.Doc.spellRules and Adapter.Doc.conv.

Source · Go docs