plurimath 0.11.17 → 0.11.18

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.
Files changed (189) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/dependent-tests.yml +2 -2
  3. data/.github/workflows/docs.yml +26 -0
  4. data/.github/workflows/gum-reference.yml +48 -0
  5. data/.github/workflows/performance-ci-legs.yml +54 -0
  6. data/.github/workflows/performance.yml +99 -0
  7. data/.github/workflows/roundtrip-cases.yml +33 -0
  8. data/.rubocop_todo.yml +0 -138
  9. data/Gemfile +13 -0
  10. data/Rakefile +2 -0
  11. data/docs/asciimath.adoc +578 -0
  12. data/docs/core-model-contract.adoc +748 -0
  13. data/docs/gum-evaluation.adoc +368 -0
  14. data/docs/latex.adoc +335 -0
  15. data/docs/mathml.adoc +638 -0
  16. data/docs/native-evaluation-request.md +28 -0
  17. data/docs/numeric-request.md +19 -0
  18. data/docs/omml.adoc +589 -0
  19. data/docs/performance-contract.adoc +279 -0
  20. data/docs/pma.adoc +949 -0
  21. data/docs/quantity-request.md +19 -0
  22. data/docs/uncertainty-asciimath-tree.md +2 -3
  23. data/docs/uncertainty.adoc +401 -425
  24. data/docs/unicodemath.adoc +453 -0
  25. data/docs/unitsml.adoc +414 -0
  26. data/lib/plurimath/asciimath/constants.rb +0 -98
  27. data/lib/plurimath/asciimath/mapper/rules.rb +1400 -0
  28. data/lib/plurimath/asciimath/mapper.rb +148 -0
  29. data/lib/plurimath/asciimath/parse.rb +23 -16
  30. data/lib/plurimath/asciimath/parser.rb +25 -11
  31. data/lib/plurimath/asciimath/slice_adapter.rb +1 -1
  32. data/lib/plurimath/asciimath.rb +1 -1
  33. data/lib/plurimath/catalog.rb +4 -5
  34. data/lib/plurimath/cli/convert.rb +3 -2
  35. data/lib/plurimath/cli.rb +2 -1
  36. data/lib/plurimath/configuration.rb +3 -0
  37. data/lib/plurimath/evaluation_request/quantity.rb +254 -0
  38. data/lib/plurimath/evaluation_request.rb +160 -0
  39. data/lib/plurimath/latex/constants.rb +0 -84
  40. data/lib/plurimath/latex/mapper.rb +418 -0
  41. data/lib/plurimath/latex/parse.rb +28 -288
  42. data/lib/plurimath/latex/parser.rb +49 -4
  43. data/lib/plurimath/latex.rb +1 -1
  44. data/lib/plurimath/math/core.rb +266 -1
  45. data/lib/plurimath/math/evaluation/accuracy.rb +62 -0
  46. data/lib/plurimath/math/evaluation/calibration.rb +85 -0
  47. data/lib/plurimath/math/evaluation/compiled_polynomial.rb +99 -0
  48. data/lib/plurimath/math/evaluation/compiled_rational.rb +131 -0
  49. data/lib/plurimath/math/evaluation/conformity.rb +133 -0
  50. data/lib/plurimath/math/evaluation/correlated_normal_sampler.rb +74 -0
  51. data/lib/plurimath/math/evaluation/covariance.rb +173 -0
  52. data/lib/plurimath/math/evaluation/distribution_sampler.rb +126 -0
  53. data/lib/plurimath/math/evaluation/evaluator.rb +236 -22
  54. data/lib/plurimath/math/evaluation/grouped_statistics.rb +56 -0
  55. data/lib/plurimath/math/evaluation/gum.rb +410 -0
  56. data/lib/plurimath/math/evaluation/implicit_model.rb +66 -0
  57. data/lib/plurimath/math/evaluation/monte_carlo.rb +198 -0
  58. data/lib/plurimath/math/evaluation/quantity_evaluator.rb +127 -0
  59. data/lib/plurimath/math/evaluation/result.rb +45 -0
  60. data/lib/plurimath/math/evaluation/statistics.rb +102 -0
  61. data/lib/plurimath/math/evaluation/taylor.rb +162 -0
  62. data/lib/plurimath/math/evaluation/wichmann_hill.rb +40 -0
  63. data/lib/plurimath/math/evaluation.rb +22 -0
  64. data/lib/plurimath/math/formula/mrow.rb +6 -1
  65. data/lib/plurimath/math/formula.rb +22 -4
  66. data/lib/plurimath/math/function/abs.rb +3 -1
  67. data/lib/plurimath/math/function/arccos.rb +1 -1
  68. data/lib/plurimath/math/function/arcsin.rb +1 -1
  69. data/lib/plurimath/math/function/arctan.rb +1 -1
  70. data/lib/plurimath/math/function/bar.rb +2 -1
  71. data/lib/plurimath/math/function/base.rb +2 -1
  72. data/lib/plurimath/math/function/binary_function.rb +1 -1
  73. data/lib/plurimath/math/function/ceil.rb +3 -1
  74. data/lib/plurimath/math/function/color.rb +2 -1
  75. data/lib/plurimath/math/function/cos.rb +1 -1
  76. data/lib/plurimath/math/function/cosh.rb +1 -1
  77. data/lib/plurimath/math/function/cot.rb +1 -1
  78. data/lib/plurimath/math/function/coth.rb +1 -1
  79. data/lib/plurimath/math/function/csc.rb +1 -1
  80. data/lib/plurimath/math/function/csch.rb +1 -1
  81. data/lib/plurimath/math/function/ddot.rb +2 -1
  82. data/lib/plurimath/math/function/dot.rb +2 -1
  83. data/lib/plurimath/math/function/exp.rb +1 -1
  84. data/lib/plurimath/math/function/fenced.rb +5 -3
  85. data/lib/plurimath/math/function/floor.rb +3 -1
  86. data/lib/plurimath/math/function/font_style/bold.rb +1 -1
  87. data/lib/plurimath/math/function/font_style/double_struck.rb +1 -1
  88. data/lib/plurimath/math/function/font_style/fraktur.rb +1 -1
  89. data/lib/plurimath/math/function/font_style/italic.rb +1 -1
  90. data/lib/plurimath/math/function/font_style/monospace.rb +1 -1
  91. data/lib/plurimath/math/function/font_style/normal.rb +22 -1
  92. data/lib/plurimath/math/function/font_style/sans-serif.rb +1 -1
  93. data/lib/plurimath/math/function/font_style/script.rb +1 -1
  94. data/lib/plurimath/math/function/frac.rb +2 -1
  95. data/lib/plurimath/math/function/hat.rb +2 -1
  96. data/lib/plurimath/math/function/int.rb +3 -2
  97. data/lib/plurimath/math/function/lg.rb +1 -1
  98. data/lib/plurimath/math/function/linebreak.rb +2 -1
  99. data/lib/plurimath/math/function/ln.rb +1 -1
  100. data/lib/plurimath/math/function/log.rb +4 -1
  101. data/lib/plurimath/math/function/longdiv.rb +3 -0
  102. data/lib/plurimath/math/function/mpadded.rb +2 -1
  103. data/lib/plurimath/math/function/msgroup.rb +3 -0
  104. data/lib/plurimath/math/function/multiscript.rb +4 -0
  105. data/lib/plurimath/math/function/nary.rb +9 -3
  106. data/lib/plurimath/math/function/norm.rb +3 -1
  107. data/lib/plurimath/math/function/obrace.rb +2 -1
  108. data/lib/plurimath/math/function/oint.rb +3 -2
  109. data/lib/plurimath/math/function/overleftrightarrow.rb +2 -1
  110. data/lib/plurimath/math/function/overset.rb +2 -1
  111. data/lib/plurimath/math/function/power.rb +1 -1
  112. data/lib/plurimath/math/function/power_base.rb +1 -1
  113. data/lib/plurimath/math/function/prod.rb +3 -2
  114. data/lib/plurimath/math/function/sec.rb +1 -1
  115. data/lib/plurimath/math/function/sech.rb +1 -1
  116. data/lib/plurimath/math/function/semantics.rb +35 -0
  117. data/lib/plurimath/math/function/sin.rb +1 -1
  118. data/lib/plurimath/math/function/sinh.rb +1 -1
  119. data/lib/plurimath/math/function/sqrt.rb +3 -2
  120. data/lib/plurimath/math/function/sum.rb +3 -2
  121. data/lib/plurimath/math/function/table/align.rb +1 -1
  122. data/lib/plurimath/math/function/table/bmatrix.rb +1 -1
  123. data/lib/plurimath/math/function/table/cases.rb +4 -0
  124. data/lib/plurimath/math/function/table/multline.rb +1 -1
  125. data/lib/plurimath/math/function/table/pmatrix.rb +1 -1
  126. data/lib/plurimath/math/function/table/split.rb +1 -1
  127. data/lib/plurimath/math/function/table/vmatrix.rb +1 -1
  128. data/lib/plurimath/math/function/table.rb +19 -2
  129. data/lib/plurimath/math/function/tan.rb +1 -1
  130. data/lib/plurimath/math/function/tanh.rb +1 -1
  131. data/lib/plurimath/math/function/td.rb +4 -0
  132. data/lib/plurimath/math/function/ternary_function.rb +2 -2
  133. data/lib/plurimath/math/function/text.rb +3 -0
  134. data/lib/plurimath/math/function/tilde.rb +2 -1
  135. data/lib/plurimath/math/function/tr.rb +3 -0
  136. data/lib/plurimath/math/function/ubrace.rb +2 -1
  137. data/lib/plurimath/math/function/ul.rb +2 -1
  138. data/lib/plurimath/math/function/unary_function.rb +1 -1
  139. data/lib/plurimath/math/function/uncertainty.rb +26 -11
  140. data/lib/plurimath/math/function/underset.rb +2 -1
  141. data/lib/plurimath/math/function/unitsml.rb +18 -6
  142. data/lib/plurimath/math/function/vec.rb +2 -1
  143. data/lib/plurimath/math/number.rb +30 -12
  144. data/lib/plurimath/math/symbol_index.rb +10254 -0
  145. data/lib/plurimath/math/symbol_table.rb +89 -0
  146. data/lib/plurimath/math/symbols/paren.rb +7 -0
  147. data/lib/plurimath/math/symbols/symbol.rb +30 -3
  148. data/lib/plurimath/math/symbols.rb +81 -5
  149. data/lib/plurimath/math.rb +8 -0
  150. data/lib/plurimath/mathml/parser.rb +2 -0
  151. data/lib/plurimath/mathml/translator.rb +17 -3
  152. data/lib/plurimath/native_kernel.rb +64 -0
  153. data/lib/plurimath/omml/parser.rb +1 -0
  154. data/lib/plurimath/omml/translator.rb +2 -1
  155. data/lib/plurimath/pma.rb +19 -0
  156. data/lib/plurimath/unicode_math/constants.rb +0 -258
  157. data/lib/plurimath/unicode_math/mapper/capture_order.rb +142 -0
  158. data/lib/plurimath/unicode_math/mapper/rules.rb +4086 -0
  159. data/lib/plurimath/unicode_math/mapper.rb +146 -0
  160. data/lib/plurimath/unicode_math/parse.rb +54 -294
  161. data/lib/plurimath/unicode_math/parser.rb +71 -2
  162. data/lib/plurimath/unicode_math.rb +1 -2
  163. data/lib/plurimath/unitsml.rb +0 -1
  164. data/lib/plurimath/utility.rb +34 -12
  165. data/lib/plurimath/version.rb +1 -1
  166. data/lib/plurimath.rb +42 -3
  167. data/plurimath.gemspec +3 -1
  168. data/scripts/check_gum_references.rb +69 -0
  169. data/scripts/check_suite_budget.rb +329 -0
  170. data/scripts/docs/asciimath_tables.rb +363 -0
  171. data/scripts/docs/core_inventory.rb +432 -0
  172. data/scripts/docs/format_specs.rb +672 -0
  173. data/scripts/generate_symbol_index.rb +118 -0
  174. data/scripts/measure_require.rb +362 -0
  175. data/scripts/replay_asciimath_corpus.rb +7 -7
  176. data/scripts/replay_stage_roundtrips.rb +242 -0
  177. data/scripts/require_baseline.json +34 -0
  178. data/scripts/roundtrip_cases.rb +462 -0
  179. metadata +97 -16
  180. data/lib/plurimath/asciimath/transform.rb +0 -1395
  181. data/lib/plurimath/latex/transform.rb +0 -1006
  182. data/lib/plurimath/unicode_math/parsing_rules/absence_rules.rb +0 -150
  183. data/lib/plurimath/unicode_math/parsing_rules/common_rules.rb +0 -136
  184. data/lib/plurimath/unicode_math/parsing_rules/constants_rules.rb +0 -136
  185. data/lib/plurimath/unicode_math/parsing_rules/helper.rb +0 -13
  186. data/lib/plurimath/unicode_math/parsing_rules/masked.rb +0 -84
  187. data/lib/plurimath/unicode_math/parsing_rules/sub_sup.rb +0 -281
  188. data/lib/plurimath/unicode_math/parsing_rules.rb +0 -14
  189. data/lib/plurimath/unicode_math/transform.rb +0 -4058
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 97890a7dadd0792e3a8a38fc4e559602b1b9fe7e08a66d9ede44dc9303cee721
4
- data.tar.gz: a46581dd8505a2913928b7af5bddb2ab0404e0ac37b056b4eb3a77fdd797fc7d
3
+ metadata.gz: 143a8be3e6add3dfe3dd28136185de3ebb80ad9f076e254f3f97448421f31833
4
+ data.tar.gz: 39544e67f73713aa341e7b122e5f036c47f0b44f799e67c9cfed4490b966f82f
5
5
  SHA512:
6
- metadata.gz: cc998579be0c5864a3c7a8f47c4943c52c9fee3b2b12042fe372ac3691bfb4925b871300fab921018efcd3d21b741c0e03bdd58b8fe954dcfe0a5e2fb6c0c387
7
- data.tar.gz: c7bf9fc1b3d8f6455425e08add1830557f230b83309ae45a6d6038cbafd8feb62b52a27fceb43f85ab4225f9581795b356ce317219692505c3fca7bade5b0ecb
6
+ metadata.gz: 8a46a7218eea481a64a002fba75f2bda5a51450120a2b924647d152bac9933374bddeeef4d07a33b7aa335c8949f16d33b1812c758aebfbf7d05b8bf1b694cc6
7
+ data.tar.gz: da2ff148f8c967ef9a2fe30214e5a2cef28b268f1ed4d4c9db99109846d18d80ad8b3cda4b1458a7f9a7ce8f70844fa9671f54caa8e5287e211107460f527ffa
@@ -14,11 +14,11 @@ jobs:
14
14
  uses: metanorma/ci/.github/workflows/dependent-rake.yml@main
15
15
  with:
16
16
  command: bundle exec rspec
17
- # Remove the source bootstrap once the amath runtime dependency in #512 is available.
17
+ # amath's typed model is unreleased (0.2.0); keep this commit in step with the Gemfile.
18
18
  after-setup-ruby: |
19
19
  set -euo pipefail
20
20
  git init ../amath
21
- git -C ../amath fetch --depth 1 https://github.com/plurimath/amath.git b67f924477ce129e85926eda5973d771c007dfec
21
+ git -C ../amath fetch --depth 1 https://github.com/plurimath/amath.git 667b517bb81276bf920f6f9fea940ae342d8c9e3
22
22
  git -C ../amath checkout --detach FETCH_HEAD
23
23
  printf '\ngem "amath", path: "../amath"\n' >> Gemfile
24
24
  repos-json-file: .github/workflows/dependent-repos-ruby.json
@@ -0,0 +1,26 @@
1
+ name: docs
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ jobs:
12
+ format-specs:
13
+ runs-on: ubuntu-22.04
14
+ timeout-minutes: 20
15
+ steps:
16
+ - uses: actions/checkout@v5
17
+ - name: Check out the shared testsuite
18
+ run: git submodule update --init submodules/plurimath-testsuite
19
+ - uses: ruby/setup-ruby@v1
20
+ with:
21
+ ruby-version: "4.0.1"
22
+ bundler-cache: true
23
+ - name: Check the generated regions of the format pages
24
+ run: bundle exec ruby scripts/docs/format_specs.rb --check
25
+ - name: Check the generated regions of the AsciiMath specification
26
+ run: bundle exec ruby scripts/docs/asciimath_tables.rb --amath "$(bundle info amath --path)" --check
@@ -0,0 +1,48 @@
1
+ name: GUM mathematical references
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ concurrency:
12
+ group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
13
+ cancel-in-progress: true
14
+
15
+ jobs:
16
+ h1-adaptive-mcm:
17
+ runs-on: ubuntu-22.04
18
+ timeout-minutes: 45
19
+ steps:
20
+ - uses: actions/checkout@v5
21
+ - uses: ruby/setup-ruby@v1
22
+ with:
23
+ ruby-version: "4.0.1"
24
+ bundler-cache: true
25
+ - name: Check both actual H.1 PDF conventions with adaptive MCM
26
+ run: >-
27
+ bundle exec ruby scripts/check_gum_references.rb
28
+ --output "$RUNNER_TEMP/gum-reference.json"
29
+ --significant-digits 2 --max-samples 2000000
30
+ spec/fixtures/evaluation/gum_h1_mcm.json
31
+ - name: Check linear, correlated quadratic, rational mass and bromine profiles
32
+ run: >-
33
+ bundle exec ruby scripts/check_gum_references.rb
34
+ --output "$RUNNER_TEMP/gum-profiles-reference.json"
35
+ --significant-digits 2 --max-samples 8000000
36
+ spec/fixtures/evaluation/gum_mcm_profiles.json
37
+ - uses: actions/upload-artifact@v4
38
+ if: always()
39
+ with:
40
+ name: gum-h1-mathematical-reference
41
+ path: ${{ runner.temp }}/gum-reference.json
42
+ if-no-files-found: warn
43
+ - uses: actions/upload-artifact@v4
44
+ if: always()
45
+ with:
46
+ name: gum-extended-mathematical-references
47
+ path: ${{ runner.temp }}/gum-profiles-reference.json
48
+ if-no-files-found: warn
@@ -0,0 +1,54 @@
1
+ name: performance-ci-legs
2
+
3
+ # Records the wall time of each leg of a rake run on main and fails when a leg
4
+ # took longer than the 30-minute budget in docs/performance-contract.adoc.
5
+ # After each rake run on main it reads that run; on demand it reads the newest
6
+ # completed rake run on main.
7
+
8
+ on:
9
+ workflow_run:
10
+ workflows: [rake]
11
+ types: [completed]
12
+ branches: [main]
13
+ workflow_dispatch:
14
+
15
+ permissions:
16
+ contents: read
17
+
18
+ concurrency:
19
+ group: performance-ci-legs-${{ github.event.workflow_run.id || github.ref }}
20
+ cancel-in-progress: true
21
+
22
+ jobs:
23
+ ci-legs:
24
+ # A cancelled rake run has legs without times; there is nothing to gate.
25
+ if: github.event_name != 'workflow_run' || github.event.workflow_run.conclusion != 'cancelled'
26
+ runs-on: ubuntu-22.04
27
+ timeout-minutes: 10
28
+ permissions:
29
+ actions: read
30
+ contents: read
31
+ steps:
32
+ - uses: actions/checkout@v5
33
+ - uses: ruby/setup-ruby@v1
34
+ with:
35
+ ruby-version: "4.0.1"
36
+ - name: Record rake leg timings against the 1800 s budget
37
+ env:
38
+ GH_TOKEN: ${{ github.token }}
39
+ RUN_ID: ${{ github.event.workflow_run.id }}
40
+ run: |
41
+ mkdir -p tmp/performance
42
+ if [ -n "$RUN_ID" ]; then
43
+ ruby scripts/check_suite_budget.rb ci --run-id "$RUN_ID" \
44
+ --budget-seconds 1800 --enforce --output tmp/performance/ci-legs.json
45
+ else
46
+ ruby scripts/check_suite_budget.rb ci --workflow rake.yml --branch main \
47
+ --budget-seconds 1800 --enforce --output tmp/performance/ci-legs.json
48
+ fi
49
+ - uses: actions/upload-artifact@v4
50
+ if: always()
51
+ with:
52
+ name: performance-ci-legs
53
+ path: tmp/performance/
54
+ retention-days: 90
@@ -0,0 +1,99 @@
1
+ name: performance
2
+
3
+ # Measures and gates plurimath's own cost. Each job fails when its figures go
4
+ # past the limits in docs/performance-contract.adoc. The rake leg timings are
5
+ # recorded by performance-ci-legs.yml, after each rake run on main.
6
+
7
+ on:
8
+ push:
9
+ branches: [main]
10
+ pull_request:
11
+ paths:
12
+ - "lib/**"
13
+ - "spec/**"
14
+ - "Gemfile"
15
+ - "plurimath.gemspec"
16
+ - "scripts/measure_require.rb"
17
+ - "scripts/check_suite_budget.rb"
18
+ - ".github/workflows/performance.yml"
19
+ workflow_dispatch:
20
+
21
+ permissions:
22
+ contents: read
23
+
24
+ concurrency:
25
+ group: performance-${{ github.event_name }}-${{ github.head_ref || github.ref }}
26
+ cancel-in-progress: true
27
+
28
+ jobs:
29
+ require-footprint:
30
+ runs-on: ubuntu-22.04
31
+ timeout-minutes: 30
32
+ steps:
33
+ - uses: actions/checkout@v5
34
+ - uses: ruby/setup-ruby@v1
35
+ with:
36
+ ruby-version: "4.0.1"
37
+ bundler-cache: true
38
+ - name: Measure require "plurimath" against the baseline (ox and oga engines)
39
+ run: |
40
+ mkdir -p tmp/performance
41
+ status=0
42
+ for engine in ox oga; do
43
+ bundle exec ruby scripts/measure_require.rb --samples 5 \
44
+ --engine "$engine" --baseline scripts/require_baseline.json --enforce \
45
+ --output "tmp/performance/require-$engine.json" || status=1
46
+ done
47
+ ruby -rjson -e '
48
+ puts "### require \"plurimath\" (median of 5 cold processes)", ""
49
+ puts "| Engine | Wall ms | Features | Own lib files | Allocated | RSS KB | First use ms | First use files | Pending autoloads | Gate |"
50
+ puts "| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |"
51
+ Dir["tmp/performance/require-*.json"].sort.each do |f|
52
+ d = JSON.parse(File.read(f))
53
+ r, u, a = d["require"], d["first_use"], d["autoload"]
54
+ failed = d.dig("gate", "checks").to_a.reject { |c| c["ok"] }.map { |c| c["name"] }
55
+ gate = failed.empty? ? "pass" : "fail: #{failed.join(", ")}"
56
+ puts "| #{d["engine"]} | #{r["wall_ms"]} | #{r["loaded_features"]} | #{r["plurimath_lib_files"]} | #{r["allocated_objects"]} | #{r["rss_growth_kb"]} | #{u["wall_ms"]} | #{u["plurimath_lib_files"]} | #{a["pending_after_require"]} | #{gate} |"
57
+ end
58
+ ' >> "$GITHUB_STEP_SUMMARY"
59
+ exit "$status"
60
+ - uses: actions/upload-artifact@v4
61
+ if: always()
62
+ with:
63
+ name: performance-require
64
+ path: tmp/performance/
65
+ retention-days: 90
66
+
67
+ suite-timing:
68
+ # Full-suite wall time on one fixed runner: the proxy for the local-suite
69
+ # target. It runs the suite exactly as rake does; only the formatter
70
+ # differs, so the example list and engine loop are unchanged. The job
71
+ # fails when an example fails or the wall time is over the ceiling in
72
+ # docs/performance-contract.adoc.
73
+ runs-on: ubuntu-22.04
74
+ timeout-minutes: 240
75
+ steps:
76
+ - uses: actions/checkout@v5
77
+ with:
78
+ submodules: recursive
79
+ - uses: ruby/setup-ruby@v1
80
+ with:
81
+ ruby-version: "4.0.1"
82
+ bundler-cache: true
83
+ - name: Run the full suite under the timing wrapper
84
+ env:
85
+ ENGINE_LOOP_REPORT: tmp/performance/engine-loop.json
86
+ run: |
87
+ mkdir -p tmp/performance
88
+ ruby scripts/check_suite_budget.rb suite --budget-seconds 1850 --enforce \
89
+ --rspec-json tmp/performance/rspec.json \
90
+ --engine-loop-json tmp/performance/engine-loop.json \
91
+ --output tmp/performance/suite.json \
92
+ -- bundle exec rspec --format progress \
93
+ --format json --out tmp/performance/rspec.json
94
+ - uses: actions/upload-artifact@v4
95
+ if: always()
96
+ with:
97
+ name: performance-suite
98
+ path: tmp/performance/
99
+ retention-days: 90
@@ -0,0 +1,33 @@
1
+ name: Roundtrip cases
2
+
3
+ # scripts/roundtrip_cases.rb writes the uncertainty round-trip payloads of
4
+ # plurimath-testsuite (stages/roundtrip). Check that it runs on both XML
5
+ # engines, writes the same bytes twice, and agrees with its spec.
6
+
7
+ on:
8
+ push:
9
+ branches: [main]
10
+ pull_request:
11
+
12
+ permissions:
13
+ contents: read
14
+
15
+ jobs:
16
+ roundtrip-cases:
17
+ runs-on: ubuntu-22.04
18
+ timeout-minutes: 30
19
+ steps:
20
+ - uses: actions/checkout@v5
21
+ with:
22
+ submodules: recursive
23
+ - uses: ruby/setup-ruby@v1
24
+ with:
25
+ ruby-version: "4.0.1"
26
+ bundler-cache: true
27
+ - name: Generate the roundtrip payloads twice
28
+ run: |
29
+ bundle exec ruby scripts/roundtrip_cases.rb --out "$RUNNER_TEMP/roundtrip-a"
30
+ bundle exec ruby scripts/roundtrip_cases.rb --out "$RUNNER_TEMP/roundtrip-b"
31
+ diff -r "$RUNNER_TEMP/roundtrip-a" "$RUNNER_TEMP/roundtrip-b"
32
+ - name: Check the cases against the round-trip matrix
33
+ run: bundle exec rspec spec/plurimath/roundtrip_cases_spec.rb
data/.rubocop_todo.yml CHANGED
@@ -32,16 +32,8 @@ Layout/ArgumentAlignment:
32
32
  Layout/ArrayAlignment:
33
33
  Exclude:
34
34
  - 'lib/plurimath/formatter/numbers/notation_renderer.rb'
35
- - 'lib/plurimath/unicode_math/transform.rb'
36
35
  - 'spec/plurimath/math/evaluation_spec.rb'
37
36
 
38
- # Offense count: 10
39
- # This cop supports safe autocorrection (--autocorrect).
40
- # Configuration parameters: IndentationWidth.
41
- Layout/AssignmentIndentation:
42
- Exclude:
43
- - 'lib/plurimath/unicode_math/transform.rb'
44
-
45
37
  # Offense count: 15
46
38
  # This cop supports safe autocorrection (--autocorrect).
47
39
  # Configuration parameters: EnforcedStyleAlignWith.
@@ -49,7 +41,6 @@ Layout/AssignmentIndentation:
49
41
  Layout/BlockAlignment:
50
42
  Exclude:
51
43
  - 'lib/plurimath/math/evaluation/evaluator.rb'
52
- - 'lib/plurimath/unicode_math/transform.rb'
53
44
  - 'spec/plurimath/math/evaluation_spec.rb'
54
45
 
55
46
  # Offense count: 12
@@ -57,7 +48,6 @@ Layout/BlockAlignment:
57
48
  Layout/BlockEndNewline:
58
49
  Exclude:
59
50
  - 'lib/plurimath/math/evaluation/evaluator.rb'
60
- - 'lib/plurimath/unicode_math/transform.rb'
61
51
  - 'spec/plurimath/math/evaluation_spec.rb'
62
52
 
63
53
  # Offense count: 35
@@ -66,29 +56,8 @@ Layout/ClosingParenthesisIndentation:
66
56
  Exclude:
67
57
  - 'lib/plurimath/formatter/numbers/notation_renderer.rb'
68
58
  - 'lib/plurimath/math/number.rb'
69
- - 'lib/plurimath/unicode_math/transform.rb'
70
59
  - 'spec/plurimath/math/evaluation_spec.rb'
71
60
 
72
- # Offense count: 18
73
- # This cop supports safe autocorrection (--autocorrect).
74
- Layout/ElseAlignment:
75
- Exclude:
76
- - 'lib/plurimath/unicode_math/transform.rb'
77
-
78
- # Offense count: 1
79
- # This cop supports safe autocorrection (--autocorrect).
80
- Layout/EmptyLines:
81
- Exclude:
82
- - 'lib/plurimath/unicode_math/transform.rb'
83
-
84
- # Offense count: 10
85
- # This cop supports safe autocorrection (--autocorrect).
86
- # Configuration parameters: EnforcedStyleAlignWith.
87
- # SupportedStylesAlignWith: keyword, variable, start_of_line
88
- Layout/EndAlignment:
89
- Exclude:
90
- - 'lib/plurimath/unicode_math/transform.rb'
91
-
92
61
  # Offense count: 35
93
62
  # This cop supports safe autocorrection (--autocorrect).
94
63
  # Configuration parameters: EnforcedStyle, IndentationWidth.
@@ -97,17 +66,8 @@ Layout/FirstArgumentIndentation:
97
66
  Exclude:
98
67
  - 'lib/plurimath/formatter/numbers/notation_renderer.rb'
99
68
  - 'lib/plurimath/math/number.rb'
100
- - 'lib/plurimath/unicode_math/transform.rb'
101
69
  - 'spec/plurimath/math/evaluation_spec.rb'
102
70
 
103
- # Offense count: 14
104
- # This cop supports safe autocorrection (--autocorrect).
105
- # Configuration parameters: EnforcedStyle, IndentationWidth.
106
- # SupportedStyles: special_inside_parentheses, consistent, align_brackets
107
- Layout/FirstArrayElementIndentation:
108
- Exclude:
109
- - 'lib/plurimath/unicode_math/transform.rb'
110
-
111
71
  # Offense count: 22
112
72
  # This cop supports safe autocorrection (--autocorrect).
113
73
  # Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
@@ -116,19 +76,10 @@ Layout/FirstArrayElementIndentation:
116
76
  # SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
117
77
  Layout/HashAlignment:
118
78
  Exclude:
119
- - 'lib/plurimath/unicode_math/transform.rb'
120
79
  - 'spec/plurimath/formatter/numbers/base_notation_spec.rb'
121
80
  - 'spec/plurimath/math/evaluation_spec.rb'
122
81
  - 'spec/plurimath/math/number_spec.rb'
123
82
 
124
- # Offense count: 4
125
- # This cop supports safe autocorrection (--autocorrect).
126
- # Configuration parameters: EnforcedStyle.
127
- # SupportedStyles: normal, indented_internal_methods
128
- Layout/IndentationConsistency:
129
- Exclude:
130
- - 'lib/plurimath/unicode_math/transform.rb'
131
-
132
83
  # Offense count: 60
133
84
  # This cop supports safe autocorrection (--autocorrect).
134
85
  # Configuration parameters: Width, EnforcedStyleAlignWith, AllowedPatterns.
@@ -136,7 +87,6 @@ Layout/IndentationConsistency:
136
87
  Layout/IndentationWidth:
137
88
  Exclude:
138
89
  - 'lib/plurimath/math/evaluation/evaluator.rb'
139
- - 'lib/plurimath/unicode_math/transform.rb'
140
90
  - 'spec/plurimath/math/evaluation_spec.rb'
141
91
 
142
92
  # Offense count: 29707
@@ -154,29 +104,14 @@ Layout/MultilineMethodCallBraceLayout:
154
104
  Exclude:
155
105
  - 'lib/plurimath/formatter/numbers/notation_renderer.rb'
156
106
  - 'lib/plurimath/math/number.rb'
157
- - 'lib/plurimath/unicode_math/transform.rb'
158
107
  - 'spec/plurimath/math/evaluation_spec.rb'
159
108
 
160
- # Offense count: 2
161
- # This cop supports safe autocorrection (--autocorrect).
162
- # Configuration parameters: EnforcedStyle, IndentationWidth.
163
- # SupportedStyles: aligned, indented
164
- Layout/MultilineOperationIndentation:
165
- Exclude:
166
- - 'lib/plurimath/unicode_math/transform.rb'
167
-
168
109
  # Offense count: 266
169
110
  # This cop supports safe autocorrection (--autocorrect).
170
111
  # Configuration parameters: AllowInHeredoc.
171
112
  Layout/TrailingWhitespace:
172
113
  Enabled: false
173
114
 
174
- # Offense count: 1
175
- # This cop supports safe autocorrection (--autocorrect).
176
- Lint/AmbiguousOperatorPrecedence:
177
- Exclude:
178
- - 'lib/plurimath/unicode_math/transform.rb'
179
-
180
115
  # Offense count: 1
181
116
  # Configuration parameters: AllowedMethods.
182
117
  # AllowedMethods: enums
@@ -193,7 +128,6 @@ Lint/DuplicateBranch:
193
128
  - 'lib/plurimath/math/function/power_base.rb'
194
129
  - 'lib/plurimath/mathml/formula_transformation.rb'
195
130
  - 'lib/plurimath/mathml/translator.rb'
196
- - 'lib/plurimath/unicode_math/transform.rb'
197
131
  - 'lib/plurimath/xml_engine/oga/dumper.rb'
198
132
 
199
133
  # Offense count: 6
@@ -270,12 +204,6 @@ Lint/UnusedMethodArgument:
270
204
  - 'lib/plurimath/utility.rb'
271
205
  - 'spec/plurimath/math/number_spec.rb'
272
206
 
273
- # Offense count: 2
274
- # This cop supports safe autocorrection (--autocorrect).
275
- Lint/UselessAssignment:
276
- Exclude:
277
- - 'lib/plurimath/unicode_math/transform.rb'
278
-
279
207
  # Offense count: 161
280
208
  # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
281
209
  Metrics/AbcSize:
@@ -485,37 +413,8 @@ RSpec/SpecFilePathFormat:
485
413
  Style/BlockDelimiters:
486
414
  Exclude:
487
415
  - 'lib/plurimath/math/evaluation/evaluator.rb'
488
- - 'lib/plurimath/unicode_math/transform.rb'
489
416
  - 'spec/plurimath/math/evaluation_spec.rb'
490
417
 
491
- # Offense count: 3
492
- # This cop supports unsafe autocorrection (--autocorrect-all).
493
- # Configuration parameters: MinBranchesCount.
494
- Style/CaseLikeIf:
495
- Exclude:
496
- - 'lib/plurimath/unicode_math/transform.rb'
497
-
498
- # Offense count: 1
499
- # This cop supports unsafe autocorrection (--autocorrect-all).
500
- Style/ConcatArrayLiterals:
501
- Exclude:
502
- - 'lib/plurimath/unicode_math/transform.rb'
503
-
504
- # Offense count: 2
505
- # This cop supports safe autocorrection (--autocorrect).
506
- # Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions.
507
- # SupportedStyles: assign_to_condition, assign_inside_condition
508
- Style/ConditionalAssignment:
509
- Exclude:
510
- - 'lib/plurimath/unicode_math/transform.rb'
511
-
512
- # Offense count: 24
513
- # This cop supports safe autocorrection (--autocorrect).
514
- # Configuration parameters: AllowIfModifier.
515
- Style/IfInsideElse:
516
- Exclude:
517
- - 'lib/plurimath/unicode_math/transform.rb'
518
-
519
418
  # Offense count: 43
520
419
  # This cop supports safe autocorrection (--autocorrect).
521
420
  Style/MultilineIfModifier:
@@ -523,13 +422,6 @@ Style/MultilineIfModifier:
523
422
  - 'lib/plurimath/formatter/numbers/notation_renderer.rb'
524
423
  - 'lib/plurimath/math/evaluation/evaluator.rb'
525
424
  - 'lib/plurimath/math/function/log.rb'
526
- - 'lib/plurimath/unicode_math/transform.rb'
527
-
528
- # Offense count: 30
529
- # This cop supports safe autocorrection (--autocorrect).
530
- Style/MultilineTernaryOperator:
531
- Exclude:
532
- - 'lib/plurimath/unicode_math/transform.rb'
533
425
 
534
426
  # Offense count: 39
535
427
  Style/OptionalArguments:
@@ -551,13 +443,6 @@ Style/OptionalArguments:
551
443
  Style/OptionalBooleanParameter:
552
444
  Enabled: false
553
445
 
554
- # Offense count: 5
555
- # This cop supports safe autocorrection (--autocorrect).
556
- # Configuration parameters: AllowSafeAssignment, AllowInMultilineConditions.
557
- Style/ParenthesesAroundCondition:
558
- Exclude:
559
- - 'lib/plurimath/unicode_math/transform.rb'
560
-
561
446
  # Offense count: 78
562
447
  # This cop supports safe autocorrection (--autocorrect).
563
448
  # Configuration parameters: EnforcedStyle.
@@ -566,12 +451,6 @@ Style/QuotedSymbols:
566
451
  Exclude:
567
452
  - 'lib/plurimath/unicode_math/constants.rb'
568
453
 
569
- # Offense count: 77
570
- # This cop supports safe autocorrection (--autocorrect).
571
- Style/RedundantParentheses:
572
- Exclude:
573
- - 'lib/plurimath/unicode_math/transform.rb'
574
-
575
454
  # Offense count: 1
576
455
  # This cop supports safe autocorrection (--autocorrect).
577
456
  Style/RedundantRegexpEscape:
@@ -613,18 +492,9 @@ Style/SymbolArray:
613
492
  # SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma
614
493
  Style/TrailingCommaInArguments:
615
494
  Exclude:
616
- - 'lib/plurimath/unicode_math/transform.rb'
617
495
  - 'spec/plurimath/formatter/numbers/formatted_notation_spec.rb'
618
496
  - 'spec/plurimath/formatter/numbers/formatted_number_spec.rb'
619
497
 
620
- # Offense count: 4
621
- # This cop supports safe autocorrection (--autocorrect).
622
- # Configuration parameters: EnforcedStyleForMultiline.
623
- # SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma
624
- Style/TrailingCommaInArrayLiteral:
625
- Exclude:
626
- - 'lib/plurimath/unicode_math/transform.rb'
627
-
628
498
  # Offense count: 6
629
499
  # This cop supports safe autocorrection (--autocorrect).
630
500
  # Configuration parameters: EnforcedStyleForMultiline.
@@ -632,11 +502,3 @@ Style/TrailingCommaInArrayLiteral:
632
502
  Style/TrailingCommaInHashLiteral:
633
503
  Exclude:
634
504
  - 'lib/plurimath/unicode_math/constants.rb'
635
-
636
- # Offense count: 15
637
- # This cop supports unsafe autocorrection (--autocorrect-all).
638
- # Configuration parameters: EnforcedStyle.
639
- # SupportedStyles: forbid_for_all_comparison_operators, forbid_for_equality_operators_only, require_for_all_comparison_operators, require_for_equality_operators_only
640
- Style/YodaCondition:
641
- Exclude:
642
- - 'lib/plurimath/unicode_math/transform.rb'
data/Gemfile CHANGED
@@ -3,7 +3,16 @@ source "https://rubygems.org"
3
3
  # Specify your gem's dependencies in plurimath.gemspec
4
4
  gemspec
5
5
 
6
+ # amath's typed model (Amath.parse_model returning Amath::Model::Document) ships in
7
+ # amath 0.2.0, which is not on RubyGems yet. Until it is, amath comes from this
8
+ # commit of plurimath/amath PR #34 (version 0.2.0). Drop this line once 0.2.0
9
+ # is published, and do not release plurimath before then.
10
+ gem "amath", git: "https://github.com/plurimath/amath",
11
+ ref: "667b517bb81276bf920f6f9fea940ae342d8c9e3"
6
12
  gem "canon"
13
+ gem "fiddle", "~> 1.1"
14
+ # Candidate includes typed symbol portability; retain its exact pin until published.
15
+ gem "latexmath", github: "plurimath/latexmath", ref: "372e377261c82e801ce755ebca7abfae1336ec39"
7
16
  gem "leptris" # third XML engine under test (spec_helper runs each example per engine)
8
17
  # Optional native image-rendering backend for `Formula#render` / `plurimath
9
18
  # render`. Git-pinned until `lasem` ships to RubyGems; intentionally NOT a
@@ -19,6 +28,10 @@ gem "nokogiri"
19
28
  gem "opal-rspec", "~> 1.1.0a"
20
29
  gem "ox"
21
30
  gem "parsanol"
31
+ gem "umath", "~> 0.1"
32
+ # Qualify the serialized quantity profile against the exact conversion producer.
33
+ # Remove this development pin when the exact fractional conversion ships.
34
+ gem "unitsml", github: "unitsml/unitsml-ruby", ref: "d64c95a478427b482f9bde2c4cbb626b111cb059"
22
35
  gem "rake", "~> 12.0"
23
36
  gem "rspec", "~> 3.0"
24
37
  gem "rubocop-performance"
data/Rakefile CHANGED
@@ -116,6 +116,8 @@ end
116
116
 
117
117
  def intent_classes
118
118
  require_math_function_files
119
+ # Symbol classes load on demand; load them all so descendants is complete.
120
+ Plurimath::Math::Symbols.eager_load!
119
121
 
120
122
  intent_classes = [
121
123
  Plurimath::Math::Function::TernaryFunction.descendants,