crc-framework 0.3.0__tar.gz → 0.4.0__tar.gz

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 (88) hide show
  1. crc_framework-0.4.0/.github/workflows/npm.yaml +72 -0
  2. {crc_framework-0.3.0 → crc_framework-0.4.0}/.gitignore +9 -1
  3. {crc_framework-0.3.0 → crc_framework-0.4.0}/Cargo.lock +149 -2
  4. {crc_framework-0.3.0 → crc_framework-0.4.0}/Cargo.toml +4 -1
  5. {crc_framework-0.3.0 → crc_framework-0.4.0}/PKG-INFO +231 -92
  6. {crc_framework-0.3.0 → crc_framework-0.4.0}/README.md +230 -91
  7. {crc_framework-0.3.0 → crc_framework-0.4.0}/crates/core/Cargo.toml +10 -2
  8. crc_framework-0.4.0/crates/core/src/canonical.rs +166 -0
  9. {crc_framework-0.3.0 → crc_framework-0.4.0}/crates/core/src/distribution.rs +257 -7
  10. {crc_framework-0.3.0 → crc_framework-0.4.0}/crates/core/src/lib.rs +7 -4
  11. {crc_framework-0.3.0 → crc_framework-0.4.0}/crates/core/src/reference/curve_fitting.rs +361 -7
  12. crc_framework-0.4.0/crates/core/tests/canonical_consumer.rs +85 -0
  13. crc_framework-0.4.0/crates/core/tests/censored_quantile_fit.rs +294 -0
  14. {crc_framework-0.3.0 → crc_framework-0.4.0}/crates/core/tests/quantile_fit_golden.rs +111 -15
  15. crc_framework-0.4.0/js/.nvmrc +1 -0
  16. crc_framework-0.4.0/js/README.md +137 -0
  17. crc_framework-0.4.0/js/build.mjs +60 -0
  18. crc_framework-0.4.0/js/package-lock.json +1233 -0
  19. crc_framework-0.4.0/js/package.json +43 -0
  20. crc_framework-0.4.0/js/publish.mjs +16 -0
  21. crc_framework-0.4.0/js/src/index.d.ts +75 -0
  22. crc_framework-0.4.0/js/src/index.js +213 -0
  23. crc_framework-0.4.0/js/test/benchmark.mjs +64 -0
  24. crc_framework-0.4.0/js/test/browser.html +47 -0
  25. crc_framework-0.4.0/js/test/browser.mjs +30 -0
  26. crc_framework-0.4.0/js/test/consumer.mjs +64 -0
  27. crc_framework-0.4.0/js/test/parity.test.mjs +185 -0
  28. crc_framework-0.4.0/js/test/publish.test.mjs +47 -0
  29. {crc_framework-0.3.0 → crc_framework-0.4.0}/python/crc_framework/__init__.py +6 -0
  30. {crc_framework-0.3.0 → crc_framework-0.4.0}/python/crc_framework/_core.pyi +25 -0
  31. {crc_framework-0.3.0 → crc_framework-0.4.0}/python/crc_framework/distributions/__init__.py +6 -0
  32. {crc_framework-0.3.0 → crc_framework-0.4.0}/python/crc_framework/distributions/fitting.py +109 -1
  33. {crc_framework-0.3.0 → crc_framework-0.4.0}/src/lib.rs +96 -0
  34. crc_framework-0.4.0/tests/fixtures/canonical-quantiles.json +645 -0
  35. crc_framework-0.4.0/tests/test_consumer_parity.py +19 -0
  36. {crc_framework-0.3.0 → crc_framework-0.4.0}/tests/test_sdk.py +20 -0
  37. crc_framework-0.4.0/tools/generate_consumer_fixtures.py +75 -0
  38. {crc_framework-0.3.0 → crc_framework-0.4.0}/.github/workflows/release.yaml +0 -0
  39. {crc_framework-0.3.0 → crc_framework-0.4.0}/.python-version +0 -0
  40. {crc_framework-0.3.0 → crc_framework-0.4.0}/LICENSE +0 -0
  41. {crc_framework-0.3.0 → crc_framework-0.4.0}/THIRD_PARTY_NOTICES.md +0 -0
  42. {crc_framework-0.3.0 → crc_framework-0.4.0}/crates/core/src/constants.rs +0 -0
  43. {crc_framework-0.3.0 → crc_framework-0.4.0}/crates/core/src/distribution/lmoments.rs +0 -0
  44. {crc_framework-0.3.0 → crc_framework-0.4.0}/crates/core/src/error.rs +0 -0
  45. {crc_framework-0.3.0 → crc_framework-0.4.0}/crates/core/src/metrics.rs +0 -0
  46. {crc_framework-0.3.0 → crc_framework-0.4.0}/crates/core/src/reference/climate/ag_params.rs +0 -0
  47. {crc_framework-0.3.0 → crc_framework-0.4.0}/crates/core/src/reference/climate/energy_params.rs +0 -0
  48. {crc_framework-0.3.0 → crc_framework-0.4.0}/crates/core/src/reference/climate/flood_params.rs +0 -0
  49. {crc_framework-0.3.0 → crc_framework-0.4.0}/crates/core/src/reference/climate/mod.rs +0 -0
  50. {crc_framework-0.3.0 → crc_framework-0.4.0}/crates/core/src/reference/climate/precipitation_thresholds.rs +0 -0
  51. {crc_framework-0.3.0 → crc_framework-0.4.0}/crates/core/src/reference/climate/spei_params.rs +0 -0
  52. {crc_framework-0.3.0 → crc_framework-0.4.0}/crates/core/src/reference/climate/wind_params.rs +0 -0
  53. {crc_framework-0.3.0 → crc_framework-0.4.0}/crates/core/src/reference/mod.rs +0 -0
  54. {crc_framework-0.3.0 → crc_framework-0.4.0}/crates/core/src/reference/spatial/continent_r4.rs +0 -0
  55. {crc_framework-0.3.0 → crc_framework-0.4.0}/crates/core/src/reference/spatial/geography_r5.rs +0 -0
  56. {crc_framework-0.3.0 → crc_framework-0.4.0}/crates/core/src/reference/spatial/ipcc.rs +0 -0
  57. {crc_framework-0.3.0 → crc_framework-0.4.0}/crates/core/src/reference/spatial/mod.rs +0 -0
  58. {crc_framework-0.3.0 → crc_framework-0.4.0}/crates/core/src/risk.rs +0 -0
  59. {crc_framework-0.3.0 → crc_framework-0.4.0}/crates/core/src/spatial.rs +0 -0
  60. {crc_framework-0.3.0 → crc_framework-0.4.0}/crates/core/src/transform.rs +0 -0
  61. {crc_framework-0.3.0 → crc_framework-0.4.0}/crates/core/tests/quantile_fit_golden.txt +0 -0
  62. {crc_framework-0.3.0 → crc_framework-0.4.0}/pyproject.toml +0 -0
  63. {crc_framework-0.3.0 → crc_framework-0.4.0}/python/crc_framework/constants.py +0 -0
  64. {crc_framework-0.3.0 → crc_framework-0.4.0}/python/crc_framework/distributions/base.py +0 -0
  65. {crc_framework-0.3.0 → crc_framework-0.4.0}/python/crc_framework/distributions/empirical.py +0 -0
  66. {crc_framework-0.3.0 → crc_framework-0.4.0}/python/crc_framework/distributions/fitted.py +0 -0
  67. {crc_framework-0.3.0 → crc_framework-0.4.0}/python/crc_framework/distributions/hurdle.py +0 -0
  68. {crc_framework-0.3.0 → crc_framework-0.4.0}/python/crc_framework/distributions/point_mass.py +0 -0
  69. {crc_framework-0.3.0 → crc_framework-0.4.0}/python/crc_framework/distributions/tabulated.py +0 -0
  70. {crc_framework-0.3.0 → crc_framework-0.4.0}/python/crc_framework/metrics/__init__.py +0 -0
  71. {crc_framework-0.3.0 → crc_framework-0.4.0}/python/crc_framework/metrics/distribution.py +0 -0
  72. {crc_framework-0.3.0 → crc_framework-0.4.0}/python/crc_framework/metrics/microscores.py +0 -0
  73. {crc_framework-0.3.0 → crc_framework-0.4.0}/python/crc_framework/metrics/risk.py +0 -0
  74. {crc_framework-0.3.0 → crc_framework-0.4.0}/python/crc_framework/metrics/spanning.py +0 -0
  75. {crc_framework-0.3.0 → crc_framework-0.4.0}/python/crc_framework/models.py +0 -0
  76. {crc_framework-0.3.0 → crc_framework-0.4.0}/python/crc_framework/py.typed +0 -0
  77. {crc_framework-0.3.0 → crc_framework-0.4.0}/python/crc_framework/spatial.py +0 -0
  78. {crc_framework-0.3.0 → crc_framework-0.4.0}/python/crc_framework/transforms/__init__.py +0 -0
  79. {crc_framework-0.3.0 → crc_framework-0.4.0}/python/crc_framework/transforms/base.py +0 -0
  80. {crc_framework-0.3.0 → crc_framework-0.4.0}/python/crc_framework/transforms/builtin.py +0 -0
  81. {crc_framework-0.3.0 → crc_framework-0.4.0}/python/crc_framework/transforms/climate.py +0 -0
  82. {crc_framework-0.3.0 → crc_framework-0.4.0}/tests/test_impacts.py +0 -0
  83. {crc_framework-0.3.0 → crc_framework-0.4.0}/tests/test_lmoments.py +0 -0
  84. {crc_framework-0.3.0 → crc_framework-0.4.0}/tests/typing_smoke.py +0 -0
  85. {crc_framework-0.3.0 → crc_framework-0.4.0}/tools/benchmark_lmoments.py +0 -0
  86. {crc_framework-0.3.0 → crc_framework-0.4.0}/tools/benchmarks/lmoments-audit-m2-pro.json +0 -0
  87. {crc_framework-0.3.0 → crc_framework-0.4.0}/tools/requirements-lmoments-benchmark.txt +0 -0
  88. {crc_framework-0.3.0 → crc_framework-0.4.0}/uv.lock +0 -0
@@ -0,0 +1,72 @@
1
+ name: JavaScript WASM
2
+ on:
3
+ pull_request:
4
+ push:
5
+ branches: [main, master]
6
+ tags: ['v*']
7
+ workflow_dispatch:
8
+ permissions:
9
+ contents: read
10
+ jobs:
11
+ build:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v7
15
+ - uses: dtolnay/rust-toolchain@stable
16
+ with:
17
+ targets: wasm32-unknown-unknown
18
+ - uses: Swatinem/rust-cache@v2
19
+ - uses: actions/setup-node@v7
20
+ with:
21
+ node-version-file: js/.nvmrc
22
+ cache: npm
23
+ cache-dependency-path: js/package-lock.json
24
+ - uses: actions/setup-python@v7
25
+ with:
26
+ python-version: '3.12'
27
+ - name: Test native core and Python parity
28
+ run: |
29
+ cargo test -p crc-framework-core --locked
30
+ cargo test -p crc-framework-core --no-default-features --lib --test canonical_consumer --locked
31
+ pip install maturin pytest numpy
32
+ maturin build --release --locked --out /tmp/crc-wheels
33
+ pip install /tmp/crc-wheels/*.whl
34
+ python -m pytest -q
35
+ - name: Install WASM build tooling
36
+ run: cargo install wasm-pack --version 0.15.0 --locked
37
+ - name: Build and test package
38
+ working-directory: js
39
+ run: |
40
+ npm ci
41
+ npm run build
42
+ npm test
43
+ npx playwright install --with-deps chromium
44
+ npm run test:browser
45
+ npm run benchmark
46
+ npm run test:consumer
47
+ - name: Verify build leaves version sources unchanged
48
+ run: git diff --exit-code -- Cargo.toml Cargo.lock crates/core/Cargo.toml crates/wasm/Cargo.toml js/package.json js/package-lock.json
49
+ - uses: actions/upload-artifact@v4
50
+ with:
51
+ name: npm-package
52
+ path: js/dist/*.tgz
53
+ publish:
54
+ if: startsWith(github.ref, 'refs/tags/v')
55
+ needs: build
56
+ runs-on: ubuntu-latest
57
+ environment: production
58
+ permissions:
59
+ contents: read
60
+ id-token: write
61
+ steps:
62
+ - uses: actions/checkout@v7
63
+ - uses: actions/setup-node@v7
64
+ with:
65
+ node-version-file: js/.nvmrc
66
+ registry-url: https://registry.npmjs.org
67
+ - uses: actions/download-artifact@v8
68
+ with:
69
+ name: npm-package
70
+ path: artifact
71
+ - name: Publish tested tarball using npm OIDC
72
+ run: node js/publish.mjs artifact
@@ -1,3 +1,5 @@
1
+ /plan
2
+
1
3
  target/
2
4
  .venv/
3
5
  **/*.so
@@ -11,4 +13,10 @@ build/
11
13
  .env
12
14
  .vscode/
13
15
  .idea/
14
- .ruff_cache/
16
+ .ruff_cache/
17
+
18
+ js/wasm/
19
+ js/LICENSE
20
+ js/THIRD_PARTY_NOTICES.md
21
+ js/*.tgz
22
+ js/node_modules/
@@ -15,6 +15,12 @@ dependencies = [
15
15
  "zerocopy",
16
16
  ]
17
17
 
18
+ [[package]]
19
+ name = "bumpalo"
20
+ version = "3.20.3"
21
+ source = "registry+https://github.com/rust-lang/crates.io-index"
22
+ checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649"
23
+
18
24
  [[package]]
19
25
  name = "cfg-if"
20
26
  version = "1.0.4"
@@ -43,22 +49,33 @@ dependencies = [
43
49
 
44
50
  [[package]]
45
51
  name = "crc-framework-core"
46
- version = "0.3.0"
52
+ version = "0.4.0"
47
53
  dependencies = [
48
54
  "h3o",
49
55
  "phf",
50
56
  "rand",
57
+ "serde",
58
+ "serde_json",
51
59
  ]
52
60
 
53
61
  [[package]]
54
62
  name = "crc-framework-rs"
55
- version = "0.3.0"
63
+ version = "0.4.0"
56
64
  dependencies = [
57
65
  "crc-framework-core",
58
66
  "h3o",
59
67
  "pyo3",
60
68
  ]
61
69
 
70
+ [[package]]
71
+ name = "crc-framework-wasm"
72
+ version = "0.4.0"
73
+ dependencies = [
74
+ "crc-framework-core",
75
+ "js-sys",
76
+ "wasm-bindgen",
77
+ ]
78
+
62
79
  [[package]]
63
80
  name = "crunchy"
64
81
  version = "0.2.4"
@@ -83,6 +100,30 @@ version = "1.0.1"
83
100
  source = "registry+https://github.com/rust-lang/crates.io-index"
84
101
  checksum = "28a80e3145d8ad11ba0995949bbcf48b9df2be62772b3d351ef017dff6ecb853"
85
102
 
103
+ [[package]]
104
+ name = "futures-core"
105
+ version = "0.3.34"
106
+ source = "registry+https://github.com/rust-lang/crates.io-index"
107
+ checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e"
108
+
109
+ [[package]]
110
+ name = "futures-task"
111
+ version = "0.3.34"
112
+ source = "registry+https://github.com/rust-lang/crates.io-index"
113
+ checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd"
114
+
115
+ [[package]]
116
+ name = "futures-util"
117
+ version = "0.3.34"
118
+ source = "registry+https://github.com/rust-lang/crates.io-index"
119
+ checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc"
120
+ dependencies = [
121
+ "futures-core",
122
+ "futures-task",
123
+ "pin-project-lite",
124
+ "slab",
125
+ ]
126
+
86
127
  [[package]]
87
128
  name = "getrandom"
88
129
  version = "0.2.17"
@@ -131,6 +172,23 @@ version = "0.5.0"
131
172
  source = "registry+https://github.com/rust-lang/crates.io-index"
132
173
  checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
133
174
 
175
+ [[package]]
176
+ name = "itoa"
177
+ version = "1.0.18"
178
+ source = "registry+https://github.com/rust-lang/crates.io-index"
179
+ checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
180
+
181
+ [[package]]
182
+ name = "js-sys"
183
+ version = "0.3.106"
184
+ source = "registry+https://github.com/rust-lang/crates.io-index"
185
+ checksum = "7883d941dae510fb2d978fc3fe018c71c9e2892fd38854de3e8b92c2e5ad9cc5"
186
+ dependencies = [
187
+ "cfg-if",
188
+ "futures-util",
189
+ "wasm-bindgen",
190
+ ]
191
+
134
192
  [[package]]
135
193
  name = "libc"
136
194
  version = "0.2.188"
@@ -143,6 +201,12 @@ version = "0.2.16"
143
201
  source = "registry+https://github.com/rust-lang/crates.io-index"
144
202
  checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981"
145
203
 
204
+ [[package]]
205
+ name = "memchr"
206
+ version = "2.8.3"
207
+ source = "registry+https://github.com/rust-lang/crates.io-index"
208
+ checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
209
+
146
210
  [[package]]
147
211
  name = "once_cell"
148
212
  version = "1.21.4"
@@ -192,6 +256,12 @@ dependencies = [
192
256
  "siphasher",
193
257
  ]
194
258
 
259
+ [[package]]
260
+ name = "pin-project-lite"
261
+ version = "0.2.17"
262
+ source = "registry+https://github.com/rust-lang/crates.io-index"
263
+ checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"
264
+
195
265
  [[package]]
196
266
  name = "portable-atomic"
197
267
  version = "1.14.0"
@@ -317,6 +387,12 @@ dependencies = [
317
387
  "getrandom 0.3.4",
318
388
  ]
319
389
 
390
+ [[package]]
391
+ name = "rustversion"
392
+ version = "1.0.23"
393
+ source = "registry+https://github.com/rust-lang/crates.io-index"
394
+ checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"
395
+
320
396
  [[package]]
321
397
  name = "serde"
322
398
  version = "1.0.229"
@@ -324,6 +400,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
324
400
  checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba"
325
401
  dependencies = [
326
402
  "serde_core",
403
+ "serde_derive",
327
404
  ]
328
405
 
329
406
  [[package]]
@@ -346,12 +423,31 @@ dependencies = [
346
423
  "syn 3.0.2",
347
424
  ]
348
425
 
426
+ [[package]]
427
+ name = "serde_json"
428
+ version = "1.0.154"
429
+ source = "registry+https://github.com/rust-lang/crates.io-index"
430
+ checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6"
431
+ dependencies = [
432
+ "itoa",
433
+ "memchr",
434
+ "serde",
435
+ "serde_core",
436
+ "zmij",
437
+ ]
438
+
349
439
  [[package]]
350
440
  name = "siphasher"
351
441
  version = "1.0.3"
352
442
  source = "registry+https://github.com/rust-lang/crates.io-index"
353
443
  checksum = "8ee5873ec9cce0195efcb7a4e9507a04cd49aec9c83d0389df45b1ef7ba2e649"
354
444
 
445
+ [[package]]
446
+ name = "slab"
447
+ version = "0.4.12"
448
+ source = "registry+https://github.com/rust-lang/crates.io-index"
449
+ checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"
450
+
355
451
  [[package]]
356
452
  name = "syn"
357
453
  version = "2.0.119"
@@ -416,6 +512,51 @@ dependencies = [
416
512
  "wit-bindgen",
417
513
  ]
418
514
 
515
+ [[package]]
516
+ name = "wasm-bindgen"
517
+ version = "0.2.129"
518
+ source = "registry+https://github.com/rust-lang/crates.io-index"
519
+ checksum = "9bb54f33acc68fd454578d9820b0bde1a1a3d17aa17bb7b6595806d02886d409"
520
+ dependencies = [
521
+ "cfg-if",
522
+ "once_cell",
523
+ "rustversion",
524
+ "wasm-bindgen-macro",
525
+ "wasm-bindgen-shared",
526
+ ]
527
+
528
+ [[package]]
529
+ name = "wasm-bindgen-macro"
530
+ version = "0.2.129"
531
+ source = "registry+https://github.com/rust-lang/crates.io-index"
532
+ checksum = "2e29d0c35b16e224a7eeb5cd2d25e3e1968fbd65604117b44d3b789d00ee8535"
533
+ dependencies = [
534
+ "quote",
535
+ "wasm-bindgen-macro-support",
536
+ ]
537
+
538
+ [[package]]
539
+ name = "wasm-bindgen-macro-support"
540
+ version = "0.2.129"
541
+ source = "registry+https://github.com/rust-lang/crates.io-index"
542
+ checksum = "6f501a8bc3719dba86ef8ae4728879c08001bea749eb1333ac5b91e040e2a6b7"
543
+ dependencies = [
544
+ "bumpalo",
545
+ "proc-macro2",
546
+ "quote",
547
+ "syn 3.0.2",
548
+ "wasm-bindgen-shared",
549
+ ]
550
+
551
+ [[package]]
552
+ name = "wasm-bindgen-shared"
553
+ version = "0.2.129"
554
+ source = "registry+https://github.com/rust-lang/crates.io-index"
555
+ checksum = "23f0c9c52aa7cd7d77769a4cfe2a9adb1b331f489a41d912ce14513d5ab995c6"
556
+ dependencies = [
557
+ "unicode-ident",
558
+ ]
559
+
419
560
  [[package]]
420
561
  name = "wit-bindgen"
421
562
  version = "0.46.0"
@@ -441,3 +582,9 @@ dependencies = [
441
582
  "quote",
442
583
  "syn 2.0.119",
443
584
  ]
585
+
586
+ [[package]]
587
+ name = "zmij"
588
+ version = "1.0.23"
589
+ source = "registry+https://github.com/rust-lang/crates.io-index"
590
+ checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "crc-framework-rs"
3
- version = "0.3.0"
3
+ version.workspace = true
4
4
  edition = "2024"
5
5
  rust-version = "1.85"
6
6
  description = "Rust-powered Python bindings for the Climate Risk Commons Framework"
@@ -11,6 +11,9 @@ readme = "README.md"
11
11
  [workspace]
12
12
  members = ["crates/core"]
13
13
 
14
+ [workspace.package]
15
+ version = "0.4.0"
16
+
14
17
  [lib]
15
18
  name = "_core"
16
19
  crate-type = ["cdylib"]