universal-physics-tensor 10.0.0 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/bin/upt.mjs +13 -1
- package/data/atlas/atlas.json +25 -25
- package/data/atlas/atlas.jsonld +1 -1
- package/data/atlas/diffusion.json +6 -6
- package/data/atlas/oscillators.json +7 -7
- package/data/atlas/waves.json +14 -14
- package/data/atlas/witness-results.json +11 -11
- package/data/bridge-catalog.json +371 -228
- package/data/bridge-catalog.schema.json +45 -7
- package/dist/atlas/applicability.d.ts.map +1 -1
- package/dist/atlas/applicability.js +21 -15
- package/dist/atlas/applicability.js.map +1 -1
- package/dist/atlas/benchmark/hybrid-retrieval.d.ts +9 -1
- package/dist/atlas/benchmark/hybrid-retrieval.d.ts.map +1 -1
- package/dist/atlas/benchmark/hybrid-retrieval.js +15 -13
- package/dist/atlas/benchmark/hybrid-retrieval.js.map +1 -1
- package/dist/atlas/benchmark/loader.js +2 -2
- package/dist/atlas/benchmark/loader.js.map +1 -1
- package/dist/atlas/benchmark/stats.d.ts +2 -2
- package/dist/atlas/benchmark/stats.d.ts.map +1 -1
- package/dist/atlas/benchmark/stats.js +15 -7
- package/dist/atlas/benchmark/stats.js.map +1 -1
- package/dist/atlas/catalog-formal-ref.d.ts +26 -3
- package/dist/atlas/catalog-formal-ref.d.ts.map +1 -1
- package/dist/atlas/catalog-formal-ref.js +52 -5
- package/dist/atlas/catalog-formal-ref.js.map +1 -1
- package/dist/atlas/chain-pipeline.d.ts.map +1 -1
- package/dist/atlas/chain-pipeline.js +7 -8
- package/dist/atlas/chain-pipeline.js.map +1 -1
- package/dist/atlas/diffusion/bridges-closure.d.ts +0 -4
- package/dist/atlas/diffusion/bridges-closure.d.ts.map +1 -1
- package/dist/atlas/diffusion/bridges-closure.js +8 -12
- package/dist/atlas/diffusion/bridges-closure.js.map +1 -1
- package/dist/atlas/diffusion/bridges.d.ts.map +1 -1
- package/dist/atlas/diffusion/bridges.js +27 -39
- package/dist/atlas/diffusion/bridges.js.map +1 -1
- package/dist/atlas/diffusion/dimensions.d.ts +6 -14
- package/dist/atlas/diffusion/dimensions.d.ts.map +1 -1
- package/dist/atlas/diffusion/dimensions.js +8 -16
- package/dist/atlas/diffusion/dimensions.js.map +1 -1
- package/dist/atlas/diffusion/models.d.ts +3 -3
- package/dist/atlas/diffusion/models.d.ts.map +1 -1
- package/dist/atlas/diffusion/models.js +5 -10
- package/dist/atlas/diffusion/models.js.map +1 -1
- package/dist/atlas/diffusion/numerics.d.ts +16 -4
- package/dist/atlas/diffusion/numerics.d.ts.map +1 -1
- package/dist/atlas/diffusion/numerics.js +38 -24
- package/dist/atlas/diffusion/numerics.js.map +1 -1
- package/dist/atlas/link-prediction.d.ts +106 -3
- package/dist/atlas/link-prediction.d.ts.map +1 -1
- package/dist/atlas/link-prediction.js +212 -66
- package/dist/atlas/link-prediction.js.map +1 -1
- package/dist/atlas/oscillators/bridges-coarse.d.ts.map +1 -1
- package/dist/atlas/oscillators/bridges-coarse.js +7 -11
- package/dist/atlas/oscillators/bridges-coarse.js.map +1 -1
- package/dist/atlas/oscillators/bridges-exact.d.ts.map +1 -1
- package/dist/atlas/oscillators/bridges-exact.js +6 -7
- package/dist/atlas/oscillators/bridges-exact.js.map +1 -1
- package/dist/atlas/oscillators/bridges-limits.d.ts +3 -16
- package/dist/atlas/oscillators/bridges-limits.d.ts.map +1 -1
- package/dist/atlas/oscillators/bridges-limits.js +23 -34
- package/dist/atlas/oscillators/bridges-limits.js.map +1 -1
- package/dist/atlas/oscillators/dimensions.d.ts +9 -21
- package/dist/atlas/oscillators/dimensions.d.ts.map +1 -1
- package/dist/atlas/oscillators/dimensions.js +9 -21
- package/dist/atlas/oscillators/dimensions.js.map +1 -1
- package/dist/atlas/oscillators/limit-witnesses.d.ts +2 -2
- package/dist/atlas/oscillators/limit-witnesses.d.ts.map +1 -1
- package/dist/atlas/oscillators/limit-witnesses.js +17 -15
- package/dist/atlas/oscillators/limit-witnesses.js.map +1 -1
- package/dist/atlas/oscillators/models.d.ts.map +1 -1
- package/dist/atlas/oscillators/models.js +2 -6
- package/dist/atlas/oscillators/models.js.map +1 -1
- package/dist/atlas/oscillators/pendulum-motion.d.ts +29 -6
- package/dist/atlas/oscillators/pendulum-motion.d.ts.map +1 -1
- package/dist/atlas/oscillators/pendulum-motion.js +60 -40
- package/dist/atlas/oscillators/pendulum-motion.js.map +1 -1
- package/dist/atlas/oscillators/phase-translation.d.ts +0 -11
- package/dist/atlas/oscillators/phase-translation.d.ts.map +1 -1
- package/dist/atlas/oscillators/phase-translation.js +3 -4
- package/dist/atlas/oscillators/phase-translation.js.map +1 -1
- package/dist/atlas/oscillators/position-translation.d.ts +68 -7
- package/dist/atlas/oscillators/position-translation.d.ts.map +1 -1
- package/dist/atlas/oscillators/position-translation.js +123 -12
- package/dist/atlas/oscillators/position-translation.js.map +1 -1
- package/dist/atlas/oscillators/rejections.d.ts +0 -2
- package/dist/atlas/oscillators/rejections.d.ts.map +1 -1
- package/dist/atlas/oscillators/rejections.js +0 -7
- package/dist/atlas/oscillators/rejections.js.map +1 -1
- package/dist/atlas/physjs-entries.generated.d.ts +25 -24
- package/dist/atlas/physjs-entries.generated.d.ts.map +1 -1
- package/dist/atlas/physjs-entries.generated.js +25 -24
- package/dist/atlas/physjs-entries.generated.js.map +1 -1
- package/dist/atlas/physjs-ref.d.ts +34 -31
- package/dist/atlas/physjs-ref.d.ts.map +1 -1
- package/dist/atlas/physjs-ref.js +55 -53
- package/dist/atlas/physjs-ref.js.map +1 -1
- package/dist/atlas/physjs-reviewed.d.ts +1 -1
- package/dist/atlas/physjs-reviewed.js +15 -15
- package/dist/atlas/physjs-reviewed.js.map +1 -1
- package/dist/atlas/poster/statements.d.ts +0 -19
- package/dist/atlas/poster/statements.d.ts.map +1 -1
- package/dist/atlas/poster/statements.js +1 -1
- package/dist/atlas/poster/statements.js.map +1 -1
- package/dist/atlas/proof-target.d.ts +1 -1
- package/dist/atlas/proof-target.js +1 -1
- package/dist/atlas/proof-target.js.map +1 -1
- package/dist/atlas/regime.d.ts +1 -1
- package/dist/atlas/regime.d.ts.map +1 -1
- package/dist/atlas/regime.js +1 -1
- package/dist/atlas/regime.js.map +1 -1
- package/dist/atlas/text-overlap.d.ts +23 -0
- package/dist/atlas/text-overlap.d.ts.map +1 -0
- package/dist/atlas/text-overlap.js +41 -0
- package/dist/atlas/text-overlap.js.map +1 -0
- package/dist/atlas/waves/bridges-closure.d.ts.map +1 -1
- package/dist/atlas/waves/bridges-closure.js +2 -6
- package/dist/atlas/waves/bridges-closure.js.map +1 -1
- package/dist/atlas/waves/bridges.d.ts.map +1 -1
- package/dist/atlas/waves/bridges.js +32 -48
- package/dist/atlas/waves/bridges.js.map +1 -1
- package/dist/atlas/waves/models.d.ts +5 -6
- package/dist/atlas/waves/models.d.ts.map +1 -1
- package/dist/atlas/waves/models.js +7 -13
- package/dist/atlas/waves/models.js.map +1 -1
- package/dist/atlas/waves/numerics.d.ts.map +1 -1
- package/dist/atlas/waves/numerics.js +10 -3
- package/dist/atlas/waves/numerics.js.map +1 -1
- package/dist/atlas/witness-numeric.d.ts +30 -0
- package/dist/atlas/witness-numeric.d.ts.map +1 -1
- package/dist/atlas/witness-numeric.js +53 -0
- package/dist/atlas/witness-numeric.js.map +1 -1
- package/dist/atlas/witness-specs.d.ts.map +1 -1
- package/dist/atlas/witness-specs.js +19 -0
- package/dist/atlas/witness-specs.js.map +1 -1
- package/dist/atlas/witness-symbolic.d.ts +75 -3
- package/dist/atlas/witness-symbolic.d.ts.map +1 -1
- package/dist/atlas/witness-symbolic.js +116 -10
- package/dist/atlas/witness-symbolic.js.map +1 -1
- package/dist/bridges/catalog-load.d.ts.map +1 -1
- package/dist/bridges/catalog-load.js +13 -8
- package/dist/bridges/catalog-load.js.map +1 -1
- package/dist/bridges/catalog-types.d.ts +26 -2
- package/dist/bridges/catalog-types.d.ts.map +1 -1
- package/dist/bridges/catalog-types.js +11 -1
- package/dist/bridges/catalog-types.js.map +1 -1
- package/dist/bridges/evaluation-errors.d.ts +31 -1
- package/dist/bridges/evaluation-errors.d.ts.map +1 -1
- package/dist/bridges/evaluation-errors.js +20 -2
- package/dist/bridges/evaluation-errors.js.map +1 -1
- package/dist/bridges/evaluator-inputs.d.ts.map +1 -1
- package/dist/bridges/evaluator-inputs.js +7 -5
- package/dist/bridges/evaluator-inputs.js.map +1 -1
- package/dist/bridges/evaluators.d.ts.map +1 -1
- package/dist/bridges/evaluators.js +27 -12
- package/dist/bridges/evaluators.js.map +1 -1
- package/dist/bridges/expr-parse.d.ts +11 -0
- package/dist/bridges/expr-parse.d.ts.map +1 -1
- package/dist/bridges/expr-parse.js +14 -5
- package/dist/bridges/expr-parse.js.map +1 -1
- package/dist/bridges/holds.d.ts +35 -3
- package/dist/bridges/holds.d.ts.map +1 -1
- package/dist/bridges/holds.js +117 -23
- package/dist/bridges/holds.js.map +1 -1
- package/dist/bridges/notices.d.ts.map +1 -1
- package/dist/bridges/notices.js +5 -5
- package/dist/bridges/notices.js.map +1 -1
- package/dist/bridges/relation-eval.d.ts +4 -4
- package/dist/bridges/relation-eval.d.ts.map +1 -1
- package/dist/bridges/relation-eval.js +15 -16
- package/dist/bridges/relation-eval.js.map +1 -1
- package/dist/bridges/sensitivity.d.ts.map +1 -1
- package/dist/bridges/sensitivity.js +3 -3
- package/dist/bridges/sensitivity.js.map +1 -1
- package/dist/bridges/validity.d.ts +33 -0
- package/dist/bridges/validity.d.ts.map +1 -0
- package/dist/bridges/validity.js +67 -0
- package/dist/bridges/validity.js.map +1 -0
- package/dist/canonical/entries/atomic.js +1 -3
- package/dist/canonical/entries/atomic.js.map +1 -1
- package/dist/canonical/entries/condensed-matter.d.ts.map +1 -1
- package/dist/canonical/entries/condensed-matter.js +4 -5
- package/dist/canonical/entries/condensed-matter.js.map +1 -1
- package/dist/canonical/entries/dimensional-classics.d.ts.map +1 -1
- package/dist/canonical/entries/dimensional-classics.js +3 -4
- package/dist/canonical/entries/dimensional-classics.js.map +1 -1
- package/dist/canonical/entries/electromagnetism.d.ts.map +1 -1
- package/dist/canonical/entries/electromagnetism.js +4 -10
- package/dist/canonical/entries/electromagnetism.js.map +1 -1
- package/dist/canonical/entries/fluids-waves.d.ts.map +1 -1
- package/dist/canonical/entries/fluids-waves.js +3 -7
- package/dist/canonical/entries/fluids-waves.js.map +1 -1
- package/dist/canonical/entries/mechanics.d.ts.map +1 -1
- package/dist/canonical/entries/mechanics.js +4 -6
- package/dist/canonical/entries/mechanics.js.map +1 -1
- package/dist/canonical/entries/nonmonomial.d.ts.map +1 -1
- package/dist/canonical/entries/nonmonomial.js +9 -17
- package/dist/canonical/entries/nonmonomial.js.map +1 -1
- package/dist/canonical/entries/relativity.d.ts.map +1 -1
- package/dist/canonical/entries/relativity.js +6 -6
- package/dist/canonical/entries/relativity.js.map +1 -1
- package/dist/canonical/entries/thermo-nuclear-cosmo.d.ts.map +1 -1
- package/dist/canonical/entries/thermo-nuclear-cosmo.js +6 -10
- package/dist/canonical/entries/thermo-nuclear-cosmo.js.map +1 -1
- package/dist/canonical/fixed-points.d.ts +94 -0
- package/dist/canonical/fixed-points.d.ts.map +1 -0
- package/dist/canonical/fixed-points.js +81 -0
- package/dist/canonical/fixed-points.js.map +1 -0
- package/dist/canonical/linkage.d.ts.map +1 -1
- package/dist/canonical/linkage.js +25 -44
- package/dist/canonical/linkage.js.map +1 -1
- package/dist/canonical/normal-form.d.ts.map +1 -1
- package/dist/canonical/normal-form.js +5 -11
- package/dist/canonical/normal-form.js.map +1 -1
- package/dist/canonical/structural.d.ts +21 -21
- package/dist/canonical/structural.d.ts.map +1 -1
- package/dist/canonical/structural.js +40 -19
- package/dist/canonical/structural.js.map +1 -1
- package/dist/cases/brownian-sphere.d.ts +3 -3
- package/dist/cases/brownian-sphere.d.ts.map +1 -1
- package/dist/cases/brownian-sphere.js +6 -5
- package/dist/cases/brownian-sphere.js.map +1 -1
- package/dist/cases/damped-resonator.d.ts.map +1 -1
- package/dist/cases/damped-resonator.js +6 -9
- package/dist/cases/damped-resonator.js.map +1 -1
- package/dist/cases/kepler-rv.d.ts +1 -1
- package/dist/cases/kepler-rv.d.ts.map +1 -1
- package/dist/cases/kepler-rv.js +3 -2
- package/dist/cases/kepler-rv.js.map +1 -1
- package/dist/cases/lumped-cooling.d.ts +8 -3
- package/dist/cases/lumped-cooling.d.ts.map +1 -1
- package/dist/cases/lumped-cooling.js +21 -23
- package/dist/cases/lumped-cooling.js.map +1 -1
- package/dist/cases/quadrature.d.ts +7 -9
- package/dist/cases/quadrature.d.ts.map +1 -1
- package/dist/cases/quadrature.js +28 -32
- package/dist/cases/quadrature.js.map +1 -1
- package/dist/cases/resistor-noise.js +4 -4
- package/dist/cases/resistor-noise.js.map +1 -1
- package/dist/cases/skin-depth.d.ts +0 -4
- package/dist/cases/skin-depth.d.ts.map +1 -1
- package/dist/cases/skin-depth.js +3 -7
- package/dist/cases/skin-depth.js.map +1 -1
- package/dist/cli/args.d.ts +23 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +30 -8
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/bindings.d.ts.map +1 -1
- package/dist/cli/bindings.js +5 -4
- package/dist/cli/bindings.js.map +1 -1
- package/dist/cli/command.d.ts +8 -1
- package/dist/cli/command.d.ts.map +1 -1
- package/dist/cli/command.js.map +1 -1
- package/dist/cli/commands/_atlas-map.d.ts +0 -9
- package/dist/cli/commands/_atlas-map.d.ts.map +1 -1
- package/dist/cli/commands/_atlas-map.js +8 -18
- package/dist/cli/commands/_atlas-map.js.map +1 -1
- package/dist/cli/commands/_atlas-route.d.ts.map +1 -1
- package/dist/cli/commands/_atlas-route.js +6 -2
- package/dist/cli/commands/_atlas-route.js.map +1 -1
- package/dist/cli/commands/_discovery-opts.d.ts.map +1 -1
- package/dist/cli/commands/_discovery-opts.js +8 -9
- package/dist/cli/commands/_discovery-opts.js.map +1 -1
- package/dist/cli/commands/atlas.d.ts.map +1 -1
- package/dist/cli/commands/atlas.js +8 -5
- package/dist/cli/commands/atlas.js.map +1 -1
- package/dist/cli/commands/audit.d.ts.map +1 -1
- package/dist/cli/commands/audit.js +8 -1
- package/dist/cli/commands/audit.js.map +1 -1
- package/dist/cli/commands/axes.d.ts.map +1 -1
- package/dist/cli/commands/axes.js +20 -1
- package/dist/cli/commands/axes.js.map +1 -1
- package/dist/cli/commands/confront.d.ts.map +1 -1
- package/dist/cli/commands/confront.js +8 -14
- package/dist/cli/commands/confront.js.map +1 -1
- package/dist/cli/commands/derive.d.ts.map +1 -1
- package/dist/cli/commands/derive.js +22 -22
- package/dist/cli/commands/derive.js.map +1 -1
- package/dist/cli/commands/discover.d.ts.map +1 -1
- package/dist/cli/commands/discover.js +6 -2
- package/dist/cli/commands/discover.js.map +1 -1
- package/dist/cli/commands/eval.d.ts.map +1 -1
- package/dist/cli/commands/eval.js +1 -0
- package/dist/cli/commands/eval.js.map +1 -1
- package/dist/cli/commands/evaluate.d.ts.map +1 -1
- package/dist/cli/commands/evaluate.js +65 -37
- package/dist/cli/commands/evaluate.js.map +1 -1
- package/dist/cli/commands/explain.d.ts.map +1 -1
- package/dist/cli/commands/explain.js +2 -1
- package/dist/cli/commands/explain.js.map +1 -1
- package/dist/cli/commands/ground.d.ts.map +1 -1
- package/dist/cli/commands/ground.js +1 -0
- package/dist/cli/commands/ground.js.map +1 -1
- package/dist/cli/commands/map.d.ts.map +1 -1
- package/dist/cli/commands/map.js +75 -5
- package/dist/cli/commands/map.js.map +1 -1
- package/dist/cli/commands/metric.d.ts.map +1 -1
- package/dist/cli/commands/metric.js +12 -9
- package/dist/cli/commands/metric.js.map +1 -1
- package/dist/cli/commands/path.d.ts +10 -0
- package/dist/cli/commands/path.d.ts.map +1 -1
- package/dist/cli/commands/path.js +25 -3
- package/dist/cli/commands/path.js.map +1 -1
- package/dist/cli/commands/probe.d.ts.map +1 -1
- package/dist/cli/commands/probe.js +59 -16
- package/dist/cli/commands/probe.js.map +1 -1
- package/dist/cli/commands/regime.d.ts.map +1 -1
- package/dist/cli/commands/regime.js +1 -0
- package/dist/cli/commands/regime.js.map +1 -1
- package/dist/cli/commands/retrieve.d.ts.map +1 -1
- package/dist/cli/commands/retrieve.js +1 -0
- package/dist/cli/commands/retrieve.js.map +1 -1
- package/dist/cli/commands/search.d.ts.map +1 -1
- package/dist/cli/commands/search.js +1 -0
- package/dist/cli/commands/search.js.map +1 -1
- package/dist/cli/commands/symbolic.d.ts.map +1 -1
- package/dist/cli/commands/symbolic.js +19 -28
- package/dist/cli/commands/symbolic.js.map +1 -1
- package/dist/cli/commands/testplan.d.ts.map +1 -1
- package/dist/cli/commands/testplan.js +4 -2
- package/dist/cli/commands/testplan.js.map +1 -1
- package/dist/cli/expr-print.d.ts +0 -2
- package/dist/cli/expr-print.d.ts.map +1 -1
- package/dist/cli/expr-print.js +7 -31
- package/dist/cli/expr-print.js.map +1 -1
- package/dist/cli/main.d.ts +7 -0
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +18 -3
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/numeric-flag.d.ts +12 -0
- package/dist/cli/numeric-flag.d.ts.map +1 -0
- package/dist/cli/numeric-flag.js +44 -0
- package/dist/cli/numeric-flag.js.map +1 -0
- package/dist/cli/output.d.ts +20 -0
- package/dist/cli/output.d.ts.map +1 -1
- package/dist/cli/output.js +15 -0
- package/dist/cli/output.js.map +1 -1
- package/dist/cli/record-reach.js +2 -2
- package/dist/cli/record-reach.js.map +1 -1
- package/dist/cli/record-tables.d.ts.map +1 -1
- package/dist/cli/record-tables.js +6 -5
- package/dist/cli/record-tables.js.map +1 -1
- package/dist/cli/record.d.ts +1 -5
- package/dist/cli/record.d.ts.map +1 -1
- package/dist/cli/record.js +9 -8
- package/dist/cli/record.js.map +1 -1
- package/dist/cli/search-index.d.ts.map +1 -1
- package/dist/cli/search-index.js +7 -6
- package/dist/cli/search-index.js.map +1 -1
- package/dist/cli/statuses.d.ts +0 -2
- package/dist/cli/statuses.d.ts.map +1 -1
- package/dist/cli/statuses.js +0 -7
- package/dist/cli/statuses.js.map +1 -1
- package/dist/cli/stored-results.d.ts +7 -0
- package/dist/cli/stored-results.d.ts.map +1 -0
- package/dist/cli/stored-results.js +23 -0
- package/dist/cli/stored-results.js.map +1 -0
- package/dist/cli/version.d.ts.map +1 -1
- package/dist/cli/version.js +7 -5
- package/dist/cli/version.js.map +1 -1
- package/dist/cli-api.d.ts +34 -5
- package/dist/cli-api.d.ts.map +1 -1
- package/dist/cli-api.js +28 -4
- package/dist/cli-api.js.map +1 -1
- package/dist/composition/algebraic-equivalence.d.ts +43 -0
- package/dist/composition/algebraic-equivalence.d.ts.map +1 -0
- package/dist/composition/algebraic-equivalence.js +115 -0
- package/dist/composition/algebraic-equivalence.js.map +1 -0
- package/dist/composition/axes.d.ts +0 -6
- package/dist/composition/axes.d.ts.map +1 -1
- package/dist/composition/axes.js +6 -6
- package/dist/composition/axes.js.map +1 -1
- package/dist/composition/axis-audit.d.ts +47 -20
- package/dist/composition/axis-audit.d.ts.map +1 -1
- package/dist/composition/axis-audit.js +82 -9
- package/dist/composition/axis-audit.js.map +1 -1
- package/dist/composition/bridge-analysis.d.ts +17 -0
- package/dist/composition/bridge-analysis.d.ts.map +1 -1
- package/dist/composition/bridge-analysis.js +102 -55
- package/dist/composition/bridge-analysis.js.map +1 -1
- package/dist/composition/canonical-compare.d.ts +40 -0
- package/dist/composition/canonical-compare.d.ts.map +1 -1
- package/dist/composition/canonical-compare.js +122 -24
- package/dist/composition/canonical-compare.js.map +1 -1
- package/dist/composition/canonical-graph.d.ts +1 -1
- package/dist/composition/canonical-graph.d.ts.map +1 -1
- package/dist/composition/canonical-graph.js +9 -36
- package/dist/composition/canonical-graph.js.map +1 -1
- package/dist/composition/canonical-json.js +2 -2
- package/dist/composition/canonical-json.js.map +1 -1
- package/dist/composition/catalog-graph.d.ts.map +1 -1
- package/dist/composition/catalog-graph.js +2 -5
- package/dist/composition/catalog-graph.js.map +1 -1
- package/dist/composition/chain-candidate.d.ts +8 -0
- package/dist/composition/chain-candidate.d.ts.map +1 -1
- package/dist/composition/chain-candidate.js +9 -2
- package/dist/composition/chain-candidate.js.map +1 -1
- package/dist/composition/chain-match.d.ts +6 -3
- package/dist/composition/chain-match.d.ts.map +1 -1
- package/dist/composition/chain-match.js +4 -1
- package/dist/composition/chain-match.js.map +1 -1
- package/dist/composition/chain-result.d.ts.map +1 -1
- package/dist/composition/chain-result.js +2 -14
- package/dist/composition/chain-result.js.map +1 -1
- package/dist/composition/compose-symbolic.d.ts.map +1 -1
- package/dist/composition/compose-symbolic.js +3 -2
- package/dist/composition/compose-symbolic.js.map +1 -1
- package/dist/composition/compose.d.ts.map +1 -1
- package/dist/composition/compose.js +13 -5
- package/dist/composition/compose.js.map +1 -1
- package/dist/composition/composition-recovery.d.ts.map +1 -1
- package/dist/composition/composition-recovery.js +4 -7
- package/dist/composition/composition-recovery.js.map +1 -1
- package/dist/composition/discovery.d.ts +56 -0
- package/dist/composition/discovery.d.ts.map +1 -1
- package/dist/composition/discovery.js +114 -60
- package/dist/composition/discovery.js.map +1 -1
- package/dist/composition/edge.d.ts +21 -2
- package/dist/composition/edge.d.ts.map +1 -1
- package/dist/composition/edge.js +23 -1
- package/dist/composition/edge.js.map +1 -1
- package/dist/composition/enumerate.d.ts.map +1 -1
- package/dist/composition/enumerate.js +18 -3
- package/dist/composition/enumerate.js.map +1 -1
- package/dist/composition/evaluate-relation.d.ts +35 -11
- package/dist/composition/evaluate-relation.d.ts.map +1 -1
- package/dist/composition/evaluate-relation.js +60 -39
- package/dist/composition/evaluate-relation.js.map +1 -1
- package/dist/composition/explain.d.ts +3 -12
- package/dist/composition/explain.d.ts.map +1 -1
- package/dist/composition/explain.js +7 -20
- package/dist/composition/explain.js.map +1 -1
- package/dist/composition/expr-eval.d.ts.map +1 -1
- package/dist/composition/expr-eval.js +2 -11
- package/dist/composition/expr-eval.js.map +1 -1
- package/dist/composition/expr-simplify.d.ts +16 -0
- package/dist/composition/expr-simplify.d.ts.map +1 -1
- package/dist/composition/expr-simplify.js +15 -20
- package/dist/composition/expr-simplify.js.map +1 -1
- package/dist/composition/formula-shape.d.ts +23 -4
- package/dist/composition/formula-shape.d.ts.map +1 -1
- package/dist/composition/formula-shape.js +57 -17
- package/dist/composition/formula-shape.js.map +1 -1
- package/dist/composition/graph-structure.d.ts +98 -0
- package/dist/composition/graph-structure.d.ts.map +1 -0
- package/dist/composition/graph-structure.js +167 -0
- package/dist/composition/graph-structure.js.map +1 -0
- package/dist/composition/graph-viz-svg.d.ts.map +1 -1
- package/dist/composition/graph-viz-svg.js +1 -1
- package/dist/composition/graph-viz-svg.js.map +1 -1
- package/dist/composition/graph-viz.d.ts.map +1 -1
- package/dist/composition/graph-viz.js +8 -37
- package/dist/composition/graph-viz.js.map +1 -1
- package/dist/composition/identifiability.d.ts +91 -4
- package/dist/composition/identifiability.d.ts.map +1 -1
- package/dist/composition/identifiability.js +363 -6
- package/dist/composition/identifiability.js.map +1 -1
- package/dist/composition/index.d.ts +8 -4
- package/dist/composition/index.d.ts.map +1 -1
- package/dist/composition/index.js +3 -2
- package/dist/composition/index.js.map +1 -1
- package/dist/composition/mathts-quiet.d.ts +4 -3
- package/dist/composition/mathts-quiet.d.ts.map +1 -1
- package/dist/composition/mathts-quiet.js +4 -3
- package/dist/composition/mathts-quiet.js.map +1 -1
- package/dist/composition/mathts-scalar-symbols.d.ts.map +1 -1
- package/dist/composition/mathts-scalar-symbols.js +2 -1
- package/dist/composition/mathts-scalar-symbols.js.map +1 -1
- package/dist/composition/probe/corpus.d.ts +4 -2
- package/dist/composition/probe/corpus.d.ts.map +1 -1
- package/dist/composition/probe/corpus.js +20 -9
- package/dist/composition/probe/corpus.js.map +1 -1
- package/dist/composition/probe/dataset.d.ts +17 -0
- package/dist/composition/probe/dataset.d.ts.map +1 -1
- package/dist/composition/probe/dataset.js +95 -50
- package/dist/composition/probe/dataset.js.map +1 -1
- package/dist/composition/probe/experiment-design.d.ts +5 -1
- package/dist/composition/probe/experiment-design.d.ts.map +1 -1
- package/dist/composition/probe/experiment-design.js +44 -24
- package/dist/composition/probe/experiment-design.js.map +1 -1
- package/dist/composition/probe/falsify.d.ts.map +1 -1
- package/dist/composition/probe/falsify.js +2 -0
- package/dist/composition/probe/falsify.js.map +1 -1
- package/dist/composition/probe/fit.d.ts +6 -0
- package/dist/composition/probe/fit.d.ts.map +1 -1
- package/dist/composition/probe/fit.js +46 -22
- package/dist/composition/probe/fit.js.map +1 -1
- package/dist/composition/probe/frontier.d.ts.map +1 -1
- package/dist/composition/probe/frontier.js +33 -15
- package/dist/composition/probe/frontier.js.map +1 -1
- package/dist/composition/probe/generator.d.ts +27 -1
- package/dist/composition/probe/generator.d.ts.map +1 -1
- package/dist/composition/probe/generator.js +53 -30
- package/dist/composition/probe/generator.js.map +1 -1
- package/dist/composition/probe/index.d.ts +14 -0
- package/dist/composition/probe/index.d.ts.map +1 -1
- package/dist/composition/probe/index.js +6 -0
- package/dist/composition/probe/index.js.map +1 -1
- package/dist/composition/probe/limits.d.ts +24 -1
- package/dist/composition/probe/limits.d.ts.map +1 -1
- package/dist/composition/probe/limits.js +53 -11
- package/dist/composition/probe/limits.js.map +1 -1
- package/dist/composition/probe/pipeline.d.ts.map +1 -1
- package/dist/composition/probe/pipeline.js +10 -4
- package/dist/composition/probe/pipeline.js.map +1 -1
- package/dist/composition/probe/power-law.d.ts +121 -0
- package/dist/composition/probe/power-law.d.ts.map +1 -0
- package/dist/composition/probe/power-law.js +255 -0
- package/dist/composition/probe/power-law.js.map +1 -0
- package/dist/composition/probe/problem.d.ts +7 -4
- package/dist/composition/probe/problem.d.ts.map +1 -1
- package/dist/composition/probe/problem.js +177 -49
- package/dist/composition/probe/problem.js.map +1 -1
- package/dist/composition/probe/report.js +1 -1
- package/dist/composition/probe/report.js.map +1 -1
- package/dist/composition/probe/residual.d.ts +6 -1
- package/dist/composition/probe/residual.d.ts.map +1 -1
- package/dist/composition/probe/residual.js +9 -7
- package/dist/composition/probe/residual.js.map +1 -1
- package/dist/composition/probe/structure.d.ts +82 -17
- package/dist/composition/probe/structure.d.ts.map +1 -1
- package/dist/composition/probe/structure.js +129 -55
- package/dist/composition/probe/structure.js.map +1 -1
- package/dist/composition/probe/study.d.ts +31 -9
- package/dist/composition/probe/study.d.ts.map +1 -1
- package/dist/composition/probe/study.js +236 -181
- package/dist/composition/probe/study.js.map +1 -1
- package/dist/composition/probe/t-tail.d.ts +17 -0
- package/dist/composition/probe/t-tail.d.ts.map +1 -0
- package/dist/composition/probe/t-tail.js +32 -0
- package/dist/composition/probe/t-tail.js.map +1 -0
- package/dist/composition/probe/types.d.ts +3 -0
- package/dist/composition/probe/types.d.ts.map +1 -1
- package/dist/composition/probe/types.js.map +1 -1
- package/dist/composition/proposed-bridges.d.ts +41 -10
- package/dist/composition/proposed-bridges.d.ts.map +1 -1
- package/dist/composition/proposed-bridges.js +100 -55
- package/dist/composition/proposed-bridges.js.map +1 -1
- package/dist/composition/quantity-clusters.d.ts +48 -0
- package/dist/composition/quantity-clusters.d.ts.map +1 -0
- package/dist/composition/quantity-clusters.js +98 -0
- package/dist/composition/quantity-clusters.js.map +1 -0
- package/dist/composition/rational-exponent.d.ts +40 -0
- package/dist/composition/rational-exponent.d.ts.map +1 -0
- package/dist/composition/rational-exponent.js +65 -0
- package/dist/composition/rational-exponent.js.map +1 -0
- package/dist/composition/representative-values.d.ts +22 -0
- package/dist/composition/representative-values.d.ts.map +1 -1
- package/dist/composition/representative-values.js +23 -0
- package/dist/composition/representative-values.js.map +1 -1
- package/dist/composition/retrodiction.d.ts.map +1 -1
- package/dist/composition/retrodiction.js +2 -1
- package/dist/composition/retrodiction.js.map +1 -1
- package/dist/composition/user-equation.d.ts.map +1 -1
- package/dist/composition/user-equation.js +2 -2
- package/dist/composition/user-equation.js.map +1 -1
- package/dist/core/assignment.d.ts +19 -0
- package/dist/core/assignment.d.ts.map +1 -0
- package/dist/core/assignment.js +19 -0
- package/dist/core/assignment.js.map +1 -0
- package/dist/core/compare.d.ts +32 -0
- package/dist/core/compare.d.ts.map +1 -0
- package/dist/core/compare.js +46 -0
- package/dist/core/compare.js.map +1 -0
- package/dist/core/constants.d.ts +30 -30
- package/dist/core/constants.d.ts.map +1 -1
- package/dist/core/constants.js +47 -30
- package/dist/core/constants.js.map +1 -1
- package/dist/core/data-file.d.ts +7 -0
- package/dist/core/data-file.d.ts.map +1 -1
- package/dist/core/data-file.js +17 -0
- package/dist/core/data-file.js.map +1 -1
- package/dist/core/format.d.ts +36 -0
- package/dist/core/format.d.ts.map +1 -0
- package/dist/core/format.js +39 -0
- package/dist/core/format.js.map +1 -0
- package/dist/core/hash.d.ts +14 -0
- package/dist/core/hash.d.ts.map +1 -0
- package/dist/core/hash.js +17 -0
- package/dist/core/hash.js.map +1 -0
- package/dist/core/json-schema.d.ts +2 -0
- package/dist/core/json-schema.d.ts.map +1 -1
- package/dist/core/json-schema.js +14 -13
- package/dist/core/json-schema.js.map +1 -1
- package/dist/core/labeled-tensor.d.ts.map +1 -1
- package/dist/core/labeled-tensor.js +0 -8
- package/dist/core/labeled-tensor.js.map +1 -1
- package/dist/core/mathts-read.d.ts +25 -0
- package/dist/core/mathts-read.d.ts.map +1 -0
- package/dist/core/mathts-read.js +51 -0
- package/dist/core/mathts-read.js.map +1 -0
- package/dist/core/tensor.d.ts.map +1 -1
- package/dist/core/tensor.js +24 -0
- package/dist/core/tensor.js.map +1 -1
- package/dist/core/types.d.ts +5 -5
- package/dist/diff/bridge-gradient.d.ts +19 -6
- package/dist/diff/bridge-gradient.d.ts.map +1 -1
- package/dist/diff/bridge-gradient.js +19 -11
- package/dist/diff/bridge-gradient.js.map +1 -1
- package/dist/diff/bridge-specs.d.ts.map +1 -1
- package/dist/diff/bridge-specs.js +3 -0
- package/dist/diff/bridge-specs.js.map +1 -1
- package/dist/dimensional/algebra.d.ts +18 -0
- package/dist/dimensional/algebra.d.ts.map +1 -1
- package/dist/dimensional/algebra.js +41 -1
- package/dist/dimensional/algebra.js.map +1 -1
- package/dist/dimensional/ast-builders.d.ts +7 -0
- package/dist/dimensional/ast-builders.d.ts.map +1 -1
- package/dist/dimensional/ast-builders.js +11 -0
- package/dist/dimensional/ast-builders.js.map +1 -1
- package/dist/dimensional/ast-leaves.d.ts +81 -0
- package/dist/dimensional/ast-leaves.d.ts.map +1 -0
- package/dist/dimensional/ast-leaves.js +146 -0
- package/dist/dimensional/ast-leaves.js.map +1 -0
- package/dist/dimensional/buckingham.d.ts.map +1 -1
- package/dist/dimensional/buckingham.js +15 -27
- package/dist/dimensional/buckingham.js.map +1 -1
- package/dist/dimensional/constant-rows.js +9 -9
- package/dist/dimensional/constant-rows.js.map +1 -1
- package/dist/dimensional/dimension-inference.d.ts.map +1 -1
- package/dist/dimensional/dimension-inference.js +1 -2
- package/dist/dimensional/dimension-inference.js.map +1 -1
- package/dist/dimensional/errors.d.ts +1 -1
- package/dist/dimensional/errors.d.ts.map +1 -1
- package/dist/dimensional/errors.js +1 -15
- package/dist/dimensional/errors.js.map +1 -1
- package/dist/dimensional/exact-scale.d.ts +0 -17
- package/dist/dimensional/exact-scale.d.ts.map +1 -1
- package/dist/dimensional/exact-scale.js +8 -8
- package/dist/dimensional/exact-scale.js.map +1 -1
- package/dist/dimensional/gauge-field.d.ts.map +1 -1
- package/dist/dimensional/gauge-field.js +2 -2
- package/dist/dimensional/gauge-field.js.map +1 -1
- package/dist/dimensional/hyphen-names.d.ts +12 -2
- package/dist/dimensional/hyphen-names.d.ts.map +1 -1
- package/dist/dimensional/hyphen-names.js +44 -19
- package/dist/dimensional/hyphen-names.js.map +1 -1
- package/dist/dimensional/metric.d.ts.map +1 -1
- package/dist/dimensional/metric.js +0 -1
- package/dist/dimensional/metric.js.map +1 -1
- package/dist/dimensional/symbolic-constants.d.ts +9 -0
- package/dist/dimensional/symbolic-constants.d.ts.map +1 -1
- package/dist/dimensional/symbolic-constants.js +13 -1
- package/dist/dimensional/symbolic-constants.js.map +1 -1
- package/dist/dimensional/types.d.ts +36 -0
- package/dist/dimensional/types.d.ts.map +1 -1
- package/dist/dimensional/types.js +45 -7
- package/dist/dimensional/types.js.map +1 -1
- package/dist/dimensional/unit-data.js +2 -2
- package/dist/dimensional/unit-data.js.map +1 -1
- package/dist/index.d.ts +9 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -4
- package/dist/index.js.map +1 -1
- package/dist/numerical/christoffel-flat.d.ts.map +1 -1
- package/dist/numerical/christoffel-flat.js +3 -2
- package/dist/numerical/christoffel-flat.js.map +1 -1
- package/dist/numerical/covariant-eikonal.d.ts.map +1 -1
- package/dist/numerical/covariant-eikonal.js +34 -11
- package/dist/numerical/covariant-eikonal.js.map +1 -1
- package/dist/numerical/curvature-lowering-helpers.js +3 -2
- package/dist/numerical/curvature-lowering-helpers.js.map +1 -1
- package/dist/numerical/errors.d.ts.map +1 -1
- package/dist/numerical/errors.js +0 -3
- package/dist/numerical/errors.js.map +1 -1
- package/dist/numerical/finite-difference.d.ts +22 -0
- package/dist/numerical/finite-difference.d.ts.map +1 -0
- package/dist/numerical/finite-difference.js +27 -0
- package/dist/numerical/finite-difference.js.map +1 -0
- package/dist/numerical/geodesic-integrator.d.ts.map +1 -1
- package/dist/numerical/geodesic-integrator.js +22 -14
- package/dist/numerical/geodesic-integrator.js.map +1 -1
- package/dist/numerical/geometrized.d.ts.map +1 -1
- package/dist/numerical/geometrized.js +0 -1
- package/dist/numerical/geometrized.js.map +1 -1
- package/dist/numerical/mathts-engine.d.ts.map +1 -1
- package/dist/numerical/mathts-engine.js +10 -24
- package/dist/numerical/mathts-engine.js.map +1 -1
- package/dist/numerical/metric-inverse.d.ts.map +1 -1
- package/dist/numerical/metric-inverse.js +83 -46
- package/dist/numerical/metric-inverse.js.map +1 -1
- package/dist/numerical/null-ray-integrator.d.ts +2 -1
- package/dist/numerical/null-ray-integrator.d.ts.map +1 -1
- package/dist/numerical/null-ray-integrator.js +12 -12
- package/dist/numerical/null-ray-integrator.js.map +1 -1
- package/dist/numerical/painleve-gullstrand-metric.js +2 -2
- package/dist/numerical/painleve-gullstrand-metric.js.map +1 -1
- package/dist/numerical/perihelion-finder.d.ts +0 -36
- package/dist/numerical/perihelion-finder.d.ts.map +1 -1
- package/dist/numerical/perihelion-finder.js +41 -87
- package/dist/numerical/perihelion-finder.js.map +1 -1
- package/dist/numerical/quadrature.d.ts.map +1 -1
- package/dist/numerical/quadrature.js +8 -10
- package/dist/numerical/quadrature.js.map +1 -1
- package/dist/numerical/rk4-trajectory.d.ts +10 -0
- package/dist/numerical/rk4-trajectory.d.ts.map +1 -0
- package/dist/numerical/rk4-trajectory.js +37 -0
- package/dist/numerical/rk4-trajectory.js.map +1 -0
- package/dist/numerical/schwarzschild.d.ts +14 -0
- package/dist/numerical/schwarzschild.d.ts.map +1 -0
- package/dist/numerical/schwarzschild.js +17 -0
- package/dist/numerical/schwarzschild.js.map +1 -0
- package/dist/numerical/spacetime-metrics.d.ts +12 -0
- package/dist/numerical/spacetime-metrics.d.ts.map +1 -1
- package/dist/numerical/spacetime-metrics.js +72 -56
- package/dist/numerical/spacetime-metrics.js.map +1 -1
- package/dist/numerical/statistics.d.ts +24 -0
- package/dist/numerical/statistics.d.ts.map +1 -0
- package/dist/numerical/statistics.js +52 -0
- package/dist/numerical/statistics.js.map +1 -0
- package/dist/numerical/tensor-engine.d.ts +21 -0
- package/dist/numerical/tensor-engine.d.ts.map +1 -1
- package/dist/numerical/tensor-engine.js +12 -0
- package/dist/numerical/tensor-engine.js.map +1 -1
- package/dist/relations/regime.d.ts +10 -0
- package/dist/relations/regime.d.ts.map +1 -1
- package/dist/relations/regime.js +18 -1
- package/dist/relations/regime.js.map +1 -1
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/composition/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAG9C,iGAAiG;AACjG,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,yBAAyB,EACzB,wBAAwB,EACxB,yBAAyB,EACzB,YAAY,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/composition/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAG9C,iGAAiG;AACjG,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,yBAAyB,EACzB,wBAAwB,EACxB,yBAAyB,EACzB,YAAY,EACZ,cAAc,GACf,MAAM,WAAW,CAAC;AACnB,oFAAoF;AACpF,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,iCAAiC,CAAC;AAKzC,OAAO,EACL,YAAY,EACZ,aAAa,EACb,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,uDAAuD;AACvD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEhE,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;AAM9B,OAAO,EACL,qBAAqB,EACrB,0BAA0B,GAC3B,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AASxD,iHAAiH;AACjH,OAAO,EACL,uBAAuB,EACvB,WAAW,EACX,cAAc,EACd,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAW9B,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAO7D,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAG/C,6HAA6H;AAC7H,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG1D,OAAO,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAUnD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AAEjF,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAG9D,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAC5B,0IAA0I;AAC1I,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAChG,sEAAsE","sourcesContent":["/**\n * Composition graph (v0.8.0) — graph-lite `Quantity` / `BridgeEdge` /\n * `composeEdges()` beside the catalog (NOT replacing it; the catalog\n * in `src/bridges/index.ts` stays authoritative).\n *\n * See docs/planning/v0.8.0-Design.md for the design. The catalog edges are\n * projected from `data/bridge-catalog.json` by `./catalog-graph.js`; the\n * pre-registered CT-* composed ids are `REGISTERED_COMPOSITION_IDS` in\n * `./enumerate.js`.\n *\n * @module composition\n */\n\nexport type { Quantity, RegimeAttributes } from './quantity.js';\nexport { regimesDiffer } from './quantity.js';\n\nexport type { BridgeEdge, EdgeConfidence, ValidityDomain } from './edge.js';\n/** Edge evaluation and the errors it throws. An unset coefficient is `CoefficientUnsetError`. */\nexport {\n CoefficientUnsetError,\n CompositionAliasError,\n CompositionDimensionError,\n CompositionJunctionError,\n UndefinedCompositionError,\n evaluateEdge,\n validityDomain,\n} from './edge.js';\n/** The errors one evaluation throws: the input checks, then the validity domain. */\nexport {\n DomainViolationError,\n DuplicateInputError,\n InputTypeError,\n MissingInputError,\n NonFiniteInputError,\n UnknownInputError,\n} from '../bridges/evaluation-errors.js';\n/** A failed validity condition and the inputs it read, as `DomainViolationError.violations` lists them. */\nexport type { DomainInput, DomainViolation } from '../bridges/evaluation-errors.js';\n\nexport type { ComposeOptions, QuantityIdentification } from './compose.js';\nexport {\n composeEdges,\n minConfidence,\n QUANTITY_IDENTIFICATIONS,\n SOURCE_ALIAS_DISPOSITIONS,\n} from './compose.js';\nexport type { AliasDisposition } from './compose.js';\n\nexport { consistencyRatio } from './consistency.js';\n\nexport { M_SUN_KG } from '../core/constants.js';\n/** The catalog graph and the edge for one graph id. */\nexport { catalogEdge, CATALOG_GRAPH } from './catalog-graph.js';\n\nexport {\n CANONICAL_GRAPH,\n canonicalToEdges,\n CANONICAL_CONSTANTS,\n} from './canonical-graph.js';\n\nexport type {\n CompositionCandidate,\n EnumerationReport,\n} from './enumerate.js';\nexport {\n enumerateCompositions,\n REGISTERED_COMPOSITION_IDS,\n} from './enumerate.js';\n\nexport type { UncertaintyResult } from './uncertainty.js';\nexport { propagateUncertainty } from './uncertainty.js';\n\n/** The classifier's verdict, result and option types, and the rank instrument's report. */\nexport type {\n IdentifiabilityVerdict,\n IdentifiabilityResult,\n IdentifiabilityOptions,\n RankIdentifiability,\n} from './identifiability.js';\n/** The forward closure, the per-target classifier, the sweep, and the log-space rank over the monomial edges. */\nexport {\n classifyIdentifiability,\n classifyAll,\n forwardClosure,\n identifiabilityByRank,\n} from './identifiability.js';\n\n/** The retrodiction harness's result, prediction, refusal, report and option types. */\nexport type {\n RetrodictionOutcome,\n RetrodictionPrediction,\n RetrodictionResult,\n RetrodictionRefusal,\n RetrodictionReport,\n RetrodictionOptions,\n} from './retrodiction.js';\nexport { retrodict, retrodictNode } from './retrodiction.js';\n\nexport type {\n DerivationExplanation,\n ExplainOptions,\n QuantityExplanation,\n} from './explain.js';\nexport { explainQuantity } from './explain.js';\n/** The result of {@link evaluateRelation}. A value carries a dimension. An unset coefficient carries the formula. */\nexport type { Evaluation, ExtraOutput } from './evaluate-relation.js';\n/** Evaluate a catalog id or a canonical id. A sourced number is `kind: 'value'`. An unset coefficient is `kind: 'unset'`. */\nexport { evaluateRelation } from './evaluate-relation.js';\n\nexport type { Observable, ComposeSymbolicOptions } from './compose-symbolic.js';\nexport { composeSymbolic, SymbolicCompositionError } from './compose-symbolic.js';\nexport { SymbolicEvalError } from './expr-eval.js';\n\nexport type {\n VizStatus,\n VizJunction,\n VizCluster,\n VizOptions,\n VizModel,\n VizFilterStats,\n} from './graph-viz.js';\nexport { buildVizModel, edgeToJunction } from './graph-viz.js';\nexport { renderDotToSvg, SvgRendererUnavailableError } from './graph-viz-svg.js';\nexport type { DimensionAdjacency } from './dimension-adjacency.js';\nexport { dimensionAdjacency } from './dimension-adjacency.js';\nexport type { UserEquation, EquationLanding } from './user-equation.js';\nexport type { EquationAnalysis, EquationHint } from './user-equation.js';\nexport {\n parseUserEquation,\n suggestQuantities,\n suggestByDimension,\n equationLanding,\n analyzeUserEquation,\n UserEquationError,\n} from './user-equation.js';\n/** The catalog or parameter name a spelling means. Two spellings of one quantity that disagree throw {@link SynonymDisagreementError}. */\nexport { resolveQuantityName, SynonymDisagreementError } from '../dimensional/formula-names.js';\n// formatConnectedSummary stays internal — CLI reaches it via cli-api."]}
|
|
@@ -12,9 +12,10 @@
|
|
|
12
12
|
* THE INVARIANT: the replacement is process-global, so a concurrent caller in
|
|
13
13
|
* the same process (a worker pool thread, a vitest worker sharing a process)
|
|
14
14
|
* loses its console for the window. The window is therefore confined to the
|
|
15
|
-
* peer's ONE-TIME load and first-use smoke in `expr-simplify.ts
|
|
16
|
-
* `mathts-scalar-symbols.ts
|
|
17
|
-
* replaced once per process, and never
|
|
15
|
+
* peer's ONE-TIME load and first-use smoke in `expr-simplify.ts`,
|
|
16
|
+
* `mathts-scalar-symbols.ts` and `algebraic-equivalence.ts`: each caches the
|
|
17
|
+
* loaded function, so the sinks are replaced once per process, and never
|
|
18
|
+
* around a per-call parse or simplify.
|
|
18
19
|
* Both helpers restore the sinks in `finally`, so a throw inside the window
|
|
19
20
|
* cannot leave them replaced. `tests/composition/mathts-quiet.test.ts` scans
|
|
20
21
|
* `src/` for any other reassignment and traps the sinks during a call.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mathts-quiet.d.ts","sourceRoot":"","sources":["../../src/composition/mathts-quiet.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"mathts-quiet.d.ts","sourceRoot":"","sources":["../../src/composition/mathts-quiet.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAsBH,uFAAuF;AACvF,wBAAgB,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAO7C;AAED,oGAAoG;AACpG,wBAAsB,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAOjE"}
|
|
@@ -12,9 +12,10 @@
|
|
|
12
12
|
* THE INVARIANT: the replacement is process-global, so a concurrent caller in
|
|
13
13
|
* the same process (a worker pool thread, a vitest worker sharing a process)
|
|
14
14
|
* loses its console for the window. The window is therefore confined to the
|
|
15
|
-
* peer's ONE-TIME load and first-use smoke in `expr-simplify.ts
|
|
16
|
-
* `mathts-scalar-symbols.ts
|
|
17
|
-
* replaced once per process, and never
|
|
15
|
+
* peer's ONE-TIME load and first-use smoke in `expr-simplify.ts`,
|
|
16
|
+
* `mathts-scalar-symbols.ts` and `algebraic-equivalence.ts`: each caches the
|
|
17
|
+
* loaded function, so the sinks are replaced once per process, and never
|
|
18
|
+
* around a per-call parse or simplify.
|
|
18
19
|
* Both helpers restore the sinks in `finally`, so a throw inside the window
|
|
19
20
|
* cannot leave them replaced. `tests/composition/mathts-quiet.test.ts` scans
|
|
20
21
|
* `src/` for any other reassignment and traps the sinks during a call.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mathts-quiet.js","sourceRoot":"","sources":["../../src/composition/mathts-quiet.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"mathts-quiet.js","sourceRoot":"","sources":["../../src/composition/mathts-quiet.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAQH,SAAS,OAAO;IACd,MAAM,KAAK,GAAU,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAC/F,OAAO,CAAC,IAAI,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;IACxB,OAAO,CAAC,KAAK,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;IACxB,OAAO,CAAC,MAA6B,CAAC,KAAK,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC;IAC1D,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,OAAO,CAAC,KAAY;IAC3B,OAAO,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;IAC1B,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IAC3B,OAAO,CAAC,MAA6B,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;AAC7D,CAAC;AAED,uFAAuF;AACvF,MAAM,UAAU,WAAW,CAAI,EAAW;IACxC,MAAM,KAAK,GAAG,OAAO,EAAE,CAAC;IACxB,IAAI,CAAC;QACH,OAAO,EAAE,EAAE,CAAC;IACd,CAAC;YAAS,CAAC;QACT,OAAO,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;AACH,CAAC;AAED,oGAAoG;AACpG,MAAM,CAAC,KAAK,UAAU,OAAO,CAAI,EAAoB;IACnD,MAAM,KAAK,GAAG,OAAO,EAAE,CAAC;IACxB,IAAI,CAAC;QACH,OAAO,MAAM,EAAE,EAAE,CAAC;IACpB,CAAC;YAAS,CAAC;QACT,OAAO,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;AACH,CAAC","sourcesContent":["/**\n * Load the MathTS peer without its console chatter reaching stderr.\n *\n * MathTS writes with `console.warn`/`console.error` directly (its `warnOnce`,\n * the factorisation fallbacks, the WASM-integrity notice) and offers no option\n * to route or silence them: `ImportOptions.silent` is for importing user\n * functions, not for logging. The only way to keep that text out of a CLI's\n * stderr is to replace the three process-global sinks for the duration of the\n * call, which is what the two helpers here do, and nothing else in `src/` may\n * do.\n *\n * THE INVARIANT: the replacement is process-global, so a concurrent caller in\n * the same process (a worker pool thread, a vitest worker sharing a process)\n * loses its console for the window. The window is therefore confined to the\n * peer's ONE-TIME load and first-use smoke in `expr-simplify.ts`,\n * `mathts-scalar-symbols.ts` and `algebraic-equivalence.ts`: each caches the\n * loaded function, so the sinks are replaced once per process, and never\n * around a per-call parse or simplify.\n * Both helpers restore the sinks in `finally`, so a throw inside the window\n * cannot leave them replaced. `tests/composition/mathts-quiet.test.ts` scans\n * `src/` for any other reassignment and traps the sinks during a call.\n *\n * @module composition/mathts-quiet\n */\n\ntype Sinks = {\n readonly warn: typeof console.warn;\n readonly error: typeof console.error;\n readonly write: typeof process.stderr.write;\n};\n\nfunction silence(): Sinks {\n const saved: Sinks = { warn: console.warn, error: console.error, write: process.stderr.write };\n console.warn = () => {};\n console.error = () => {};\n (process.stderr as { write: unknown }).write = () => true;\n return saved;\n}\n\nfunction restore(saved: Sinks): void {\n console.warn = saved.warn;\n console.error = saved.error;\n (process.stderr as { write: unknown }).write = saved.write;\n}\n\n/** Run `fn` with the console sinks replaced, restoring them in `finally`. @internal */\nexport function quietlySync<T>(fn: () => T): T {\n const saved = silence();\n try {\n return fn();\n } finally {\n restore(saved);\n }\n}\n\n/** The asynchronous form of {@link quietlySync}: the window spans the awaited promise. @internal */\nexport async function quietly<T>(fn: () => Promise<T>): Promise<T> {\n const saved = silence();\n try {\n return await fn();\n } finally {\n restore(saved);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mathts-scalar-symbols.d.ts","sourceRoot":"","sources":["../../src/composition/mathts-scalar-symbols.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;
|
|
1
|
+
{"version":3,"file":"mathts-scalar-symbols.d.ts","sourceRoot":"","sources":["../../src/composition/mathts-scalar-symbols.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAKH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEzD,yEAAyE;AACzE,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;CACzB;AAED,UAAU,QAAQ;IAChB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;CACzB;AAeD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAA;CAAE,EACxD,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAC7B,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,GAC1B,MAAM,CASR;AAsFD;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,QAAQ,GAAG,YAAY,EAAE,CAetE"}
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import { parse as mathtsParse } from '@danielsimonjr/mathts-functions';
|
|
16
16
|
import { quietlySync } from './mathts-quiet.js';
|
|
17
|
-
|
|
17
|
+
import { isDecimalLiteral } from '../dimensional/ast-leaves.js';
|
|
18
|
+
const isLiteral = isDecimalLiteral;
|
|
18
19
|
/**
|
|
19
20
|
* Render one symbol the way `expr-simplify.ts` does: a numeric literal stays
|
|
20
21
|
* a number, and every other name becomes `gN`. Repeated names share one
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mathts-scalar-symbols.js","sourceRoot":"","sources":["../../src/composition/mathts-scalar-symbols.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,KAAK,IAAI,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"mathts-scalar-symbols.js","sourceRoot":"","sources":["../../src/composition/mathts-scalar-symbols.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,KAAK,IAAI,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AA0BhE,MAAM,SAAS,GAAG,gBAAgB,CAAC;AAEnC;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAC9B,IAAwD,EACxD,QAA6B,EAC7B,IAA2B;IAE3B,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3D,IAAI,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChC,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;QACpB,CAAC,GAAG,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC;QACxB,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QAC3B,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE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IACf,CAAC,CAAC,CAAC;IACH,WAAW,GAAG,KAAK,CAAC;IACpB,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,uBAAuB,CAAC,IAAc;IACpD,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC3C,MAAM,IAAI,GAAG,IAAI,GAAG,EAAoB,CAAC;IACzC,MAAM,QAAQ,GAAG,iBAAiB,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;IACzD,IAAI,QAAQ,KAAK,IAAI;QAAE,OAAO,EAAE,CAAC;IACjC,MAAM,IAAI,GAAG,WAAW,EAAE,CAAC,QAAQ,CAAC,CAAC;IACrC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,MAAM,MAAM,GAAmB,EAAE,CAAC;IAClC,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,YAAY,KAAK,IAAI,CAAC,EAAE,CAAC;QACjF,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAC7E,IAAI,MAAM,KAAK,SAAS,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;YAAE,SAAS;QAC5D,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACtB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACtB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["/**\n * Scalar leaves of an `ExprNode`, read from a MathTS AST.\n *\n * `governingOf` and the free-leaf list in `compose-symbolic.ts` both call\n * {@link scalarSymbolsFromMathTs}. The names come from that node's symbol\n * filter. This module does not walk `ExprNode` to collect them.\n *\n * The rendered text uses the same gensym as `expr-simplify.ts`: a bare `e`\n * is `gN`, never the identifier MathTS reads as Euler's number. Mapped back,\n * the name is the elementary charge. `exp(1)` does not introduce `e`.\n * Tensor and curvature kinds contribute no symbol.\n *\n * @module composition/mathts-scalar-symbols\n */\n\nimport { parse as mathtsParse } from '@danielsimonjr/mathts-functions';\nimport { quietlySync } from './mathts-quiet.js';\nimport { isDecimalLiteral } from '../dimensional/ast-leaves.js';\nimport type { ExprNode } from '../dimensional/validator.js';\nimport type { Dimension } from '../dimensional/types.js';\n\n/** One scalar leaf and the dimension stored on that symbol. @internal */\nexport interface ScalarSymbol {\n readonly name: string;\n readonly dim: Dimension;\n}\n\ninterface LeafMeta {\n readonly name: string;\n readonly dim: Dimension;\n}\n\n/** The bits of a MathTS node this reader uses. */\ninterface MathNode {\n filter(predicate: (node: MathNode) => boolean): MathNode[];\n readonly isSymbolNode?: boolean;\n readonly name?: string;\n}\n\ninterface MathtsFunctionsModule {\n parse(expr: string): MathNode;\n}\n\nconst isLiteral = isDecimalLiteral;\n\n/**\n * Render one symbol the way `expr-simplify.ts` does: a numeric literal stays\n * a number, and every other name becomes `gN`. Repeated names share one\n * gensym, so MathTS never sees the physics spelling of `e`.\n *\n * @internal\n */\nexport function renderScalarLeaf(\n expr: { readonly name: string; readonly dim: Dimension },\n gensymOf: Map<string, string>,\n meta: Map<string, LeafMeta>,\n): string {\n if (isLiteral(expr.name)) return String(Number(expr.name));\n let g = gensymOf.get(expr.name);\n if (g === undefined) {\n g = `g${gensymOf.size}`;\n gensymOf.set(expr.name, g);\n meta.set(g, { name: expr.name, dim: expr.dim });\n }\n return g;\n}\n\n/**\n * A MathTS expression whose symbol nodes are the scalar leaves.\n * Integral bounds are omitted: the previous leaf list did not include them.\n * A curvature or tensor kind returns null.\n */\nfunction renderSymbolQuery(\n expr: ExprNode,\n gensymOf: Map<string, string>,\n meta: Map<string, LeafMeta>,\n): string | null {\n switch (expr.kind) {\n case 'symbol':\n return renderScalarLeaf(expr, gensymOf, meta);\n case 'op': {\n const parts: string[] = [];\n for (const arg of expr.args) {\n const part = renderSymbolQuery(arg, gensymOf, meta);\n if (part !== null) parts.push(part);\n }\n return joinParts(parts, expr.op);\n }\n case 'transcendental':\n case 'abs':\n case 'dirac-delta':\n return renderSymbolQuery(expr.arg, gensymOf, meta);\n case 'integral':\n return joinParts(\n [\n renderSymbolQuery(expr.over, gensymOf, meta),\n renderSymbolQuery(expr.integrand, gensymOf, meta),\n ].filter((part): part is string => part !== null),\n '+',\n );\n case 'derivative':\n return joinParts(\n [\n renderSymbolQuery(expr.of, gensymOf, meta),\n renderSymbolQuery(expr.wrt, gensymOf, meta),\n ].filter((part): part is string => part !== null),\n '+',\n );\n case 'variational-derivative':\n return joinParts(\n [\n renderSymbolQuery(expr.functional, gensymOf, meta),\n renderSymbolQuery(expr.field, gensymOf, meta),\n renderSymbolQuery(expr.over, gensymOf, meta),\n ].filter((part): part is string => part !== null),\n '+',\n );\n default:\n return null;\n }\n}\n\nfunction joinParts(parts: readonly string[], op: string): string | null {\n if (parts.length === 0) return null;\n if (parts.length === 1) return parts[0] ?? null;\n return `(${parts.map((part) => `(${part})`).join(op)})`;\n}\n\nlet cachedParse: MathtsFunctionsModule['parse'] | undefined;\n\n/**\n * `parse`, bound once. The package is a required dependency and `quadrature.ts`\n * already imports it statically, so this module imports it the same way (a\n * `createRequire` of the ESM package once stood here, which needs Node 22.12 or\n * 20.19 while `engines` says 18; Tom's second round). The first parse runs\n * inside the one console-silencing window this module opens (`mathts-quiet.ts`\n * states the invariant): the peer's WASM-fallback chatter fires lazily on first\n * use, so the smoke parse is that first use, and every later parse runs with the\n * console untouched.\n */\nfunction mathTsParse(): MathtsFunctionsModule['parse'] {\n if (cachedParse !== undefined) return cachedParse;\n const parse = quietlySync(() => {\n const bound = (mathtsParse as MathtsFunctionsModule['parse']).bind(undefined);\n bound('g0');\n return bound;\n });\n cachedParse = parse;\n return cachedParse;\n}\n\n/**\n * Distinct scalar leaves of `expr`, in first-seen order.\n *\n * The MathTS symbol filter supplies the names. A gensym that this renderer\n * did not issue is dropped, so a function callee such as `exp` is not a leaf.\n * Tensor and curvature kinds return an empty list.\n *\n * @internal\n */\nexport function scalarSymbolsFromMathTs(expr: ExprNode): ScalarSymbol[] {\n const gensymOf = new Map<string, string>();\n const meta = new Map<string, LeafMeta>();\n const rendered = renderSymbolQuery(expr, gensymOf, meta);\n if (rendered === null) return [];\n const node = mathTsParse()(rendered);\n const seen = new Set<string>();\n const leaves: ScalarSymbol[] = [];\n for (const symbol of node.filter((candidate) => candidate.isSymbolNode === true)) {\n const issued = symbol.name !== undefined ? meta.get(symbol.name) : undefined;\n if (issued === undefined || seen.has(issued.name)) continue;\n seen.add(issued.name);\n leaves.push(issued);\n }\n return leaves;\n}\n"]}
|
|
@@ -25,11 +25,13 @@ export declare function compareToCorpus(expr: ExprNode, corpusVersion: string):
|
|
|
25
25
|
* pendulum fitted on finite-amplitude data gives ĉ = 7.39, not 2π. Only a fully
|
|
26
26
|
* quantitative canonical entry records a prefactor; for any other match the
|
|
27
27
|
* note says the fitted value is not compared. `tolerance` is relative (the
|
|
28
|
-
* holdout tolerance of the run)
|
|
28
|
+
* holdout tolerance of the run) and is what decides agreement; when the fit
|
|
29
|
+
* carries a standard error `stderr`, the note also states the difference in
|
|
30
|
+
* σ beside that verdict, and decides nothing by it.
|
|
29
31
|
*
|
|
30
32
|
* @internal
|
|
31
33
|
*/
|
|
32
|
-
export declare function corpusPrefactorNotes(result: CorpusComparisonResult, candidate: ExprNode, fitted: number, tolerance: number): string[];
|
|
34
|
+
export declare function corpusPrefactorNotes(result: CorpusComparisonResult, candidate: ExprNode, fitted: number, tolerance: number, stderr?: number | null): string[];
|
|
33
35
|
/** Allowed automated novelty sentence. @internal */
|
|
34
36
|
export declare function corpusRelativeWording(result: CorpusComparisonResult): string;
|
|
35
37
|
//# sourceMappingURL=corpus.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"corpus.d.ts","sourceRoot":"","sources":["../../../src/composition/probe/corpus.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"corpus.d.ts","sourceRoot":"","sources":["../../../src/composition/probe/corpus.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAW/D,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,QAAQ,CAAC;CACxC;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,YAAY,EAAE,SAAS,WAAW,EAAE,CAAC;IAC9C,QAAQ,CAAC,gBAAgB,EAAE,SAAS,WAAW,EAAE,CAAC;IAClD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAID,sEAAsE;AACtE,wBAAgB,eAAe,CAAC,IAAI,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,GAAG,sBAAsB,CA4B7F;AAgDD;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,sBAAsB,EAC9B,SAAS,EAAE,QAAQ,EACnB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GACrB,MAAM,EAAE,CA0CV;AAED,oDAAoD;AACpD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,sBAAsB,GAAG,MAAM,CAM5E"}
|
|
@@ -11,6 +11,7 @@ import { monomialToExpr } from './generator.js';
|
|
|
11
11
|
import { evalExpr } from '../expr-eval.js';
|
|
12
12
|
import { equals } from '../../dimensional/algebra.js';
|
|
13
13
|
import { canonicalPrefactor } from '../canonical-prefactors.js';
|
|
14
|
+
import { constantRatio, fixedPoint } from '../../canonical/fixed-points.js';
|
|
14
15
|
const CORPUS_ID = 'upt-l-layer+b-layer';
|
|
15
16
|
/** Compare an expression to the in-repo L- and B-layers. @internal */
|
|
16
17
|
export function compareToCorpus(expr, corpusVersion) {
|
|
@@ -62,8 +63,9 @@ function dimensionedSymbols(node, out) {
|
|
|
62
63
|
* The corpus prefactor k of a fully quantitative canonical entry against a
|
|
63
64
|
* candidate body: `scalarAst / candidate`, which must be constant. Symbols align
|
|
64
65
|
* by name, then by a dimension exactly one candidate symbol carries. Evaluated at
|
|
65
|
-
* three points where variable i takes (1.7 + i)^p, p = 1, 1.3, 1.6
|
|
66
|
-
* the
|
|
66
|
+
* three points where variable i takes (1.7 + i)^p, p = 1, 1.3, 1.6 (`fixedPoint`, base 1.7,
|
|
67
|
+
* step 1), and the ratio is constant when its largest relative departure is at most 1e-9
|
|
68
|
+
* (`constantRatio`). `null` when the symbols do not align or the ratio is not constant.
|
|
67
69
|
*/
|
|
68
70
|
function corpusPrefactor(ast, candidate) {
|
|
69
71
|
const astSyms = dimensionedSymbols(ast, new Map());
|
|
@@ -86,12 +88,12 @@ function corpusPrefactor(ast, candidate) {
|
|
|
86
88
|
}
|
|
87
89
|
const names = [...candSyms.keys()].sort();
|
|
88
90
|
const ratios = [1, 1.3, 1.6].map((p) => {
|
|
89
|
-
const vals =
|
|
91
|
+
const vals = fixedPoint(names, p, { base: 1.7, step: 1 });
|
|
90
92
|
const astVals = Object.fromEntries([...toCand].map(([s, c]) => [s, vals[c]]));
|
|
91
93
|
return evalExpr(ast, astVals) / evalExpr(candidate, vals);
|
|
92
94
|
});
|
|
93
|
-
const
|
|
94
|
-
return
|
|
95
|
+
const decided = constantRatio(ratios, 1e-9);
|
|
96
|
+
return decided.constant ? decided.value : null;
|
|
95
97
|
}
|
|
96
98
|
/**
|
|
97
99
|
* Compare a FITTED prefactor with the prefactor of each corpus relation the
|
|
@@ -100,12 +102,20 @@ function corpusPrefactor(ast, candidate) {
|
|
|
100
102
|
* pendulum fitted on finite-amplitude data gives ĉ = 7.39, not 2π. Only a fully
|
|
101
103
|
* quantitative canonical entry records a prefactor; for any other match the
|
|
102
104
|
* note says the fitted value is not compared. `tolerance` is relative (the
|
|
103
|
-
* holdout tolerance of the run)
|
|
105
|
+
* holdout tolerance of the run) and is what decides agreement; when the fit
|
|
106
|
+
* carries a standard error `stderr`, the note also states the difference in
|
|
107
|
+
* σ beside that verdict, and decides nothing by it.
|
|
104
108
|
*
|
|
105
109
|
* @internal
|
|
106
110
|
*/
|
|
107
|
-
export function corpusPrefactorNotes(result, candidate, fitted, tolerance) {
|
|
111
|
+
export function corpusPrefactorNotes(result, candidate, fitted, tolerance, stderr) {
|
|
108
112
|
const c = fitted.toPrecision(4);
|
|
113
|
+
const inSigma = (k) => {
|
|
114
|
+
if (stderr === undefined || stderr === null || !(stderr > 0))
|
|
115
|
+
return '';
|
|
116
|
+
const z = (fitted - k) / stderr;
|
|
117
|
+
return `; ${z >= 0 ? '+' : ''}${z.toFixed(1)}σ (σ_ĉ = ${Number(stderr.toPrecision(2))})`;
|
|
118
|
+
};
|
|
109
119
|
return result.algebraicMatches.map((m) => {
|
|
110
120
|
const entry = m.layer === 'canonical' ? CANONICAL_EQUATIONS.find((e) => e.id === m.id) : undefined;
|
|
111
121
|
let k = null;
|
|
@@ -133,11 +143,12 @@ export function corpusPrefactorNotes(result, candidate, fitted, tolerance) {
|
|
|
133
143
|
return `${m.id} records no prefactor, so the fitted ĉ=${c} is not compared with it`;
|
|
134
144
|
const rel = fitted / k - 1;
|
|
135
145
|
if (Math.abs(rel) <= tolerance) {
|
|
136
|
-
return `fitted ĉ=${c} agrees with ${m.id}'s prefactor ${k.toPrecision(4)} (within the holdout tolerance ${tolerance})`;
|
|
146
|
+
return `fitted ĉ=${c} agrees with ${m.id}'s prefactor ${k.toPrecision(4)} (within the holdout tolerance ${tolerance}${inSigma(k)})`;
|
|
137
147
|
}
|
|
138
148
|
const pct = `${rel > 0 ? '+' : ''}${Math.round(rel * 100)}%`;
|
|
149
|
+
const sigma = inSigma(k);
|
|
139
150
|
return (`fitted ĉ=${c} contradicts ${m.id}'s prefactor ${k.toPrecision(4)} (${pct}): ` +
|
|
140
|
-
|
|
151
|
+
`the data may lie outside that relation's regime${sigma === '' ? '' : `; the difference is ${sigma.slice(2)}`}`);
|
|
141
152
|
});
|
|
142
153
|
}
|
|
143
154
|
/** Allowed automated novelty sentence. @internal */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"corpus.js","sourceRoot":"","sources":["../../../src/composition/probe/corpus.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAEtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAehE,MAAM,SAAS,GAAG,qBAAqB,CAAC;AAExC,sEAAsE;AACtE,MAAM,UAAU,eAAe,CAAC,IAAc,EAAE,aAAqB;IACnE,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IAC9B,MAAM,SAAS,GAAkB,EAAE,CAAC;IACpC,KAAK,MAAM,EAAE,IAAI,mBAAmB,EAAE,CAAC;QACrC,IAAI,EAAE,CAAC,SAAS,IAAI,UAAU,CAAC,EAAE,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE,CAAC;YACtD,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,EA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wCAAwC,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,aAAa,KAAK,GAAG,EAAE,CAAC;IACnG,CAAC;IACD,OAAO,qCAAqC,MAAM,CAAC,QAAQ,YAAY,MAAM,CAAC,aAAa,iFAAiF,CAAC;AAC/K,CAAC","sourcesContent":["/**\n * In-repo corpus comparison: canonical scalarAst + normalForm.\n * Novelty wording is always corpus-relative.\n *\n * @module composition/probe/corpus\n */\n\nimport type { ExprNode } from '../../dimensional/ast-types.js';\nimport { CANONICAL_EQUATIONS } from '../../canonical/registry.js';\nimport { normalForm } from '../../canonical/normal-form.js';\nimport { BRIDGE_RHS_BY_ID } from '../../bridges/rhs-registry.js';\nimport { monomialToExpr } from './generator.js';\nimport { evalExpr } from '../expr-eval.js';\nimport { equals } from '../../dimensional/algebra.js';\nimport type { Dimension } from '../../dimensional/types.js';\nimport { canonicalPrefactor } from '../canonical-prefactors.js';\n\nexport interface CorpusMatch {\n readonly id: string;\n readonly layer: 'canonical' | 'bridge';\n}\n\nexport interface CorpusComparisonResult {\n readonly corpusId: string;\n readonly corpusVersion: string;\n readonly exactMatches: readonly CorpusMatch[];\n readonly algebraicMatches: readonly CorpusMatch[];\n readonly searchedAt: string;\n}\n\nconst CORPUS_ID = 'upt-l-layer+b-layer';\n\n/** Compare an expression to the in-repo L- and B-layers. @internal */\nexport function compareToCorpus(expr: ExprNode, corpusVersion: string): CorpusComparisonResult {\n const form = normalForm(expr);\n const algebraic: CorpusMatch[] = [];\n for (const ce of CANONICAL_EQUATIONS) {\n if (ce.scalarAst && normalForm(ce.scalarAst) === form) {\n algebraic.push({ id: ce.id, layer: 'canonical' });\n } else if (ce.dimensional?.monomial) {\n const mono = monomialToExpr(ce.dimensional.monomial, [\n ce.dimensional.target,\n ...ce.dimensional.governing,\n ]);\n if (normalForm(mono) === form) {\n algebraic.push({ id: ce.id, layer: 'canonical' });\n }\n }\n }\n for (const [id, rhs] of BRIDGE_RHS_BY_ID.entries()) {\n if (rhs && normalForm(rhs) === form) {\n algebraic.push({ id: `be-${id}`, layer: 'bridge' });\n }\n }\n return {\n corpusId: CORPUS_ID,\n corpusVersion,\n exactMatches: [],\n algebraicMatches: algebraic,\n searchedAt: new Date().toISOString(),\n };\n}\n\n/**\n * The symbols of an AST that carry a dimension, with that dimension. Numeric\n * literals and named numbers (`8pi`) are dimensionless and left out; so is a\n * dimensionless variable, which then makes the ratio vary and returns no prefactor.\n */\nfunction dimensionedSymbols(node: ExprNode, out: Map<string, Dimension>): Map<string, Dimension> {\n if (node.kind === 'symbol') {\n if (Object.values(node.dim).some((e) => e !== 0)) out.set(node.name, node.dim);\n return out;\n }\n for (const a of (node as { args?: readonly ExprNode[] }).args ?? []) dimensionedSymbols(a, out);\n return out;\n}\n\n/**\n * The corpus prefactor k of a fully quantitative canonical entry against a\n * candidate body: `scalarAst / candidate`, which must be constant. Symbols align\n * by name, then by a dimension exactly one candidate symbol carries. Evaluated at\n * three points where variable i takes (1.7 + i)^p, p = 1, 1.3, 1.6. `null` when\n * the symbols do not align or the ratio is not constant.\n */\nfunction corpusPrefactor(ast: ExprNode, candidate: ExprNode): number | null {\n const astSyms = dimensionedSymbols(ast, new Map());\n const candSyms = dimensionedSymbols(candidate, new Map());\n if (astSyms.size !== candSyms.size) return null;\n const toCand = new Map<string, string>();\n const free = new Set(candSyms.keys());\n for (const s of astSyms.keys()) if (free.has(s)) (toCand.set(s, s), free.delete(s));\n for (const [s, d] of astSyms) {\n if (toCand.has(s)) continue;\n const hits = [...free].filter((c) => equals(candSyms.get(c)!, d));\n if (hits.length !== 1) return null;\n toCand.set(s, hits[0]!);\n free.delete(hits[0]!);\n }\n const names = [...candSyms.keys()].sort();\n const ratios = [1, 1.3, 1.6].map((p) => {\n const vals = Object.fromEntries(names.map((n, i) => [n, Math.pow(1.7 + i, p)]));\n const astVals = Object.fromEntries([...toCand].map(([s, c]) => [s, vals[c]!]));\n return evalExpr(ast, astVals) / evalExpr(candidate, vals);\n });\n const k = ratios[0]!;\n return Number.isFinite(k) && ratios.every((r) => Math.abs(r / k - 1) <= 1e-9) ? k : null;\n}\n\n/**\n * Compare a FITTED prefactor with the prefactor of each corpus relation the\n * candidate is algebraically equivalent to. `normalForm` matches up to a\n * constant, so an equivalent candidate can still carry the wrong constant: a\n * pendulum fitted on finite-amplitude data gives ĉ = 7.39, not 2π. Only a fully\n * quantitative canonical entry records a prefactor; for any other match the\n * note says the fitted value is not compared. `tolerance` is relative (the\n * holdout tolerance of the run).\n *\n * @internal\n */\nexport function corpusPrefactorNotes(\n result: CorpusComparisonResult,\n candidate: ExprNode,\n fitted: number,\n tolerance: number,\n): string[] {\n const c = fitted.toPrecision(4);\n return result.algebraicMatches.map((m) => {\n const entry = m.layer === 'canonical' ? CANONICAL_EQUATIONS.find((e) => e.id === m.id) : undefined;\n let k: number | null = null;\n // Fully quantitative entries carry their prefactor; others may take it from\n // the sourced table, applied to the entry's AST or, lacking one, its monomial.\n const tabled = entry && entry.epistemicStatus !== 'fully-quantitative' ? canonicalPrefactor(entry.id) : undefined;\n const body =\n entry?.epistemicStatus === 'fully-quantitative'\n ? entry.scalarAst\n : tabled === undefined\n ? undefined\n : (entry?.scalarAst ??\n (entry?.dimensional.monomial\n ? monomialToExpr(entry.dimensional.monomial, [entry.dimensional.target, ...entry.dimensional.governing])\n : undefined));\n if (body !== undefined) {\n try {\n const base = corpusPrefactor(body, candidate);\n k = base === null ? null : (tabled ?? 1) * base;\n } catch {\n k = null;\n }\n }\n if (k === null) return `${m.id} records no prefactor, so the fitted ĉ=${c} is not compared with it`;\n const rel = fitted / k - 1;\n if (Math.abs(rel) <= tolerance) {\n return `fitted ĉ=${c} agrees with ${m.id}'s prefactor ${k.toPrecision(4)} (within the holdout tolerance ${tolerance})`;\n }\n const pct = `${rel > 0 ? '+' : ''}${Math.round(rel * 100)}%`;\n return (\n `fitted ĉ=${c} contradicts ${m.id}'s prefactor ${k.toPrecision(4)} (${pct}): ` +\n \"the data may lie outside that relation's regime\"\n );\n });\n}\n\n/** Allowed automated novelty sentence. @internal */\nexport function corpusRelativeWording(result: CorpusComparisonResult): string {\n if (result.algebraicMatches.length > 0) {\n const ids = result.algebraicMatches.map((m) => m.id).join(', ');\n return `Algebraic equivalent found in corpus ${result.corpusId}@${result.corpusVersion}: ${ids}`;\n }\n return `No equivalent was found in corpus ${result.corpusId} version ${result.corpusVersion} under equivalence procedures E=normalForm. SCIENTIFIC NOVELTY NOT ESTABLISHED.`;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"corpus.js","sourceRoot":"","sources":["../../../src/composition/probe/corpus.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAEtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAe5E,MAAM,SAAS,GAAG,qBAAqB,CAAC;AAExC,sEAAsE;AACtE,MAAM,UAAU,eAAe,CAAC,IAAc,EAAE,aAAqB;IACnE,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IAC9B,MAAM,SAAS,GAAkB,EAAE,CAAC;IACpC,KAAK,MAAM,EAAE,IAAI,mBAAmB,EAAE,CAAC;QACrC,IAAI,EAAE,CAAC,SAAS,IAAI,UAAU,CAAC,EAAE,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE,CAAC;YACtD,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,KAA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K,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,uBAAuB,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAChH,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED,oDAAoD;AACpD,MAAM,UAAU,qBAAqB,CAAC,MAA8B;IAClE,IAAI,MAAM,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvC,MAAM,GAAG,GAAG,MAAM,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAChE,OAAO,wCAAwC,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,aAAa,KAAK,GAAG,EAAE,CAAC;IACnG,CAAC;IACD,OAAO,qCAAqC,MAAM,CAAC,QAAQ,YAAY,MAAM,CAAC,aAAa,iFAAiF,CAAC;AAC/K,CAAC","sourcesContent":["/**\n * In-repo corpus comparison: canonical scalarAst + normalForm.\n * Novelty wording is always corpus-relative.\n *\n * @module composition/probe/corpus\n */\n\nimport type { ExprNode } from '../../dimensional/ast-types.js';\nimport { CANONICAL_EQUATIONS } from '../../canonical/registry.js';\nimport { normalForm } from '../../canonical/normal-form.js';\nimport { BRIDGE_RHS_BY_ID } from '../../bridges/rhs-registry.js';\nimport { monomialToExpr } from './generator.js';\nimport { evalExpr } from '../expr-eval.js';\nimport { equals } from '../../dimensional/algebra.js';\nimport type { Dimension } from '../../dimensional/types.js';\nimport { canonicalPrefactor } from '../canonical-prefactors.js';\nimport { constantRatio, fixedPoint } from '../../canonical/fixed-points.js';\n\nexport interface CorpusMatch {\n readonly id: string;\n readonly layer: 'canonical' | 'bridge';\n}\n\nexport interface CorpusComparisonResult {\n readonly corpusId: string;\n readonly corpusVersion: string;\n readonly exactMatches: readonly CorpusMatch[];\n readonly algebraicMatches: readonly CorpusMatch[];\n readonly searchedAt: string;\n}\n\nconst CORPUS_ID = 'upt-l-layer+b-layer';\n\n/** Compare an expression to the in-repo L- and B-layers. @internal */\nexport function compareToCorpus(expr: ExprNode, corpusVersion: string): CorpusComparisonResult {\n const form = normalForm(expr);\n const algebraic: CorpusMatch[] = [];\n for (const ce of CANONICAL_EQUATIONS) {\n if (ce.scalarAst && normalForm(ce.scalarAst) === form) {\n algebraic.push({ id: ce.id, layer: 'canonical' });\n } else if (ce.dimensional?.monomial) {\n const mono = monomialToExpr(ce.dimensional.monomial, [\n ce.dimensional.target,\n ...ce.dimensional.governing,\n ]);\n if (normalForm(mono) === form) {\n algebraic.push({ id: ce.id, layer: 'canonical' });\n }\n }\n }\n for (const [id, rhs] of BRIDGE_RHS_BY_ID.entries()) {\n if (rhs && normalForm(rhs) === form) {\n algebraic.push({ id: `be-${id}`, layer: 'bridge' });\n }\n }\n return {\n corpusId: CORPUS_ID,\n corpusVersion,\n exactMatches: [],\n algebraicMatches: algebraic,\n searchedAt: new Date().toISOString(),\n };\n}\n\n/**\n * The symbols of an AST that carry a dimension, with that dimension. Numeric\n * literals and named numbers (`8pi`) are dimensionless and left out; so is a\n * dimensionless variable, which then makes the ratio vary and returns no prefactor.\n */\nfunction dimensionedSymbols(node: ExprNode, out: Map<string, Dimension>): Map<string, Dimension> {\n if (node.kind === 'symbol') {\n if (Object.values(node.dim).some((e) => e !== 0)) out.set(node.name, node.dim);\n return out;\n }\n for (const a of (node as { args?: readonly ExprNode[] }).args ?? []) dimensionedSymbols(a, out);\n return out;\n}\n\n/**\n * The corpus prefactor k of a fully quantitative canonical entry against a\n * candidate body: `scalarAst / candidate`, which must be constant. Symbols align\n * by name, then by a dimension exactly one candidate symbol carries. Evaluated at\n * three points where variable i takes (1.7 + i)^p, p = 1, 1.3, 1.6 (`fixedPoint`, base 1.7,\n * step 1), and the ratio is constant when its largest relative departure is at most 1e-9\n * (`constantRatio`). `null` when the symbols do not align or the ratio is not constant.\n */\nfunction corpusPrefactor(ast: ExprNode, candidate: ExprNode): number | null {\n const astSyms = dimensionedSymbols(ast, new Map());\n const candSyms = dimensionedSymbols(candidate, new Map());\n if (astSyms.size !== candSyms.size) return null;\n const toCand = new Map<string, string>();\n const free = new Set(candSyms.keys());\n for (const s of astSyms.keys()) if (free.has(s)) (toCand.set(s, s), free.delete(s));\n for (const [s, d] of astSyms) {\n if (toCand.has(s)) continue;\n const hits = [...free].filter((c) => equals(candSyms.get(c)!, d));\n if (hits.length !== 1) return null;\n toCand.set(s, hits[0]!);\n free.delete(hits[0]!);\n }\n const names = [...candSyms.keys()].sort();\n const ratios = [1, 1.3, 1.6].map((p) => {\n const vals = fixedPoint(names, p, { base: 1.7, step: 1 });\n const astVals = Object.fromEntries([...toCand].map(([s, c]) => [s, vals[c]!]));\n return evalExpr(ast, astVals) / evalExpr(candidate, vals);\n });\n const decided = constantRatio(ratios, 1e-9);\n return decided.constant ? decided.value : null;\n}\n\n/**\n * Compare a FITTED prefactor with the prefactor of each corpus relation the\n * candidate is algebraically equivalent to. `normalForm` matches up to a\n * constant, so an equivalent candidate can still carry the wrong constant: a\n * pendulum fitted on finite-amplitude data gives ĉ = 7.39, not 2π. Only a fully\n * quantitative canonical entry records a prefactor; for any other match the\n * note says the fitted value is not compared. `tolerance` is relative (the\n * holdout tolerance of the run) and is what decides agreement; when the fit\n * carries a standard error `stderr`, the note also states the difference in\n * σ beside that verdict, and decides nothing by it.\n *\n * @internal\n */\nexport function corpusPrefactorNotes(\n result: CorpusComparisonResult,\n candidate: ExprNode,\n fitted: number,\n tolerance: number,\n stderr?: number | null,\n): string[] {\n const c = fitted.toPrecision(4);\n const inSigma = (k: number): string => {\n if (stderr === undefined || stderr === null || !(stderr > 0)) return '';\n const z = (fitted - k) / stderr;\n return `; ${z >= 0 ? '+' : ''}${z.toFixed(1)}σ (σ_ĉ = ${Number(stderr.toPrecision(2))})`;\n };\n return result.algebraicMatches.map((m) => {\n const entry = m.layer === 'canonical' ? CANONICAL_EQUATIONS.find((e) => e.id === m.id) : undefined;\n let k: number | null = null;\n // Fully quantitative entries carry their prefactor; others may take it from\n // the sourced table, applied to the entry's AST or, lacking one, its monomial.\n const tabled = entry && entry.epistemicStatus !== 'fully-quantitative' ? canonicalPrefactor(entry.id) : undefined;\n const body =\n entry?.epistemicStatus === 'fully-quantitative'\n ? entry.scalarAst\n : tabled === undefined\n ? undefined\n : (entry?.scalarAst ??\n (entry?.dimensional.monomial\n ? monomialToExpr(entry.dimensional.monomial, [entry.dimensional.target, ...entry.dimensional.governing])\n : undefined));\n if (body !== undefined) {\n try {\n const base = corpusPrefactor(body, candidate);\n k = base === null ? null : (tabled ?? 1) * base;\n } catch {\n k = null;\n }\n }\n if (k === null) return `${m.id} records no prefactor, so the fitted ĉ=${c} is not compared with it`;\n const rel = fitted / k - 1;\n if (Math.abs(rel) <= tolerance) {\n return `fitted ĉ=${c} agrees with ${m.id}'s prefactor ${k.toPrecision(4)} (within the holdout tolerance ${tolerance}${inSigma(k)})`;\n }\n const pct = `${rel > 0 ? '+' : ''}${Math.round(rel * 100)}%`;\n const sigma = inSigma(k);\n return (\n `fitted ĉ=${c} contradicts ${m.id}'s prefactor ${k.toPrecision(4)} (${pct}): ` +\n `the data may lie outside that relation's regime${sigma === '' ? '' : `; the difference is ${sigma.slice(2)}`}`\n );\n });\n}\n\n/** Allowed automated novelty sentence. @internal */\nexport function corpusRelativeWording(result: CorpusComparisonResult): string {\n if (result.algebraicMatches.length > 0) {\n const ids = result.algebraicMatches.map((m) => m.id).join(', ');\n return `Algebraic equivalent found in corpus ${result.corpusId}@${result.corpusVersion}: ${ids}`;\n }\n return `No equivalent was found in corpus ${result.corpusId} version ${result.corpusVersion} under equivalence procedures E=normalForm. SCIENTIFIC NOVELTY NOT ESTABLISHED.`;\n}\n"]}
|
|
@@ -5,9 +5,26 @@
|
|
|
5
5
|
* that tree is Product A's confrontation ledger and must stay cycle-free
|
|
6
6
|
* from probe.
|
|
7
7
|
*
|
|
8
|
+
* A cell is a finite number or a non-empty string in the strict decimal
|
|
9
|
+
* grammar (`1`, `-0.5`, `.5`, `2.`, `1e-3`). Nothing is coerced: an empty
|
|
10
|
+
* cell, `null`, `true`, `false`, a list and `"0x10"` are refused by column
|
|
11
|
+
* and row, with {@link DatasetError}. `Number(v)` once read all of those as
|
|
12
|
+
* 0, 1 or 16, which also defeated the missing-observation guard of the
|
|
13
|
+
* declared-limit check (a missing observation scored as 0).
|
|
14
|
+
*
|
|
8
15
|
* @internal
|
|
9
16
|
*/
|
|
10
17
|
import type { DatasetRole, ObservationRow, ProbeDataset } from './types.js';
|
|
18
|
+
/** A dataset file or object that is not a dataset: the message names the row and the column. @internal */
|
|
19
|
+
export declare class DatasetError extends Error {
|
|
20
|
+
constructor(message: string);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A cell as a number: a finite number, or a non-empty string in the strict
|
|
24
|
+
* decimal grammar. Anything else is refused at `where` (the dataset, row and
|
|
25
|
+
* column). @internal
|
|
26
|
+
*/
|
|
27
|
+
export declare function readDatasetNumber(v: unknown, where: string): number;
|
|
11
28
|
/** Build an in-memory dataset. @internal */
|
|
12
29
|
export declare function datasetFromRows(rows: readonly ObservationRow[], observable: string, role: DatasetRole, id?: string, sigma?: number): ProbeDataset;
|
|
13
30
|
/** Coerce unknown JSON into a ProbeDataset. @internal */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataset.d.ts","sourceRoot":"","sources":["../../../src/composition/probe/dataset.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"dataset.d.ts","sourceRoot":"","sources":["../../../src/composition/probe/dataset.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG5E,0GAA0G;AAC1G,qBAAa,YAAa,SAAQ,KAAK;IACrC,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AAcD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAYnE;AAED,4CAA4C;AAC5C,wBAAgB,eAAe,CAC7B,IAAI,EAAE,SAAS,cAAc,EAAE,EAC/B,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,WAAW,EACjB,EAAE,SAAW,EACb,KAAK,CAAC,EAAE,MAAM,GACb,YAAY,CAEd;AAED,yDAAyD;AACzD,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,WAAW,GAAG,YAAY,CA6CxG;AAED,wDAAwD;AACxD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,WAAW,GAAG,YAAY,CAG1F;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,WAAW,CAAC,EAAE,YAAY,CAAC;IACpC,QAAQ,CAAC,OAAO,CAAC,EAAE,YAAY,CAAC;CACjC;AAED,sDAAsD;AACtD,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,CA0BzE;AAiCD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,WAAW,EACjB,EAAE,SAAO,GACR,YAAY,CAYd;AAED,qEAAqE;AACrE,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,GACjB;IAAE,WAAW,EAAE,YAAY,CAAC;IAAC,OAAO,EAAE,YAAY,CAAA;CAAE,CAoBtD"}
|
|
@@ -5,10 +5,60 @@
|
|
|
5
5
|
* that tree is Product A's confrontation ledger and must stay cycle-free
|
|
6
6
|
* from probe.
|
|
7
7
|
*
|
|
8
|
+
* A cell is a finite number or a non-empty string in the strict decimal
|
|
9
|
+
* grammar (`1`, `-0.5`, `.5`, `2.`, `1e-3`). Nothing is coerced: an empty
|
|
10
|
+
* cell, `null`, `true`, `false`, a list and `"0x10"` are refused by column
|
|
11
|
+
* and row, with {@link DatasetError}. `Number(v)` once read all of those as
|
|
12
|
+
* 0, 1 or 16, which also defeated the missing-observation guard of the
|
|
13
|
+
* declared-limit check (a missing observation scored as 0).
|
|
14
|
+
*
|
|
8
15
|
* @internal
|
|
9
16
|
*/
|
|
10
17
|
import { readFileSync } from 'node:fs';
|
|
18
|
+
import { readJsonFile } from '../../core/data-file.js';
|
|
11
19
|
import { SCHEMA_VERSION } from './types.js';
|
|
20
|
+
/** A dataset file or object that is not a dataset: the message names the row and the column. @internal */
|
|
21
|
+
export class DatasetError extends Error {
|
|
22
|
+
constructor(message) {
|
|
23
|
+
super(message);
|
|
24
|
+
this.name = 'DatasetError';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/** The strict decimal grammar a string cell must match: sign, digits with an optional fraction, an optional exponent. */
|
|
28
|
+
const DECIMAL = /^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/;
|
|
29
|
+
/** What a JSON value is, in the words a file author would use. */
|
|
30
|
+
function kindOf(v) {
|
|
31
|
+
if (v === null)
|
|
32
|
+
return 'null';
|
|
33
|
+
if (Array.isArray(v))
|
|
34
|
+
return 'a list';
|
|
35
|
+
if (typeof v === 'boolean')
|
|
36
|
+
return String(v);
|
|
37
|
+
if (typeof v === 'string')
|
|
38
|
+
return `'${v}'`;
|
|
39
|
+
return typeof v === 'object' ? 'an object' : typeof v;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A cell as a number: a finite number, or a non-empty string in the strict
|
|
43
|
+
* decimal grammar. Anything else is refused at `where` (the dataset, row and
|
|
44
|
+
* column). @internal
|
|
45
|
+
*/
|
|
46
|
+
export function readDatasetNumber(v, where) {
|
|
47
|
+
if (typeof v === 'number') {
|
|
48
|
+
if (!Number.isFinite(v))
|
|
49
|
+
throw new DatasetError(`${where}: ${v} is not a finite number`);
|
|
50
|
+
return v;
|
|
51
|
+
}
|
|
52
|
+
if (typeof v === 'string') {
|
|
53
|
+
if (v.trim() === '')
|
|
54
|
+
throw new DatasetError(`${where}: an empty cell is not a number`);
|
|
55
|
+
const n = DECIMAL.test(v.trim()) ? Number(v.trim()) : NaN;
|
|
56
|
+
if (!Number.isFinite(n))
|
|
57
|
+
throw new DatasetError(`${where}: ${kindOf(v)} is not a finite decimal number`);
|
|
58
|
+
return n;
|
|
59
|
+
}
|
|
60
|
+
throw new DatasetError(`${where}: ${kindOf(v)} is not a number`);
|
|
61
|
+
}
|
|
12
62
|
/** Build an in-memory dataset. @internal */
|
|
13
63
|
export function datasetFromRows(rows, observable, role, id = 'inline', sigma) {
|
|
14
64
|
return { id, role, rows, observable, ...(sigma !== undefined ? { sigma } : {}), schemaVersion: SCHEMA_VERSION };
|
|
@@ -16,33 +66,29 @@ export function datasetFromRows(rows, observable, role, id = 'inline', sigma) {
|
|
|
16
66
|
/** Coerce unknown JSON into a ProbeDataset. @internal */
|
|
17
67
|
export function asDatasetSafe(raw, fallbackId, fallbackRole) {
|
|
18
68
|
if (!raw || typeof raw !== 'object') {
|
|
19
|
-
throw new
|
|
69
|
+
throw new DatasetError(`dataset JSON is not an object (${fallbackId})`);
|
|
20
70
|
}
|
|
21
71
|
const obj = raw;
|
|
22
72
|
if (!Array.isArray(obj.rows)) {
|
|
23
|
-
throw new
|
|
73
|
+
throw new DatasetError(`dataset at ${fallbackId} is missing rows[]`);
|
|
24
74
|
}
|
|
25
75
|
if (typeof obj.observable !== 'string' || obj.observable.length === 0) {
|
|
26
|
-
throw new
|
|
76
|
+
throw new DatasetError(`dataset at ${fallbackId} is missing observable`);
|
|
27
77
|
}
|
|
28
78
|
const role = (typeof obj.role === 'string' ? obj.role : fallbackRole);
|
|
29
79
|
if (role !== 'exploratory-fit' &&
|
|
30
80
|
role !== 'validation-holdout' &&
|
|
31
81
|
role !== 'external-replication' &&
|
|
32
82
|
role !== 'falsification-only') {
|
|
33
|
-
throw new
|
|
83
|
+
throw new DatasetError(`dataset at ${fallbackId} has invalid role '${String(obj.role)}'`);
|
|
34
84
|
}
|
|
35
85
|
const rows = obj.rows.map((row, i) => {
|
|
36
86
|
if (!row || typeof row !== 'object' || Array.isArray(row)) {
|
|
37
|
-
throw new
|
|
87
|
+
throw new DatasetError(`dataset ${fallbackId} row ${i} is not an object`);
|
|
38
88
|
}
|
|
39
89
|
const out = {};
|
|
40
90
|
for (const [k, v] of Object.entries(row)) {
|
|
41
|
-
|
|
42
|
-
if (!Number.isFinite(n)) {
|
|
43
|
-
throw new Error(`dataset ${fallbackId} row ${i} column ${k}: not a finite number`);
|
|
44
|
-
}
|
|
45
|
-
out[k] = n;
|
|
91
|
+
out[k] = readDatasetNumber(v, `dataset ${fallbackId} row ${i} column ${k}`);
|
|
46
92
|
}
|
|
47
93
|
return out;
|
|
48
94
|
});
|
|
@@ -57,12 +103,12 @@ export function asDatasetSafe(raw, fallbackId, fallbackRole) {
|
|
|
57
103
|
}
|
|
58
104
|
/** Load a single ProbeDataset JSON object. @internal */
|
|
59
105
|
export function loadDatasetFromJson(path, fallbackRole) {
|
|
60
|
-
const raw =
|
|
106
|
+
const raw = readJsonFile(path);
|
|
61
107
|
return asDatasetSafe(raw, path, fallbackRole);
|
|
62
108
|
}
|
|
63
109
|
/** Load `{ exploratory, holdout }` JSON. @internal */
|
|
64
110
|
export function loadSplitDatasetsFromJson(path) {
|
|
65
|
-
const raw =
|
|
111
|
+
const raw = readJsonFile(path);
|
|
66
112
|
if (raw.exploratory || raw.holdout) {
|
|
67
113
|
return {
|
|
68
114
|
exploratory: raw.exploratory
|
|
@@ -78,7 +124,35 @@ export function loadSplitDatasetsFromJson(path) {
|
|
|
78
124
|
exploratory: asDatasetSafe({ ...raw.observations, role: 'exploratory-fit' }, `${path}#observations`, 'exploratory-fit'),
|
|
79
125
|
};
|
|
80
126
|
}
|
|
81
|
-
throw new
|
|
127
|
+
throw new DatasetError(`JSON at ${path} needs exploratory/holdout or observations`);
|
|
128
|
+
}
|
|
129
|
+
/** The header and the data lines of a CSV file; the file needs both. */
|
|
130
|
+
function csvLines(path) {
|
|
131
|
+
const text = readFileSync(path, 'utf8').trim();
|
|
132
|
+
const lines = text.split(/\r?\n/).filter((l) => l.length > 0);
|
|
133
|
+
if (lines.length < 2) {
|
|
134
|
+
throw new DatasetError(`CSV dataset at ${path} needs a header and at least one row`);
|
|
135
|
+
}
|
|
136
|
+
const headers = lines[0].split(',').map((h) => h.trim());
|
|
137
|
+
return { headers, lines };
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* One CSV data line as a row of numbers. A line with fewer cells than the
|
|
141
|
+
* header is refused by the first column it lacks; `skip` names the header
|
|
142
|
+
* column (if any) that is not a number column. `line` is the 1-based line
|
|
143
|
+
* number of the file, so a message points at the file.
|
|
144
|
+
*/
|
|
145
|
+
function csvRow(cells, headers, line, path, skip) {
|
|
146
|
+
if (cells.length < headers.length) {
|
|
147
|
+
throw new DatasetError(`CSV ${path} row ${line} has ${cells.length} cell(s); the header has ${headers.length} (column ${headers[cells.length]} is missing)`);
|
|
148
|
+
}
|
|
149
|
+
const row = {};
|
|
150
|
+
for (let c = 0; c < headers.length; c++) {
|
|
151
|
+
if (c === skip)
|
|
152
|
+
continue;
|
|
153
|
+
row[headers[c]] = readDatasetNumber(cells[c], `CSV ${path} row ${line} column ${headers[c]}`);
|
|
154
|
+
}
|
|
155
|
+
return row;
|
|
82
156
|
}
|
|
83
157
|
/**
|
|
84
158
|
* Minimal CSV: first row headers, remaining rows numeric values.
|
|
@@ -88,66 +162,37 @@ export function loadSplitDatasetsFromJson(path) {
|
|
|
88
162
|
* @internal
|
|
89
163
|
*/
|
|
90
164
|
export function loadDatasetFromCsv(path, observable, role, id = path) {
|
|
91
|
-
const
|
|
92
|
-
const
|
|
93
|
-
if (lines.length < 2) {
|
|
94
|
-
throw new Error(`CSV dataset at ${path} needs a header and at least one row`);
|
|
95
|
-
}
|
|
96
|
-
const headers = lines[0].split(',').map((h) => h.trim());
|
|
165
|
+
const { headers, lines } = csvLines(path);
|
|
166
|
+
const splitIdx = headers.indexOf('split');
|
|
97
167
|
const rows = [];
|
|
98
168
|
for (let i = 1; i < lines.length; i++) {
|
|
99
169
|
const cells = lines[i].split(',').map((c) => c.trim());
|
|
100
|
-
|
|
101
|
-
for (let c = 0; c < headers.length; c++) {
|
|
102
|
-
const h = headers[c];
|
|
103
|
-
if (h === 'split')
|
|
104
|
-
continue;
|
|
105
|
-
const n = Number(cells[c] ?? '');
|
|
106
|
-
if (!Number.isFinite(n)) {
|
|
107
|
-
throw new Error(`CSV ${path} row ${i + 1} column ${h}: not a finite number`);
|
|
108
|
-
}
|
|
109
|
-
row[h] = n;
|
|
110
|
-
}
|
|
111
|
-
rows.push(row);
|
|
170
|
+
rows.push(csvRow(cells, headers, i + 1, path, splitIdx));
|
|
112
171
|
}
|
|
113
172
|
if (!(observable in (rows[0] ?? {}))) {
|
|
114
|
-
throw new
|
|
173
|
+
throw new DatasetError(`CSV ${path} is missing observable column '${observable}'`);
|
|
115
174
|
}
|
|
116
175
|
return datasetFromRows(rows, observable, role, id);
|
|
117
176
|
}
|
|
118
177
|
/** Partition a mixed-split CSV (uses a `split` column). @internal */
|
|
119
178
|
export function loadSplitCsv(path, observable) {
|
|
120
|
-
const
|
|
121
|
-
const lines = text.split(/\r?\n/).filter((l) => l.length > 0);
|
|
122
|
-
if (lines.length < 2) {
|
|
123
|
-
throw new Error(`CSV dataset at ${path} needs a header and at least one row`);
|
|
124
|
-
}
|
|
125
|
-
const headers = lines[0].split(',').map((h) => h.trim());
|
|
179
|
+
const { headers, lines } = csvLines(path);
|
|
126
180
|
const splitIdx = headers.indexOf('split');
|
|
127
181
|
if (splitIdx < 0) {
|
|
128
|
-
throw new
|
|
182
|
+
throw new DatasetError(`CSV ${path} has no split column`);
|
|
129
183
|
}
|
|
130
184
|
const exploratoryRows = [];
|
|
131
185
|
const holdoutRows = [];
|
|
132
186
|
for (let i = 1; i < lines.length; i++) {
|
|
133
187
|
const cells = lines[i].split(',').map((c) => c.trim());
|
|
134
|
-
const row =
|
|
135
|
-
for (let c = 0; c < headers.length; c++) {
|
|
136
|
-
if (c === splitIdx)
|
|
137
|
-
continue;
|
|
138
|
-
const n = Number(cells[c] ?? '');
|
|
139
|
-
if (!Number.isFinite(n)) {
|
|
140
|
-
throw new Error(`CSV ${path} row ${i + 1} column ${headers[c]}: not a finite number`);
|
|
141
|
-
}
|
|
142
|
-
row[headers[c]] = n;
|
|
143
|
-
}
|
|
188
|
+
const row = csvRow(cells, headers, i + 1, path, splitIdx);
|
|
144
189
|
const split = cells[splitIdx];
|
|
145
190
|
if (split === 'holdout' || split === 'blind')
|
|
146
191
|
holdoutRows.push(row);
|
|
147
192
|
else if (split === 'exploratory')
|
|
148
193
|
exploratoryRows.push(row);
|
|
149
194
|
else
|
|
150
|
-
throw new
|
|
195
|
+
throw new DatasetError(`CSV ${path} row ${i + 1} has invalid split '${split}'`);
|
|
151
196
|
}
|
|
152
197
|
return {
|
|
153
198
|
exploratory: datasetFromRows(exploratoryRows, observable, 'exploratory-fit', `${path}#exploratory`),
|