pyrorb 26.11.24.1__py3-none-any.whl
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.
- pyrorb-26.11.24.1.dist-info/METADATA +76 -0
- pyrorb-26.11.24.1.dist-info/RECORD +87 -0
- pyrorb-26.11.24.1.dist-info/WHEEL +5 -0
- pyrorb-26.11.24.1.dist-info/licenses/LICENSE +73 -0
- pyrorb-26.11.24.1.dist-info/top_level.txt +1 -0
- runoff_routing/__init__.py +1 -0
- runoff_routing/_cmd644/__init__.py +5 -0
- runoff_routing/_cmd644/geometry.py +110 -0
- runoff_routing/_cmd644/models.py +60 -0
- runoff_routing/_cmd644/native_diagnostics.py +55 -0
- runoff_routing/_cmd644/power.py +137 -0
- runoff_routing/_cmd644/precision.py +149 -0
- runoff_routing/_cmd644/preparation.py +131 -0
- runoff_routing/_cmd644/reporting.py +214 -0
- runoff_routing/_cmd644/routing.py +369 -0
- runoff_routing/arr_arf.py +338 -0
- runoff_routing/arr_data.py +278 -0
- runoff_routing/arr_design_batch.py +803 -0
- runoff_routing/arr_import.py +432 -0
- runoff_routing/arr_legacy.py +274 -0
- runoff_routing/arr_losses.py +564 -0
- runoff_routing/arr_patterns.py +315 -0
- runoff_routing/arr_report.py +203 -0
- runoff_routing/arr_result_summary.py +665 -0
- runoff_routing/arr_selection.py +148 -0
- runoff_routing/arr_storm.py +146 -0
- runoff_routing/bom_ifd.py +361 -0
- runoff_routing/cmd_deviation.py +106 -0
- runoff_routing/cmd_engine.py +295 -0
- runoff_routing/engine_execution.py +313 -0
- runoff_routing/engine_provenance.py +118 -0
- runoff_routing/engine_types.py +192 -0
- runoff_routing/engineering_batch.py +83 -0
- runoff_routing/integration.py +374 -0
- runoff_routing/integration_reporting.py +102 -0
- runoff_routing/legacy_inputs.py +82 -0
- runoff_routing/mcp_catalog.py +205 -0
- runoff_routing/mcp_reference.py +406 -0
- runoff_routing/mcp_results.py +230 -0
- runoff_routing/mcp_server.py +422 -0
- runoff_routing/mcp_tool_errors.py +89 -0
- runoff_routing/monte_carlo_bridge.py +348 -0
- runoff_routing/monte_carlo_comparison.py +233 -0
- runoff_routing/monte_carlo_effective.py +890 -0
- runoff_routing/monte_carlo_execution.py +855 -0
- runoff_routing/monte_carlo_frequency.py +819 -0
- runoff_routing/monte_carlo_frequency_bridge.py +383 -0
- runoff_routing/monte_carlo_plan.py +932 -0
- runoff_routing/native_cmd.py +453 -0
- runoff_routing/native_export.py +507 -0
- runoff_routing/offline_reference.py +311 -0
- runoff_routing/onset_diagnostics.py +177 -0
- runoff_routing/par_project_import.py +193 -0
- runoff_routing/parity_metrics.py +382 -0
- runoff_routing/project_batch.py +709 -0
- runoff_routing/project_execution.py +172 -0
- runoff_routing/project_json.py +980 -0
- runoff_routing/project_native_review.py +325 -0
- runoff_routing/py.typed +0 -0
- runoff_routing/reach_analysis.py +157 -0
- runoff_routing/reach_routing.py +214 -0
- runoff_routing/reference.py +561 -0
- runoff_routing/reference_compare.py +164 -0
- runoff_routing/regression_dataset.py +974 -0
- runoff_routing/regression_metric_controls.py +111 -0
- runoff_routing/regression_metrics.py +212 -0
- runoff_routing/regression_scalar_adapter.py +103 -0
- runoff_routing/reporting_conventions.py +133 -0
- runoff_routing/rorb_codec.py +984 -0
- runoff_routing/rorb_documents.py +147 -0
- runoff_routing/rorb_ge_authoring.py +310 -0
- runoff_routing/rorb_ge_gis.py +258 -0
- runoff_routing/rorb_ge_profile.py +157 -0
- runoff_routing/rorb_inspect.py +56 -0
- runoff_routing/rorb_model.py +929 -0
- runoff_routing/rorb_out.py +178 -0
- runoff_routing/rorb_par.py +229 -0
- runoff_routing/rorb_readers/__init__.py +1 -0
- runoff_routing/rorb_readers/associations.py +250 -0
- runoff_routing/rorb_readers/output_reader.py +369 -0
- runoff_routing/rorb_readers/parameter_reader.py +178 -0
- runoff_routing/rorb_readers/reader_types.py +139 -0
- runoff_routing/rorb_readers/readers.py +141 -0
- runoff_routing/rorb_readers/result_readers.py +272 -0
- runoff_routing/rorb_report_views.py +109 -0
- runoff_routing/rorbwin_losses.py +80 -0
- runoff_routing/single_storm.py +392 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pyrorb
|
|
3
|
+
Version: 26.11.24.1
|
|
4
|
+
Summary: PyRORB: an in-development Python rainfall-runoff routing implementation
|
|
5
|
+
License-Expression: LicenseRef-SUL-1.0
|
|
6
|
+
Requires-Python: >=3.11
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: typing_extensions>=4.12
|
|
10
|
+
Provides-Extra: mcp
|
|
11
|
+
Requires-Dist: mcp<3,>=2.3; extra == "mcp"
|
|
12
|
+
Provides-Extra: dev
|
|
13
|
+
Requires-Dist: build; extra == "dev"
|
|
14
|
+
Requires-Dist: pytest; extra == "dev"
|
|
15
|
+
Requires-Dist: mcp<3,>=2.3; extra == "dev"
|
|
16
|
+
Requires-Dist: pyright; extra == "dev"
|
|
17
|
+
Requires-Dist: ruff==0.16.6; extra == "dev"
|
|
18
|
+
Provides-Extra: research
|
|
19
|
+
Requires-Dist: scipy>=1.15; extra == "research"
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
|
|
22
|
+
# PyRORB
|
|
23
|
+
|
|
24
|
+
**PyRORB** is an **in-development** Python package for selected RORB rainfall–runoff procedures, including canonical dependency-light RORB report readers maintained in PyRORB. Normal Python runs and the public regression suite require **no private repository and no native RORB executable**. This is not a certified full CMD replacement or a released hydrologic product.
|
|
25
|
+
|
|
26
|
+
The repository and distribution use `pyrorb`; the Python import namespace remains `runoff_routing`. Install from the public checkout below while PyPI publication is deferred. The [naming and compatibility policy](docs/NAMING.md) distinguishes current branding from stable file-format and provenance identifiers.
|
|
27
|
+
|
|
28
|
+
## Install and execute a supplied storm
|
|
29
|
+
|
|
30
|
+
Python **3.11, 3.12, 3.13 or 3.14** (3.14 preferred for development), on **Linux or Windows**, is supported for pure-Python development. From a checkout of [Chain-Frost/pyrorb](https://github.com/Chain-Frost/pyrorb):
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
python -m pip install -r requirements-catg.txt -e ".[dev]"
|
|
34
|
+
python repo-scripts/check_local.py
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
The first command installs the package, development tools and the optional PR-pinned PyRomb writer. To install only the core checkout, use `python -m pip install -e .`; edited CATG export requires the separately installed writer. See [CATG authoring](docs/RORB_GE_AUTHORING.md). the second runs repository, Ruff, strict Pyright and non-native test checks. A virtual environment is optional. For an existing explicit S1 run document, run the checked-in synthetic example:
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
from pathlib import Path
|
|
41
|
+
from runoff_routing.integration import read_run_json, run_model
|
|
42
|
+
|
|
43
|
+
model = read_run_json(Path("examples/synthetic-run.json").read_text(encoding="utf-8"))
|
|
44
|
+
result = run_model(model)
|
|
45
|
+
print(result.to_csv())
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
This executes the supported direct S2 engineering API. Schema-based project and CLI execution uses the temporary `python-cmd` default described below. The example is a software smoke check, not unrestricted native/engineering-accuracy acceptance. See the [quickstart](docs/QUICKSTART.md) for projects, explicit engine selection, batches, installed wheels and reproducible offline regression.
|
|
49
|
+
|
|
50
|
+
## Three selectable product engines
|
|
51
|
+
|
|
52
|
+
| Engine ID | Role | Current main availability |
|
|
53
|
+
| --- | --- | --- |
|
|
54
|
+
| `python-cmd` | **Temporary project/CLI default**, CMD 6.44 compatible arithmetic | Bounded computation and original-source regression; full feature/physical qualification remains under #5. |
|
|
55
|
+
| `python` | Explicit independent engineering implementation; **intended long-term default** | Supported event/batch method, including merged #110/#125 mode-2 and code-2/impervious counterparts; broader accuracy remains separately qualified. |
|
|
56
|
+
| `rorb-cmd` | Explicit optional user-installed native CMD adapter | Verified local executable/configuration and supported inputs; no bundled binary or engine fallback. |
|
|
57
|
+
|
|
58
|
+
Projects preserve the engine/profile separately from rainfall source and method. Historical engine-less schema-1 projects retain `python`; explicitly stored choices never migrate silently. See the [engine contract](docs/ENGINES.md) and [current status](docs/STATUS.md) for supported subsets and acceptance limits.
|
|
59
|
+
|
|
60
|
+
## Development priority
|
|
61
|
+
|
|
62
|
+
The CLI/text-file MVP #119, deterministic rainfall preparation #136/#175, reporting #155 and the import/edit/export/reader programme #138–#143 are **delivered on main**. Current work includes the owner-approved **provisional** Monte Carlo CLI/API/text implementation from [PR #151](https://github.com/Chain-Frost/pyrorb/pull/151). Its reproducible sampling, routed-event and weighted-frequency software is available on main, but RORBwin statistical equivalence, full probability support and design-flood engineering accuracy are **not qualified**. See [method and limitations](docs/MONTE_CARLO.md). [Current status](docs/STATUS.md) and [the backlog](docs/BACKLOG.md) identify remaining work. Advanced #114–#118 and saved RORBwin PAR #144 remain deferred. Deliverables are CLI, Python API and text files; no graphical-interface implementation, design or planning is included.
|
|
63
|
+
|
|
64
|
+
## Regression and outstanding acceptance
|
|
65
|
+
|
|
66
|
+
The [self-contained public regression guide](docs/REGRESSION_DATASET.md) uses one maintained register and comparator. Current bounded original-CMD evidence is **50/50 printed Q cases / 19,550 ordinates**, **48 reporting-scalar passes and two undefined all-zero peak-time incompletes**. The former 14 source exclusions were admitted by #132; 36-case results are historical. Original native gaps, authored controls and unresolved feature/site/physical qualifications remain explicit. `--snapshot` compares historical candidate outputs and does not execute the installed engine. Exact source/wheel receipts are linked from [current status](docs/STATUS.md).
|
|
67
|
+
|
|
68
|
+
The [engineering method and CMD deviation policy](docs/ENGINEERING_METHOD.md), [batch contract](docs/ENGINEERING_BATCHES.md), [single CMD feature matrix](docs/CMD_FEATURE_MATRIX.md) and open [CMD gate #5](https://github.com/Chain-Frost/pyrorb/issues/5) distinguish delivered software from scientific acceptance. Monte Carlo's independently verified software subset is admitted **provisionally**, while [#9](https://github.com/Chain-Frost/pyrorb/issues/9) remains open for native/source/statistical/physical-catchment qualification. The first public release remains separately gated; the reader implementation is now owned by PyRORB, with ryan-tools compatibility imports planned after that release.
|
|
69
|
+
|
|
70
|
+
## Documentation and source custody
|
|
71
|
+
|
|
72
|
+
- [Quickstart and commands](docs/QUICKSTART.md) · [documentation index](docs/README.md) · [development guide](docs/DEVELOPMENT.md) · [source register](docs/SOURCES.md) · [regression policy](docs/REGRESSION.md).
|
|
73
|
+
- Preserve authentic native inputs, original source identities/hashes, exact raw clocks, full horizons and frozen metrics. Approved, path-sanitised public data are versioned test evidence; original and transformed bytes are not interchangeable.
|
|
74
|
+
- The private investigations repository is for agent research only. No executable, manual, restricted capture, client data or private installation path is distributed. The optional RORBwin loss profile is experimental and not the default method. This project is not endorsed by RORB's authors or custodians.
|
|
75
|
+
|
|
76
|
+
Python compatibility: [24 November 2026 migration receipt](docs/work/2026-11-24-python311-compatibility.md).
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
pyrorb-26.11.24.1.dist-info/licenses/LICENSE,sha256=c6MQtnMtFKY24Qpdbc-cpxIv94cO8G36B6hy3bFSdSo,3600
|
|
2
|
+
runoff_routing/__init__.py,sha256=DdD9ndzpoiEtzyQnq1drEFeuL3aI7CmtZ7aE1OElqhE,79
|
|
3
|
+
runoff_routing/arr_arf.py,sha256=d7mlJ9iX_oNh5nSQmGY45GmbUHOSHiNVKzTnIXoWBTI,13940
|
|
4
|
+
runoff_routing/arr_data.py,sha256=mmw7LXc2hcWSAwQiO1bcXz8JZ_xvTQhuIdK3izLDFhs,10977
|
|
5
|
+
runoff_routing/arr_design_batch.py,sha256=Ai991b7DjY_A1grzlwq5sm_Xh0g11vWOUifzTVQX8Yo,34802
|
|
6
|
+
runoff_routing/arr_import.py,sha256=tHZ9lS5r68kOj6hKu_aGBkddLWb8uIbDAgZMXTA4m8s,17911
|
|
7
|
+
runoff_routing/arr_legacy.py,sha256=f5QSiw8liBTMPUe7ivuaTU9kpQaxlpD-qeYtkRe6LNA,11475
|
|
8
|
+
runoff_routing/arr_losses.py,sha256=1Qbv70K8mOj4XA3tfZXlBj8gNdQSCFMb5THsnL3LHVc,25461
|
|
9
|
+
runoff_routing/arr_patterns.py,sha256=lYKr_hQXMkOmq-A03U-bQCwjsC0HVYE33hvrT65jEVM,13365
|
|
10
|
+
runoff_routing/arr_report.py,sha256=ep1uVGanTkVB6c3sSxLnKneeNMdBa6xnv54lZSV8uHE,8009
|
|
11
|
+
runoff_routing/arr_result_summary.py,sha256=nJHUGdR9xvk9A05pYr3x1p-P0EvzHG3eZPq7ZFjGUIU,31032
|
|
12
|
+
runoff_routing/arr_selection.py,sha256=v0qJ1uHePfyuYlDBWU9uc7TOUxZBjNjpa7JP1p_W-rc,5526
|
|
13
|
+
runoff_routing/arr_storm.py,sha256=Aq1UamfaN0T_mSg3-36SVF9gRlTTq6ZMdiSVmEa4qqE,5502
|
|
14
|
+
runoff_routing/bom_ifd.py,sha256=98lLSC0WpVSOLz-qFzPd61g-Jx2mfGiU9-rTPWL6TLs,15425
|
|
15
|
+
runoff_routing/cmd_deviation.py,sha256=FAKcLZQZjwhcIeXqjyod8zVtZZCajj7fUeTeKGwq8do,4392
|
|
16
|
+
runoff_routing/cmd_engine.py,sha256=V_CclcMriIiYMMjGoMVSt-rJF_RmYn54a3Wt9DbR4ng,13691
|
|
17
|
+
runoff_routing/engine_execution.py,sha256=T3uWzVZjFU3IX3IYzeVfF2I_2F5DjMH15Wwk0X_94iQ,13290
|
|
18
|
+
runoff_routing/engine_provenance.py,sha256=lztjCz2VoOd146c8PWH1AUha6W0981DQSMcKalREqq8,5120
|
|
19
|
+
runoff_routing/engine_types.py,sha256=a-apsMy7aivGhFB0Hq80XncTIbTtDjMNFKSMXrgY2vw,7086
|
|
20
|
+
runoff_routing/engineering_batch.py,sha256=qdLZbflsmFbKUGRD5L_AGSr4-YKWrQrDGucVFFmNvYc,3322
|
|
21
|
+
runoff_routing/integration.py,sha256=6Co_WoG6pM1GRfN_uuEvADY14D2n1B0nvx-Gebpup2o,16726
|
|
22
|
+
runoff_routing/integration_reporting.py,sha256=KgBNjhk9B9y2JQLCGsdO2qLCJykUS1QU-7bgRHi63ZM,4296
|
|
23
|
+
runoff_routing/legacy_inputs.py,sha256=J-v6KYqvpxhtRYb70AOg7OgI6Y1AEVhbUF-mxzFV-VI,3396
|
|
24
|
+
runoff_routing/mcp_catalog.py,sha256=jSWHSySujMLG9zjwyYagcCDjGXF58Tjpo_FIJPPTpMQ,7241
|
|
25
|
+
runoff_routing/mcp_reference.py,sha256=mVFEG9TJfnqEBPc063nvKchvafAIfUeTOHtz9PRDyQU,17239
|
|
26
|
+
runoff_routing/mcp_results.py,sha256=FPjLQ_AO8NQavnUjZTIO9p5t9bSfUJ8FFc-NUzAmO3w,9059
|
|
27
|
+
runoff_routing/mcp_server.py,sha256=_O8uqY0Qort6hfH60ulzPSVulvwEARr3y1830J1KqEQ,19273
|
|
28
|
+
runoff_routing/mcp_tool_errors.py,sha256=9QcjpgK6GfWgUq-yIGKrArr0pCztVezU2SDFcAChQPE,4128
|
|
29
|
+
runoff_routing/monte_carlo_bridge.py,sha256=NKN2AZOkP4_6iBmo6n2vnCDNrM6xtshQTodDCr4TfV4,13211
|
|
30
|
+
runoff_routing/monte_carlo_comparison.py,sha256=QYN4GXFeHK-STVPF1g6dvm_xoZkjoddbmh3xwisgh7g,9284
|
|
31
|
+
runoff_routing/monte_carlo_effective.py,sha256=nSBAgO93pCUc3bUz5OOCH8BwTFU4mLvkLUX0UEx3AOI,39835
|
|
32
|
+
runoff_routing/monte_carlo_execution.py,sha256=owg6byuMLt60epM1zI4QJX3dKbOjZ3jFHJcdd_ZpnpI,36698
|
|
33
|
+
runoff_routing/monte_carlo_frequency.py,sha256=WdCiTE4ZD1tVcbFbSHjIl9e9gp84-Z-G-VojOINHE9Y,32901
|
|
34
|
+
runoff_routing/monte_carlo_frequency_bridge.py,sha256=9G6xCeh63z0gnzO5abeCKwwK-rXGaY6n5Mm0pH0SRaE,15846
|
|
35
|
+
runoff_routing/monte_carlo_plan.py,sha256=LTb62Va6PMEocjV0pE8GvY1FI2QW1v11x9Kwj1gp7tw,42194
|
|
36
|
+
runoff_routing/native_cmd.py,sha256=vyV7eWT6SXx73U7akTJ8tUZZ2_svJZeILMNSUWSm_Cg,21914
|
|
37
|
+
runoff_routing/native_export.py,sha256=JSkw8wgkMQKPwjebEZv4f2P3g-kS_6O0-Pv0Pl1HCEk,22233
|
|
38
|
+
runoff_routing/offline_reference.py,sha256=-w1h5PuG6UhqQGilrvbJuBzhT1GE75_DCvPYMrDO120,13508
|
|
39
|
+
runoff_routing/onset_diagnostics.py,sha256=bZwMk2Iq-FhDdMkgQ3Bw7kjJ66OFfxj14EkR7J_B1wo,7463
|
|
40
|
+
runoff_routing/par_project_import.py,sha256=ukcAixqIJYi04dTROxnokrtRJiYIWa3zXlnc4oIE7-0,8289
|
|
41
|
+
runoff_routing/parity_metrics.py,sha256=0VjuQZABvbxrGq7dROAW5hembebIhNVJqNUhCtFhtt8,15870
|
|
42
|
+
runoff_routing/project_batch.py,sha256=H8L26aG3EfTpLESv3aZKqeooAyzTVoJsSzT0CMH-1DY,29681
|
|
43
|
+
runoff_routing/project_execution.py,sha256=WWUKoIKaZ008yfW4afXdeUy1mlgTm7hCPVQB8mefECU,7336
|
|
44
|
+
runoff_routing/project_json.py,sha256=v5lbJo3yBSc39zx6K37zytJ80jm-xG0GPPXIYSipO7c,40669
|
|
45
|
+
runoff_routing/project_native_review.py,sha256=KK-B6HWZb-GRW3PUN4LGukj3FiI7kHvJ9sD7iSX-Si8,14948
|
|
46
|
+
runoff_routing/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
47
|
+
runoff_routing/reach_analysis.py,sha256=CaIXNhUZTLE9t4BBu6gPIr4kmiM4f-OjmLhlwvuwRo4,6641
|
|
48
|
+
runoff_routing/reach_routing.py,sha256=kiSjkta-rBAcY5CydJYMzvOBEcewE-D3gGF8u0IGmq4,7872
|
|
49
|
+
runoff_routing/reference.py,sha256=xs1xaar0VVDDk1f89jx7joKCv9Yk_6fXYX3m6vzV98U,25713
|
|
50
|
+
runoff_routing/reference_compare.py,sha256=JZWg3kDLfI6Q05IULLfuXE7yV5ips844fzGZnhm3dxg,7139
|
|
51
|
+
runoff_routing/regression_dataset.py,sha256=Of2NUHB5cDTQotvufDQVfb69lZ9AVhC8hxtfJq9bcZA,45153
|
|
52
|
+
runoff_routing/regression_metric_controls.py,sha256=bw-Piy-WRc4yg-CsQE5Rl-9tTXBEt2vPlf5db4kMknI,4876
|
|
53
|
+
runoff_routing/regression_metrics.py,sha256=qoZ6Sfu1CRGfNziAXa1Ipbvmb0kNrV0PIQuk7q_aonQ,9509
|
|
54
|
+
runoff_routing/regression_scalar_adapter.py,sha256=lhVkLaGlcmK4tJscv8PoNy2K9xn0lZJg1ZpzTcOFFCE,4621
|
|
55
|
+
runoff_routing/reporting_conventions.py,sha256=flndLXFFYAFZzWaw9vQUImLJR8Xn__3Q1lffA1oRvhw,6016
|
|
56
|
+
runoff_routing/rorb_codec.py,sha256=W7DWD5JULPN3Kx5sshykVLGf3MZ3ETjIFIYSB-iDicE,45207
|
|
57
|
+
runoff_routing/rorb_documents.py,sha256=49Y7XhwTLmLjCPF9XcNmAaBDo2kVL43eOnKjz5UExYs,3995
|
|
58
|
+
runoff_routing/rorb_ge_authoring.py,sha256=QyBzE_wcex24p7jHAQ0c8pj_6GDBXWQq89oN4e6kkdc,14163
|
|
59
|
+
runoff_routing/rorb_ge_gis.py,sha256=qM0wsdpdgxP8675mSo8M3sqDffrwK1CFhCN5eeYfPVg,10737
|
|
60
|
+
runoff_routing/rorb_ge_profile.py,sha256=hb5Vo0QeqIHbpka7B0NE4QdVMno1F5WYPiL3TzQGdNs,5699
|
|
61
|
+
runoff_routing/rorb_inspect.py,sha256=5-ZLMoV9IBUWVZr58C5IurhW4V5XcVjcWu-_6shdYJ0,2521
|
|
62
|
+
runoff_routing/rorb_model.py,sha256=4hXf50vshBTMnQcGkYlek9k5q03f6heHN8CJA9hkSuo,36035
|
|
63
|
+
runoff_routing/rorb_out.py,sha256=5dTbBpme1p2Yobv9BNrwkYMk3CkzNhQ4JAN4pOc70BM,8607
|
|
64
|
+
runoff_routing/rorb_par.py,sha256=S7CFPCQCF5eP2biRUsOyW2r8ieyXvBl02ulEtwjX06k,9110
|
|
65
|
+
runoff_routing/rorb_report_views.py,sha256=InTwGgY_kQpRGyMq4xEkRPeBn0oeAO6w5Jmv4lrdCjI,4536
|
|
66
|
+
runoff_routing/rorbwin_losses.py,sha256=O91cPoZJ959rCqoLdrtKgrP6FeiC2RqV3by8zsOhX1I,3412
|
|
67
|
+
runoff_routing/single_storm.py,sha256=Z-Njo35Z7bshdL5mx_rI5EI0_ZdFSy7R1p0EuEoAuwk,18012
|
|
68
|
+
runoff_routing/_cmd644/__init__.py,sha256=h_NNTR79ty_f8-T6_chIvazEknSgnCAPhEACdwYIIe8,231
|
|
69
|
+
runoff_routing/_cmd644/geometry.py,sha256=rOkrLQxfzthd7_5opaVZpbOvpC7UBaSqnBw7HGsi5pA,4570
|
|
70
|
+
runoff_routing/_cmd644/models.py,sha256=IOG361sRFHgT95TiCHHrh2XhUwwnpCR2aUgBF1Ulcj8,1563
|
|
71
|
+
runoff_routing/_cmd644/native_diagnostics.py,sha256=uKpDjXovF_yCl6cMBAQ0GqButN07GHBMA6SZLo0FSW4,1953
|
|
72
|
+
runoff_routing/_cmd644/power.py,sha256=5Az4jG86yjZmJR2DC-wyjXqC2wPwdg5rPKWBMZscflo,5238
|
|
73
|
+
runoff_routing/_cmd644/precision.py,sha256=nVEgr1b0tbadtdodOCXHRYfdtTHsTXXYj7Y_JnJOjJ0,5189
|
|
74
|
+
runoff_routing/_cmd644/preparation.py,sha256=8yYL7JrUS7o05rNvIj3OLvwz6d0vnM4onm49bATluuA,5074
|
|
75
|
+
runoff_routing/_cmd644/reporting.py,sha256=mTOyOa279elqDnOnR6Kgg2CJSRgKaCOWMl8fIg6q1GA,8969
|
|
76
|
+
runoff_routing/_cmd644/routing.py,sha256=FG1sLkGAIGWFY4WObegRCFIuwlpqInE9irZmKFNFiR8,13594
|
|
77
|
+
runoff_routing/rorb_readers/__init__.py,sha256=nkAP6l8K9KvKkpcQr7gLipP19CLvab1Ke2v6MtELyUM,75
|
|
78
|
+
runoff_routing/rorb_readers/associations.py,sha256=cPhO0BAW-SP7TN4C4TBH8fgm8JVcBirk5sRhN5OpHWk,12496
|
|
79
|
+
runoff_routing/rorb_readers/output_reader.py,sha256=ClFydAi5w6kmXtqrGAt8eQfOMAynOFDecSJ3nE2yktw,17320
|
|
80
|
+
runoff_routing/rorb_readers/parameter_reader.py,sha256=uq5zfedVo_MVeGoDhvfEXJPQjbFdO02VkEERyKOMAFY,8107
|
|
81
|
+
runoff_routing/rorb_readers/reader_types.py,sha256=fBcVvZNDbP5rrCWAz83BIhOK56jXVV8WDRJ3BgIZVtA,5404
|
|
82
|
+
runoff_routing/rorb_readers/readers.py,sha256=6ZDNjvfsWrP8hCST6SZ5JuE4Hbx5kP1Nf4vZyR_9AmE,5739
|
|
83
|
+
runoff_routing/rorb_readers/result_readers.py,sha256=kqfmiQWs33H-Yw5On7-v_uVmeGR-Tv7q8eTBi54KUQA,13530
|
|
84
|
+
pyrorb-26.11.24.1.dist-info/METADATA,sha256=FhWK0jHUpI5HGdY2zuJ5DF19q__Ksw0-G56VjrerapU,7094
|
|
85
|
+
pyrorb-26.11.24.1.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
86
|
+
pyrorb-26.11.24.1.dist-info/top_level.txt,sha256=YkSYeiQmsv52WfXjToiMmLGBZ3HUZt64j_UKChYrKqY,15
|
|
87
|
+
pyrorb-26.11.24.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
Sustainable Use License
|
|
2
|
+
|
|
3
|
+
Version 1.0
|
|
4
|
+
|
|
5
|
+
Acceptance
|
|
6
|
+
|
|
7
|
+
By using the software, you agree to all of the terms and conditions below.
|
|
8
|
+
|
|
9
|
+
Copyright License
|
|
10
|
+
|
|
11
|
+
The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license
|
|
12
|
+
to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject
|
|
13
|
+
to the limitations below.
|
|
14
|
+
|
|
15
|
+
Limitations
|
|
16
|
+
|
|
17
|
+
You may use or modify the software only for your own internal business purposes or for non-commercial or
|
|
18
|
+
personal use. You may distribute the software or provide it to others only if you do so free of charge for
|
|
19
|
+
non-commercial purposes. You may not alter, remove, or obscure any licensing, copyright, or other notices of
|
|
20
|
+
the licensor in the software. Any use of the licensor’s trademarks is subject to applicable law.
|
|
21
|
+
|
|
22
|
+
Patents
|
|
23
|
+
|
|
24
|
+
The licensor grants you a license, under any patent claims the licensor can license, or becomes able to
|
|
25
|
+
license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case
|
|
26
|
+
subject to the limitations and conditions in this license. This license does not cover any patent claims that
|
|
27
|
+
you cause to be infringed by modifications or additions to the software. If you or your company make any
|
|
28
|
+
written claim that the software infringes or contributes to infringement of any patent, your patent license
|
|
29
|
+
for the software granted under these terms ends immediately. If your company makes such a claim, your patent
|
|
30
|
+
license ends immediately for work on behalf of your company.
|
|
31
|
+
|
|
32
|
+
Notices
|
|
33
|
+
|
|
34
|
+
You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these
|
|
35
|
+
terms. If you modify the software, you must include in any modified copies of the software a prominent notice
|
|
36
|
+
stating that you have modified the software.
|
|
37
|
+
|
|
38
|
+
No Other Rights
|
|
39
|
+
|
|
40
|
+
These terms do not imply any licenses other than those expressly granted in these terms.
|
|
41
|
+
|
|
42
|
+
Termination
|
|
43
|
+
|
|
44
|
+
If you use the software in violation of these terms, such use is not licensed, and your license will
|
|
45
|
+
automatically terminate. If the licensor provides you with a notice of your violation, and you cease all
|
|
46
|
+
violation of this license no later than 30 days after you receive that notice, your license will be reinstated
|
|
47
|
+
retroactively. However, if you violate these terms after such reinstatement, any additional violation of these
|
|
48
|
+
terms will cause your license to terminate automatically and permanently.
|
|
49
|
+
|
|
50
|
+
No Liability
|
|
51
|
+
|
|
52
|
+
As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will
|
|
53
|
+
not be liable to you for any damages arising out of these terms or the use or nature of the software, under
|
|
54
|
+
any kind of legal claim.
|
|
55
|
+
|
|
56
|
+
Definitions
|
|
57
|
+
|
|
58
|
+
The “licensor” is the entity offering these terms.
|
|
59
|
+
|
|
60
|
+
The “software” is the software the licensor makes available under these terms, including any portion of it.
|
|
61
|
+
|
|
62
|
+
“You” refers to the individual or entity agreeing to these terms.
|
|
63
|
+
|
|
64
|
+
“Your company” is any legal entity, sole proprietorship, or other kind of organization that you work for, plus
|
|
65
|
+
all organizations that have control over, are under the control of, or are under common control with that
|
|
66
|
+
organization. Control means ownership of substantially all the assets of an entity, or the power to direct its
|
|
67
|
+
management and policies by vote, contract, or otherwise. Control can be direct or indirect.
|
|
68
|
+
|
|
69
|
+
“Your license” is the license granted to you for the software under these terms.
|
|
70
|
+
|
|
71
|
+
“Use” means anything you do with the software requiring your license.
|
|
72
|
+
|
|
73
|
+
“Trademark” means trademarks, service marks, and similar rights.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
runoff_routing
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""PyRORB's Python API, retained under the runoff_routing import namespace."""
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"""Ordered source membership geometry and odd/even p53 weighted-distance rule."""
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from fractions import Fraction
|
|
5
|
+
|
|
6
|
+
from .models import Event
|
|
7
|
+
from .precision import UnsupportedNumericPath, add53, div53, fraction, mul53, store_rational
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@dataclass(frozen=True, slots=True)
|
|
11
|
+
class ReachGeometry:
|
|
12
|
+
"""Coefficient values for a reach in original encounter order."""
|
|
13
|
+
|
|
14
|
+
reach_id: int
|
|
15
|
+
length_km: float
|
|
16
|
+
relative_delay: float
|
|
17
|
+
coefficient: float
|
|
18
|
+
coefficient_seconds: float
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@dataclass(frozen=True, slots=True)
|
|
22
|
+
class Geometry:
|
|
23
|
+
"""Whole-event mean and reach coefficients from stored input geometry."""
|
|
24
|
+
|
|
25
|
+
distances: tuple[float, ...]
|
|
26
|
+
total_area: float
|
|
27
|
+
weighted_total: float
|
|
28
|
+
mean_distance: float
|
|
29
|
+
reaches: tuple[ReachGeometry, ...]
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def _source_distances(event: Event) -> tuple[list[float], list[float]]:
|
|
33
|
+
"""Compute C11-C13 geometry without changing the control evaluation order."""
|
|
34
|
+
distances = [0.0] * event.source_count
|
|
35
|
+
active: set[int] | None = None
|
|
36
|
+
branches: list[set[int]] = []
|
|
37
|
+
reach_lengths: list[float] = []
|
|
38
|
+
source = 0
|
|
39
|
+
for control in event.controls:
|
|
40
|
+
code = control.code
|
|
41
|
+
if code == 2 and active is None:
|
|
42
|
+
message = "code-2 source needs an existing running hydrograph"
|
|
43
|
+
raise UnsupportedNumericPath(message)
|
|
44
|
+
if code in (1, 2):
|
|
45
|
+
if active is None:
|
|
46
|
+
active = set()
|
|
47
|
+
active.add(source)
|
|
48
|
+
source += 1
|
|
49
|
+
elif code == 3:
|
|
50
|
+
active = _active_sources(active)
|
|
51
|
+
branches.append(active.copy())
|
|
52
|
+
active = None
|
|
53
|
+
elif code == 4:
|
|
54
|
+
active = _active_sources(active)
|
|
55
|
+
active.update(branches.pop())
|
|
56
|
+
if code in (1, 2, 5):
|
|
57
|
+
active = _active_sources(active)
|
|
58
|
+
length = control.length.stored
|
|
59
|
+
reach_lengths.append(length)
|
|
60
|
+
for index in sorted(active):
|
|
61
|
+
distances[index] = store_rational(add53(fraction(distances[index]), fraction(length)))
|
|
62
|
+
return distances, reach_lengths
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def compute_geometry(event: Event) -> Geometry: # noqa: C901 -- bounded zero terminal copy guard
|
|
66
|
+
"""Compute stored coefficients in the original arithmetic order."""
|
|
67
|
+
distances, reach_lengths = _source_distances(event)
|
|
68
|
+
if not all(x > 0 for x in distances):
|
|
69
|
+
message = "nonpositive source-to-outlet distance"
|
|
70
|
+
raise UnsupportedNumericPath(message)
|
|
71
|
+
area_total = 0.0
|
|
72
|
+
for area in event.areas:
|
|
73
|
+
area_total = store_rational(add53(fraction(area_total), fraction(area.stored)))
|
|
74
|
+
if area_total <= 0:
|
|
75
|
+
message = "nonpositive total area after store"
|
|
76
|
+
raise UnsupportedNumericPath(message)
|
|
77
|
+
even = event.source_count - (event.source_count % 2)
|
|
78
|
+
weighted = Fraction()
|
|
79
|
+
for index in range(even):
|
|
80
|
+
weighted = add53(weighted, mul53(fraction(event.areas[index].stored), fraction(distances[index])))
|
|
81
|
+
weighted_store = store_rational(weighted)
|
|
82
|
+
if even < event.source_count:
|
|
83
|
+
last_product = mul53(fraction(event.areas[-1].stored), fraction(distances[-1]))
|
|
84
|
+
weighted_store = store_rational(add53(fraction(weighted_store), last_product))
|
|
85
|
+
mean = store_rational(div53(fraction(weighted_store), fraction(area_total)))
|
|
86
|
+
if mean <= 0:
|
|
87
|
+
message = "nonpositive stored mean source distance"
|
|
88
|
+
raise UnsupportedNumericPath(message)
|
|
89
|
+
inverse = div53(Fraction(1), fraction(mean))
|
|
90
|
+
reaches: list[ReachGeometry] = []
|
|
91
|
+
for reach_id, length in enumerate(reach_lengths, 1):
|
|
92
|
+
relative = store_rational(mul53(fraction(length), inverse))
|
|
93
|
+
coefficient = store_rational(mul53(fraction(event.kc.stored), fraction(relative)))
|
|
94
|
+
seconds = store_rational(mul53(fraction(coefficient), Fraction(3600)))
|
|
95
|
+
if length == 0.0:
|
|
96
|
+
if relative != 0.0 or coefficient != 0.0 or seconds != 0.0:
|
|
97
|
+
message = f"reach {reach_id}: zero-length coefficient mismatch"
|
|
98
|
+
raise UnsupportedNumericPath(message)
|
|
99
|
+
elif min(relative, coefficient, seconds) <= 0:
|
|
100
|
+
message = f"reach {reach_id}: positive coefficient underflow"
|
|
101
|
+
raise UnsupportedNumericPath(message)
|
|
102
|
+
reaches.append(ReachGeometry(reach_id, length, relative, coefficient, seconds))
|
|
103
|
+
return Geometry(tuple(distances), area_total, weighted_store, mean, tuple(reaches))
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def _active_sources(active: set[int] | None) -> set[int]:
|
|
107
|
+
if active is None:
|
|
108
|
+
message = "geometry requires an active source branch"
|
|
109
|
+
raise UnsupportedNumericPath(message)
|
|
110
|
+
return active
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"""Immutable typed computational event and domain errors."""
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from typing import Literal
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class InvalidInputError(ValueError):
|
|
8
|
+
"""Typed JSON event violates the declared structural or physical input contract."""
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
# Preserve the submitted public exception import and catch identity.
|
|
12
|
+
InvalidInput = InvalidInputError
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@dataclass(frozen=True, slots=True)
|
|
16
|
+
class NumberInput:
|
|
17
|
+
"""Original decimal numeric token and the admitted binary64 -> binary32 value."""
|
|
18
|
+
|
|
19
|
+
lexeme: str
|
|
20
|
+
binary64: float
|
|
21
|
+
stored: float
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@dataclass(frozen=True, slots=True)
|
|
25
|
+
class Control:
|
|
26
|
+
"""Input-order control, with original numeric length identity."""
|
|
27
|
+
|
|
28
|
+
code: int
|
|
29
|
+
length: NumberInput
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@dataclass(frozen=True, slots=True)
|
|
33
|
+
class Event:
|
|
34
|
+
"""One ordinary start-zero event, including original input text and identity."""
|
|
35
|
+
|
|
36
|
+
event_id: str
|
|
37
|
+
input_sha256: str
|
|
38
|
+
original_json: str
|
|
39
|
+
controls: tuple[Control, ...]
|
|
40
|
+
areas: tuple[NumberInput, ...]
|
|
41
|
+
depths: tuple[NumberInput, ...]
|
|
42
|
+
impervious: tuple[NumberInput, ...]
|
|
43
|
+
weights: tuple[NumberInput, ...]
|
|
44
|
+
h: NumberInput
|
|
45
|
+
kc: NumberInput
|
|
46
|
+
m: NumberInput
|
|
47
|
+
il: NumberInput
|
|
48
|
+
cl: NumberInput
|
|
49
|
+
n: int
|
|
50
|
+
loss_model: Literal[1, 2] = 1
|
|
51
|
+
|
|
52
|
+
@property
|
|
53
|
+
def source_count(self) -> int:
|
|
54
|
+
"""Number of code-1 records in original encounter order."""
|
|
55
|
+
return len(self.areas)
|
|
56
|
+
|
|
57
|
+
@property
|
|
58
|
+
def reach_count(self) -> int:
|
|
59
|
+
"""Number of code-1 and code-5 reaches."""
|
|
60
|
+
return sum(control.code in (1, 2, 5) for control in self.controls)
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"""Explicit native target view; the frozen v6 target and numerical state stay intact.
|
|
2
|
+
|
|
3
|
+
The m=0 dry shortcut emits a model trace placeholder, whereas retained CMD records
|
|
4
|
+
contain the continuity target with constant storage. This view reports both values.
|
|
5
|
+
It is not a replacement routing step or permission to change the v6 fixture schema.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from dataclasses import dataclass
|
|
9
|
+
from typing import Literal
|
|
10
|
+
|
|
11
|
+
from .precision import safe64
|
|
12
|
+
|
|
13
|
+
DIAGNOSTIC_PROFILE = "cmd644-native-target-diagnostics-v1"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@dataclass(frozen=True, slots=True)
|
|
17
|
+
class TargetOperands:
|
|
18
|
+
"""Actual emitted candidate operands; durations are stored seconds."""
|
|
19
|
+
|
|
20
|
+
sample_index: int
|
|
21
|
+
exponent: float
|
|
22
|
+
previous_q: float
|
|
23
|
+
previous_s: float
|
|
24
|
+
previous_i: float
|
|
25
|
+
current_i: float
|
|
26
|
+
duration_seconds: float
|
|
27
|
+
model_target: float
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@dataclass(frozen=True, slots=True)
|
|
31
|
+
class TargetDiagnostic:
|
|
32
|
+
"""Distinct historical model and native-continuity diagnostic identities."""
|
|
33
|
+
|
|
34
|
+
sample_index: int
|
|
35
|
+
model_target: float
|
|
36
|
+
native_compatibility_target: float
|
|
37
|
+
basis: Literal["v6-model-target", "m0-dry-continuity"]
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def target_diagnostic(operands: TargetOperands) -> TargetDiagnostic:
|
|
41
|
+
"""Interpret the dry m=0 target without mutating or rerouting accepted states.
|
|
42
|
+
|
|
43
|
+
Only the existing m=0 dry shortcut is projected. All other targets are preserved
|
|
44
|
+
directly from the actual calculation, including clamping and precision decisions.
|
|
45
|
+
"""
|
|
46
|
+
dry_constant_storage = (
|
|
47
|
+
operands.exponent == 0.0
|
|
48
|
+
and operands.previous_q == 0.0
|
|
49
|
+
and operands.previous_i == 0.0
|
|
50
|
+
and operands.current_i == 0.0
|
|
51
|
+
)
|
|
52
|
+
if dry_constant_storage:
|
|
53
|
+
target = max(0.0, safe64(operands.previous_s / operands.duration_seconds))
|
|
54
|
+
return TargetDiagnostic(operands.sample_index, operands.model_target, target, "m0-dry-continuity")
|
|
55
|
+
return TargetDiagnostic(operands.sample_index, operands.model_target, operands.model_target, "v6-model-target")
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"""Research-exposed bounded power approximation with exact documented constants.
|
|
2
|
+
|
|
3
|
+
This is an independently authored transcription of the owner-approved v2 operation
|
|
4
|
+
contract; it is not native source, general-purpose pow, or clean-room decoding.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import math
|
|
8
|
+
import struct
|
|
9
|
+
from fractions import Fraction
|
|
10
|
+
from functools import lru_cache
|
|
11
|
+
|
|
12
|
+
from .precision import (
|
|
13
|
+
UnsupportedNumericPath,
|
|
14
|
+
add53,
|
|
15
|
+
div53,
|
|
16
|
+
fraction,
|
|
17
|
+
internal_store,
|
|
18
|
+
internal_store_rational,
|
|
19
|
+
mul53,
|
|
20
|
+
store,
|
|
21
|
+
sub53,
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
_TABLE_RATIOS: tuple[tuple[int, int], ...] = (
|
|
25
|
+
(1, 1),
|
|
26
|
+
(2351495508712263, 2251799813685248),
|
|
27
|
+
(613901277312157, 562949953421312),
|
|
28
|
+
(1282162017789723, 1125899906842624),
|
|
29
|
+
(5355712719980343, 4503599627370496),
|
|
30
|
+
(5592830379685591, 4503599627370496),
|
|
31
|
+
(1460111533770265, 1125899906842624),
|
|
32
|
+
(6099024776563411, 4503599627370496),
|
|
33
|
+
(3184525836255917, 2251799813685248),
|
|
34
|
+
(3325516840273195, 2251799813685248),
|
|
35
|
+
(6945500098643221, 4503599627370496),
|
|
36
|
+
(3626501829426903, 2251799813685248),
|
|
37
|
+
(946765195599901, 562949953421312),
|
|
38
|
+
(7909456575010961, 4503599627370496),
|
|
39
|
+
(1032454766818819, 562949953421312),
|
|
40
|
+
(8625323556258569, 4503599627370496),
|
|
41
|
+
)
|
|
42
|
+
TABLE = tuple(Fraction(a, b) for a, b in _TABLE_RATIOS)
|
|
43
|
+
LOG_C = (
|
|
44
|
+
Fraction(6004812949407949, 9007199254740992),
|
|
45
|
+
Fraction(225038089494995, 562949953421312),
|
|
46
|
+
Fraction(5390925971852145, 18014398509481984),
|
|
47
|
+
)
|
|
48
|
+
LOG_FACTOR = Fraction(1624330212139199, 1125899906842624)
|
|
49
|
+
EXP_C = (
|
|
50
|
+
Fraction(6243314764586391, 9007199254740992),
|
|
51
|
+
Fraction(8655072069380201, 36028797018963968),
|
|
52
|
+
Fraction(7999219623028855, 144115188075855872),
|
|
53
|
+
Fraction(1386091390059765, 144115188075855872),
|
|
54
|
+
)
|
|
55
|
+
MAGIC = Fraction(422212465065984)
|
|
56
|
+
EXPONENT = store(0.8)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def _split_normalized(base: float) -> tuple[Fraction, int]:
|
|
60
|
+
"""Perform the specified integer high/low-word normalisation."""
|
|
61
|
+
encoded = int.from_bytes(struct.pack("<d", base), "little", signed=False)
|
|
62
|
+
low_word = encoded & 0xFFFFFFFF
|
|
63
|
+
high_word = encoded >> 32
|
|
64
|
+
field = high_word & 0x7FF00000
|
|
65
|
+
displacement = field - 0x3FE00000 - ((high_word - 0x6A09E - field) & 0x100000)
|
|
66
|
+
updated_high = (high_word - displacement) & 0xFFFFFFFF
|
|
67
|
+
updated_bits = (updated_high << 32) | low_word
|
|
68
|
+
normalized = struct.unpack("<d", updated_bits.to_bytes(8, "little", signed=False))[0]
|
|
69
|
+
return fraction(normalized), displacement >> 20
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def _scaled_log(base: float, exponent: float) -> Fraction:
|
|
73
|
+
"""Construct the p53 logarithmic exponent product without transcendentals."""
|
|
74
|
+
normalized, order = _split_normalized(base)
|
|
75
|
+
delta = sub53(normalized, Fraction(1))
|
|
76
|
+
ratio = div53(delta, add53(normalized, Fraction(1)))
|
|
77
|
+
square = mul53(ratio, ratio)
|
|
78
|
+
p0, p1, p2 = LOG_C
|
|
79
|
+
poly = mul53(add53(mul53(p2, square), p1), square)
|
|
80
|
+
poly = add53(poly, p0)
|
|
81
|
+
y = fraction(exponent)
|
|
82
|
+
scale_y = mul53(y, LOG_FACTOR)
|
|
83
|
+
odd = mul53(mul53(square, ratio), scale_y)
|
|
84
|
+
odd = mul53(poly, odd)
|
|
85
|
+
correction = mul53(sub53(mul53(delta, ratio), delta), scale_y)
|
|
86
|
+
return sub53(odd, sub53(correction, mul53(y, Fraction(order))))
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def bounded_power(base: float, exponent: float) -> float:
|
|
90
|
+
"""Calculate P(base, exponent) for the exact bounded binary32 domain."""
|
|
91
|
+
if (
|
|
92
|
+
not math.isfinite(exponent)
|
|
93
|
+
or exponent < 0
|
|
94
|
+
or store(exponent) != exponent
|
|
95
|
+
or not math.isfinite(base)
|
|
96
|
+
or base < 0
|
|
97
|
+
):
|
|
98
|
+
message = "power helper exponent/base outside supported domain"
|
|
99
|
+
raise UnsupportedNumericPath(message)
|
|
100
|
+
if internal_store(base) != base:
|
|
101
|
+
message = "power base must be previously stored binary32"
|
|
102
|
+
raise UnsupportedNumericPath(message)
|
|
103
|
+
return _power_stored(base, exponent)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
@lru_cache(maxsize=32768)
|
|
107
|
+
def _power_stored(base: float, exponent: float) -> float:
|
|
108
|
+
"""Core bounded helper with native-like integer and early-zero branches."""
|
|
109
|
+
if exponent == 0:
|
|
110
|
+
return 1.0 # Including 0**0 under this specifically bounded contract.
|
|
111
|
+
if base == 0:
|
|
112
|
+
return 0.0
|
|
113
|
+
if exponent in (1, 2, 3, 4, 5, 6, 7):
|
|
114
|
+
carried = base
|
|
115
|
+
for _ in range(1, int(exponent)):
|
|
116
|
+
carried = internal_store(carried * base)
|
|
117
|
+
return carried
|
|
118
|
+
exponent_product = _scaled_log(base, exponent)
|
|
119
|
+
if exponent_product < -127:
|
|
120
|
+
return 0.0
|
|
121
|
+
if exponent_product >= 128:
|
|
122
|
+
message = "power helper logarithmic product outside ordinary range"
|
|
123
|
+
raise UnsupportedNumericPath(message)
|
|
124
|
+
magic_plus = add53(exponent_product, MAGIC)
|
|
125
|
+
low = int.from_bytes(struct.pack("<d", float(magic_plus)), "little") & 0xFFFFFFFF
|
|
126
|
+
position = low & 0xF
|
|
127
|
+
leftover = add53(sub53(MAGIC, magic_plus), exponent_product)
|
|
128
|
+
top_word = (((low - position) << 16) + 0x3FF00000) & 0xFFFFFFFF
|
|
129
|
+
scale_bits = top_word << 32
|
|
130
|
+
scale = fraction(struct.unpack("<d", scale_bits.to_bytes(8, "little"))[0])
|
|
131
|
+
c0, c1, c2, c3 = EXP_C
|
|
132
|
+
curve_high = mul53(add53(mul53(c3, leftover), c2), mul53(leftover, leftover))
|
|
133
|
+
curve_low = add53(mul53(c1, leftover), c0)
|
|
134
|
+
polynomial = add53(curve_low, curve_high)
|
|
135
|
+
polynomial = mul53(polynomial, mul53(leftover, TABLE[position]))
|
|
136
|
+
polynomial = add53(polynomial, TABLE[position])
|
|
137
|
+
return internal_store_rational(mul53(polynomial, scale))
|