unibm 0.1.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.
- unibm-0.1.0/.gitignore +108 -0
- unibm-0.1.0/LICENSE +21 -0
- unibm-0.1.0/PKG-INFO +187 -0
- unibm-0.1.0/README.md +158 -0
- unibm-0.1.0/pyproject.toml +108 -0
- unibm-0.1.0/src/unibm/__about__.py +3 -0
- unibm-0.1.0/src/unibm/__init__.py +39 -0
- unibm-0.1.0/src/unibm/_block_grid.py +83 -0
- unibm-0.1.0/src/unibm/_bootstrap_precision.py +124 -0
- unibm-0.1.0/src/unibm/_bootstrap_sampling.py +90 -0
- unibm-0.1.0/src/unibm/_numeric.py +17 -0
- unibm-0.1.0/src/unibm/_runtime.py +61 -0
- unibm-0.1.0/src/unibm/_validation.py +265 -0
- unibm-0.1.0/src/unibm/_window_ops.py +111 -0
- unibm-0.1.0/src/unibm/cdf.py +77 -0
- unibm-0.1.0/src/unibm/ei/__init__.py +66 -0
- unibm-0.1.0/src/unibm/ei/_likelihood.py +90 -0
- unibm-0.1.0/src/unibm/ei/_stats.py +59 -0
- unibm-0.1.0/src/unibm/ei/_validation.py +66 -0
- unibm-0.1.0/src/unibm/ei/bm.py +447 -0
- unibm-0.1.0/src/unibm/ei/bootstrap.py +252 -0
- unibm-0.1.0/src/unibm/ei/models.py +117 -0
- unibm-0.1.0/src/unibm/ei/paths.py +203 -0
- unibm-0.1.0/src/unibm/ei/plotting.py +228 -0
- unibm-0.1.0/src/unibm/ei/preparation.py +54 -0
- unibm-0.1.0/src/unibm/ei/selection.py +117 -0
- unibm-0.1.0/src/unibm/ei/threshold.py +318 -0
- unibm-0.1.0/src/unibm/evi/__init__.py +101 -0
- unibm-0.1.0/src/unibm/evi/_regression.py +208 -0
- unibm-0.1.0/src/unibm/evi/blocks.py +97 -0
- unibm-0.1.0/src/unibm/evi/bootstrap.py +532 -0
- unibm-0.1.0/src/unibm/evi/design.py +146 -0
- unibm-0.1.0/src/unibm/evi/estimation.py +313 -0
- unibm-0.1.0/src/unibm/evi/models.py +153 -0
- unibm-0.1.0/src/unibm/evi/plotting.py +104 -0
- unibm-0.1.0/src/unibm/evi/selection.py +113 -0
- unibm-0.1.0/src/unibm/evi/spectrum.py +218 -0
- unibm-0.1.0/src/unibm/evi/summaries.py +103 -0
- unibm-0.1.0/src/unibm/evi/tail.py +505 -0
- unibm-0.1.0/src/unibm/evi/targets.py +46 -0
- unibm-0.1.0/src/unibm/py.typed +1 -0
unibm-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# Project-generated outputs
|
|
2
|
+
scratch*
|
|
3
|
+
/tmp/
|
|
4
|
+
/.python-version
|
|
5
|
+
/doc/
|
|
6
|
+
/site/
|
|
7
|
+
/out/
|
|
8
|
+
*.pkl
|
|
9
|
+
*.csv.gz
|
|
10
|
+
*.npz
|
|
11
|
+
CONTEXT.md
|
|
12
|
+
|
|
13
|
+
# Canonical provider snapshots (derived data and download chunks stay ignored)
|
|
14
|
+
/data/*
|
|
15
|
+
!/data/README.md
|
|
16
|
+
!/data/raw/
|
|
17
|
+
/data/raw/*
|
|
18
|
+
!/data/raw/cpi/
|
|
19
|
+
/data/raw/cpi/*
|
|
20
|
+
!/data/raw/cpi/cpi_u_monthly.csv
|
|
21
|
+
!/data/raw/fema/
|
|
22
|
+
/data/raw/fema/*
|
|
23
|
+
!/data/raw/fema/nfip_claims_fl.csv.gz
|
|
24
|
+
!/data/raw/fema/nfip_claims_tx.csv.gz
|
|
25
|
+
!/data/raw/ghcn/
|
|
26
|
+
/data/raw/ghcn/*
|
|
27
|
+
!/data/raw/ghcn/USW00012918.csv.gz
|
|
28
|
+
!/data/raw/ghcn/USW00023183.csv.gz
|
|
29
|
+
!/data/raw/usgs/
|
|
30
|
+
/data/raw/usgs/*
|
|
31
|
+
!/data/raw/usgs/usgs_02236000.csv.gz
|
|
32
|
+
!/data/raw/usgs/usgs_02320500.csv.gz
|
|
33
|
+
!/data/raw/usgs/usgs_02366500.csv.gz
|
|
34
|
+
!/data/raw/usgs/usgs_08066500.csv.gz
|
|
35
|
+
!/data/raw/usgs/usgs_08114000.csv.gz
|
|
36
|
+
!/data/raw/usgs/usgs_08158000.csv.gz
|
|
37
|
+
!/data/metadata/
|
|
38
|
+
/data/metadata/*
|
|
39
|
+
!/data/metadata/sources.json
|
|
40
|
+
!/data/metadata/application/
|
|
41
|
+
/data/metadata/application/*
|
|
42
|
+
!/data/metadata/application/usgs_candidate_sites.json
|
|
43
|
+
!/data/metadata/application/usgs_frozen_sites.json
|
|
44
|
+
|
|
45
|
+
# Python runtime
|
|
46
|
+
__pycache__/
|
|
47
|
+
*.py[codz]
|
|
48
|
+
*$py.class
|
|
49
|
+
*.so
|
|
50
|
+
|
|
51
|
+
# Packaging / build
|
|
52
|
+
.Python
|
|
53
|
+
MANIFEST
|
|
54
|
+
build/
|
|
55
|
+
dist/
|
|
56
|
+
*.egg
|
|
57
|
+
*.egg-info/
|
|
58
|
+
|
|
59
|
+
# Environments / secrets
|
|
60
|
+
.env
|
|
61
|
+
.envrc
|
|
62
|
+
.venv/
|
|
63
|
+
ENV/
|
|
64
|
+
env/
|
|
65
|
+
venv/
|
|
66
|
+
|
|
67
|
+
# Testing / coverage
|
|
68
|
+
.coverage
|
|
69
|
+
.coverage.*
|
|
70
|
+
.hypothesis/
|
|
71
|
+
.nox/
|
|
72
|
+
.tox/
|
|
73
|
+
.cache/
|
|
74
|
+
cover/
|
|
75
|
+
coverage.xml
|
|
76
|
+
htmlcov/
|
|
77
|
+
nosetests.xml
|
|
78
|
+
*.cover
|
|
79
|
+
*.py.cover
|
|
80
|
+
|
|
81
|
+
# Tool caches
|
|
82
|
+
.serena/
|
|
83
|
+
.dmypy.json
|
|
84
|
+
.mypy_cache/
|
|
85
|
+
dmypy.json
|
|
86
|
+
|
|
87
|
+
# IPython
|
|
88
|
+
ipython_config.py
|
|
89
|
+
profile_default/
|
|
90
|
+
|
|
91
|
+
# Editors
|
|
92
|
+
.vscode/*
|
|
93
|
+
!.vscode/*.code-snippets
|
|
94
|
+
!.vscode/extensions.json
|
|
95
|
+
!.vscode/launch.json
|
|
96
|
+
!.vscode/settings.json
|
|
97
|
+
!.vscode/tasks.json
|
|
98
|
+
!*.code-workspace
|
|
99
|
+
*.vsix
|
|
100
|
+
|
|
101
|
+
# macOS
|
|
102
|
+
**/.DS_Store
|
|
103
|
+
|
|
104
|
+
# Misc
|
|
105
|
+
*.log
|
|
106
|
+
.pypirc
|
|
107
|
+
pip-delete-this-directory.txt
|
|
108
|
+
pip-log.txt
|
unibm-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024- Tuoyuan Cheng, Kan Chen
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
unibm-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: unibm
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Block-maxima inference methods for heavy-tailed time series under serial dependence.
|
|
5
|
+
Project-URL: Homepage, https://github.com/TY-Cheng/UniBM/
|
|
6
|
+
Project-URL: Repository, https://github.com/TY-Cheng/UniBM/
|
|
7
|
+
Project-URL: Documentation, https://ty-cheng.github.io/UniBM/
|
|
8
|
+
Project-URL: Issues, https://github.com/TY-Cheng/UniBM/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/TY-Cheng/UniBM/releases
|
|
10
|
+
Author-email: Tuoyuan Cheng <tuoyuan.cheng@nus.edu.sg>
|
|
11
|
+
Maintainer-email: Tuoyuan Cheng <tuoyuan.cheng@nus.edu.sg>
|
|
12
|
+
License-Expression: MIT
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Keywords: block maxima,block-maximum quantiles,design-life levels,environmental extremes,extremal index,extreme value theory,heavy tails,serial dependence,sliding blocks
|
|
15
|
+
Classifier: Intended Audience :: Science/Research
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering
|
|
22
|
+
Requires-Python: >=3.11
|
|
23
|
+
Requires-Dist: matplotlib>=3.8
|
|
24
|
+
Requires-Dist: numpy>=2
|
|
25
|
+
Requires-Dist: pandas>=2
|
|
26
|
+
Requires-Dist: pillow>=12.3.0
|
|
27
|
+
Requires-Dist: scipy>=1.13
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
# UniBM
|
|
31
|
+
|
|
32
|
+
UniBM is a Python package for dependence-aware block-maxima inference in
|
|
33
|
+
environmental extremes.
|
|
34
|
+
|
|
35
|
+
It exposes two complementary inferential targets:
|
|
36
|
+
|
|
37
|
+
- severity via the extreme value index (EVI) and design-life levels
|
|
38
|
+
- persistence via the extremal index (EI)
|
|
39
|
+
|
|
40
|
+
The installable package lives under `src/unibm`. Repository-level benchmark,
|
|
41
|
+
application, report, and static-site workflows are orchestrated through the
|
|
42
|
+
root `justfile`.
|
|
43
|
+
|
|
44
|
+
UniBM is developed and maintained by Tuoyuan Cheng under the project supervision
|
|
45
|
+
of Kan Chen. It is distributed under the MIT License.
|
|
46
|
+
|
|
47
|
+
## Package surface
|
|
48
|
+
|
|
49
|
+
The public package is organized around four entrypoints:
|
|
50
|
+
|
|
51
|
+
- `unibm` for the headline EVI and design-life-level calls
|
|
52
|
+
- `unibm.evi` for the severity-side workflow
|
|
53
|
+
- `unibm.ei` for the persistence-side workflow
|
|
54
|
+
- `unibm.cdf` for the public empirical CDF helper
|
|
55
|
+
|
|
56
|
+
## Quick start
|
|
57
|
+
|
|
58
|
+
Install the package from a source checkout with Python 3.11 or later:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
git clone https://github.com/TY-Cheng/UniBM.git
|
|
62
|
+
python -m pip install ./UniBM
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
This installs `unibm`, including its estimators, interval helpers, design-life
|
|
66
|
+
levels, and plotting helpers. Research scripts, datasets, and `just full` belong
|
|
67
|
+
to the GitHub checkout and are not included in the wheel or source distribution.
|
|
68
|
+
|
|
69
|
+
For repository development:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
cd UniBM
|
|
73
|
+
just check
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
No `.env` or external project is required. Defaults are `data/`, `out/reports/`,
|
|
77
|
+
and uv's normal project environment. Copy `.env.example` only to override the
|
|
78
|
+
report destination or environment location. Top-level `just` tasks load `.env`
|
|
79
|
+
and sync the development environment automatically.
|
|
80
|
+
|
|
81
|
+
For ad hoc uv commands that should use `.env`, use `just --command`, for example
|
|
82
|
+
`just --command uv run pytest -q tests/test_unibm_cdf.py`. A plain `uv sync` or
|
|
83
|
+
`uv run` does not automatically load `.env` before choosing its project environment;
|
|
84
|
+
without an exported override it uses `.venv/`.
|
|
85
|
+
|
|
86
|
+
## Results and reports
|
|
87
|
+
|
|
88
|
+
Calculation results stay in the code repository:
|
|
89
|
+
|
|
90
|
+
- `out/benchmark/`: benchmark CSVs and sensitivity summaries
|
|
91
|
+
- `out/benchmark/cache/`: reusable simulation caches
|
|
92
|
+
- `out/applications/`: application CSVs and JSON
|
|
93
|
+
|
|
94
|
+
Final PDF figures and LaTeX tables go to `Figure/` and `Table/` inside a single
|
|
95
|
+
report destination. `UNIBM_REPORT_DIR` unset or blank means `out/reports/`.
|
|
96
|
+
An explicit value selects that destination directly, without an additional local
|
|
97
|
+
copy. Relative paths are resolved against the code repository root:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
UNIBM_REPORT_DIR="/path/to/your/report-project" just reports
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
An invalid destination raises an error; it never silently falls back. Report
|
|
104
|
+
output directories and files must not redirect writes through symlinks.
|
|
105
|
+
Table filenames describe their contents, for example `application_summary.tex`;
|
|
106
|
+
direct JoH updates use these names and their matching LaTeX labels.
|
|
107
|
+
Benchmark figures and tables use paired `benchmark_evi_*` / `benchmark_ei_*`
|
|
108
|
+
names; raw benchmark CSVs use `evi_*` / `ei_*`. Application method comparisons
|
|
109
|
+
use `application_evi_methods.csv` / `application_ei_methods.csv`. Combined
|
|
110
|
+
application summaries retain the general `application_summary` name.
|
|
111
|
+
`report_subset_manifest.json` indexes expected paths, labels, producers, and
|
|
112
|
+
placements for the curated four-case report subset. It is not a complete
|
|
113
|
+
inventory or a verification of generated files. `manifest_code_commit` and
|
|
114
|
+
`manifest_code_worktree_dirty` describe the code checkout when the index was
|
|
115
|
+
written, not the version used to calculate the listed results.
|
|
116
|
+
|
|
117
|
+
The cleanup step in `just full` removes only explicitly named workflow outputs for the
|
|
118
|
+
selected benchmark sample size and report destination. Those names are reserved
|
|
119
|
+
for generated files. It preserves caches, other sample-size runs, research notes,
|
|
120
|
+
historical report folders, and unrecognized files. It never deletes an entire
|
|
121
|
+
output directory. Web snapshots under `docs/assets/` are refreshed by the report
|
|
122
|
+
workflows separately.
|
|
123
|
+
|
|
124
|
+
## Documentation
|
|
125
|
+
|
|
126
|
+
Package documentation is available at:
|
|
127
|
+
|
|
128
|
+
- [https://ty-cheng.github.io/UniBM/](https://ty-cheng.github.io/UniBM/)
|
|
129
|
+
|
|
130
|
+
Useful local docs command:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
just --command uv run mkdocs serve
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
This builds the static site under `site/` and launches the local preview server.
|
|
137
|
+
|
|
138
|
+
## Main repo entrypoints
|
|
139
|
+
|
|
140
|
+
The stable top-level entrypoints are:
|
|
141
|
+
|
|
142
|
+
- `just check`
|
|
143
|
+
- `just check-full`
|
|
144
|
+
- `just data`
|
|
145
|
+
- `just refresh-data`
|
|
146
|
+
- `just benchmark`
|
|
147
|
+
- `just application`
|
|
148
|
+
- `just reports`
|
|
149
|
+
- `just full`
|
|
150
|
+
|
|
151
|
+
`just check` runs tests affected by local changes in parallel, then checks all
|
|
152
|
+
formatting and lint rules. `just check-full` runs the complete parallel test
|
|
153
|
+
suite with the coverage gate.
|
|
154
|
+
`just data` validates the tracked canonical inputs and prepares the four report
|
|
155
|
+
cases without network access. `just refresh-data` is the only networked data
|
|
156
|
+
entrypoint; it refreshes the fixed-cutoff provider snapshots and leaves their
|
|
157
|
+
Git diff for review. `just reports` reuses valid benchmark summaries, computes
|
|
158
|
+
missing ones, and reruns application fits to refresh reports and web snapshots.
|
|
159
|
+
`just full` checks the project, cleans named outputs, and rebuilds the benchmark,
|
|
160
|
+
application, report, and static-site outputs offline. These research workflows
|
|
161
|
+
can be expensive; they are not required to use or install the package.
|
|
162
|
+
|
|
163
|
+
## Minimal package example
|
|
164
|
+
|
|
165
|
+
```python
|
|
166
|
+
import numpy as np
|
|
167
|
+
from unibm import estimate_design_life_level, estimate_evi_quantile
|
|
168
|
+
|
|
169
|
+
sample = np.random.default_rng(7).pareto(2.0, 4096) + 1.0
|
|
170
|
+
fit = estimate_evi_quantile(
|
|
171
|
+
sample,
|
|
172
|
+
regression="FGLS",
|
|
173
|
+
quantile=0.5,
|
|
174
|
+
sliding=True,
|
|
175
|
+
bootstrap_reps="adaptive",
|
|
176
|
+
random_state=7,
|
|
177
|
+
)
|
|
178
|
+
design_life = estimate_design_life_level(fit, years=np.array([10.0, 50.0]))
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
See the docs site for API details, returned objects, and worked examples.
|
|
182
|
+
|
|
183
|
+
The example uses the default adaptive policy with checkpoints 128, 256, 512,
|
|
184
|
+
768, and 1024. An explicit integer such as `bootstrap_reps=480` instead fixes R. Inspect
|
|
185
|
+
`bootstrap_reps_used` and `bootstrap_precision_met`: reaching the cap does not
|
|
186
|
+
imply precision was met. Adaptive R controls numerical Monte Carlo error, not
|
|
187
|
+
statistical CI width or coverage. Both EVI/EI FGLS defaults use fixed shrinkage 0.37.
|
unibm-0.1.0/README.md
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# UniBM
|
|
2
|
+
|
|
3
|
+
UniBM is a Python package for dependence-aware block-maxima inference in
|
|
4
|
+
environmental extremes.
|
|
5
|
+
|
|
6
|
+
It exposes two complementary inferential targets:
|
|
7
|
+
|
|
8
|
+
- severity via the extreme value index (EVI) and design-life levels
|
|
9
|
+
- persistence via the extremal index (EI)
|
|
10
|
+
|
|
11
|
+
The installable package lives under `src/unibm`. Repository-level benchmark,
|
|
12
|
+
application, report, and static-site workflows are orchestrated through the
|
|
13
|
+
root `justfile`.
|
|
14
|
+
|
|
15
|
+
UniBM is developed and maintained by Tuoyuan Cheng under the project supervision
|
|
16
|
+
of Kan Chen. It is distributed under the MIT License.
|
|
17
|
+
|
|
18
|
+
## Package surface
|
|
19
|
+
|
|
20
|
+
The public package is organized around four entrypoints:
|
|
21
|
+
|
|
22
|
+
- `unibm` for the headline EVI and design-life-level calls
|
|
23
|
+
- `unibm.evi` for the severity-side workflow
|
|
24
|
+
- `unibm.ei` for the persistence-side workflow
|
|
25
|
+
- `unibm.cdf` for the public empirical CDF helper
|
|
26
|
+
|
|
27
|
+
## Quick start
|
|
28
|
+
|
|
29
|
+
Install the package from a source checkout with Python 3.11 or later:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
git clone https://github.com/TY-Cheng/UniBM.git
|
|
33
|
+
python -m pip install ./UniBM
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
This installs `unibm`, including its estimators, interval helpers, design-life
|
|
37
|
+
levels, and plotting helpers. Research scripts, datasets, and `just full` belong
|
|
38
|
+
to the GitHub checkout and are not included in the wheel or source distribution.
|
|
39
|
+
|
|
40
|
+
For repository development:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
cd UniBM
|
|
44
|
+
just check
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
No `.env` or external project is required. Defaults are `data/`, `out/reports/`,
|
|
48
|
+
and uv's normal project environment. Copy `.env.example` only to override the
|
|
49
|
+
report destination or environment location. Top-level `just` tasks load `.env`
|
|
50
|
+
and sync the development environment automatically.
|
|
51
|
+
|
|
52
|
+
For ad hoc uv commands that should use `.env`, use `just --command`, for example
|
|
53
|
+
`just --command uv run pytest -q tests/test_unibm_cdf.py`. A plain `uv sync` or
|
|
54
|
+
`uv run` does not automatically load `.env` before choosing its project environment;
|
|
55
|
+
without an exported override it uses `.venv/`.
|
|
56
|
+
|
|
57
|
+
## Results and reports
|
|
58
|
+
|
|
59
|
+
Calculation results stay in the code repository:
|
|
60
|
+
|
|
61
|
+
- `out/benchmark/`: benchmark CSVs and sensitivity summaries
|
|
62
|
+
- `out/benchmark/cache/`: reusable simulation caches
|
|
63
|
+
- `out/applications/`: application CSVs and JSON
|
|
64
|
+
|
|
65
|
+
Final PDF figures and LaTeX tables go to `Figure/` and `Table/` inside a single
|
|
66
|
+
report destination. `UNIBM_REPORT_DIR` unset or blank means `out/reports/`.
|
|
67
|
+
An explicit value selects that destination directly, without an additional local
|
|
68
|
+
copy. Relative paths are resolved against the code repository root:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
UNIBM_REPORT_DIR="/path/to/your/report-project" just reports
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
An invalid destination raises an error; it never silently falls back. Report
|
|
75
|
+
output directories and files must not redirect writes through symlinks.
|
|
76
|
+
Table filenames describe their contents, for example `application_summary.tex`;
|
|
77
|
+
direct JoH updates use these names and their matching LaTeX labels.
|
|
78
|
+
Benchmark figures and tables use paired `benchmark_evi_*` / `benchmark_ei_*`
|
|
79
|
+
names; raw benchmark CSVs use `evi_*` / `ei_*`. Application method comparisons
|
|
80
|
+
use `application_evi_methods.csv` / `application_ei_methods.csv`. Combined
|
|
81
|
+
application summaries retain the general `application_summary` name.
|
|
82
|
+
`report_subset_manifest.json` indexes expected paths, labels, producers, and
|
|
83
|
+
placements for the curated four-case report subset. It is not a complete
|
|
84
|
+
inventory or a verification of generated files. `manifest_code_commit` and
|
|
85
|
+
`manifest_code_worktree_dirty` describe the code checkout when the index was
|
|
86
|
+
written, not the version used to calculate the listed results.
|
|
87
|
+
|
|
88
|
+
The cleanup step in `just full` removes only explicitly named workflow outputs for the
|
|
89
|
+
selected benchmark sample size and report destination. Those names are reserved
|
|
90
|
+
for generated files. It preserves caches, other sample-size runs, research notes,
|
|
91
|
+
historical report folders, and unrecognized files. It never deletes an entire
|
|
92
|
+
output directory. Web snapshots under `docs/assets/` are refreshed by the report
|
|
93
|
+
workflows separately.
|
|
94
|
+
|
|
95
|
+
## Documentation
|
|
96
|
+
|
|
97
|
+
Package documentation is available at:
|
|
98
|
+
|
|
99
|
+
- [https://ty-cheng.github.io/UniBM/](https://ty-cheng.github.io/UniBM/)
|
|
100
|
+
|
|
101
|
+
Useful local docs command:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
just --command uv run mkdocs serve
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
This builds the static site under `site/` and launches the local preview server.
|
|
108
|
+
|
|
109
|
+
## Main repo entrypoints
|
|
110
|
+
|
|
111
|
+
The stable top-level entrypoints are:
|
|
112
|
+
|
|
113
|
+
- `just check`
|
|
114
|
+
- `just check-full`
|
|
115
|
+
- `just data`
|
|
116
|
+
- `just refresh-data`
|
|
117
|
+
- `just benchmark`
|
|
118
|
+
- `just application`
|
|
119
|
+
- `just reports`
|
|
120
|
+
- `just full`
|
|
121
|
+
|
|
122
|
+
`just check` runs tests affected by local changes in parallel, then checks all
|
|
123
|
+
formatting and lint rules. `just check-full` runs the complete parallel test
|
|
124
|
+
suite with the coverage gate.
|
|
125
|
+
`just data` validates the tracked canonical inputs and prepares the four report
|
|
126
|
+
cases without network access. `just refresh-data` is the only networked data
|
|
127
|
+
entrypoint; it refreshes the fixed-cutoff provider snapshots and leaves their
|
|
128
|
+
Git diff for review. `just reports` reuses valid benchmark summaries, computes
|
|
129
|
+
missing ones, and reruns application fits to refresh reports and web snapshots.
|
|
130
|
+
`just full` checks the project, cleans named outputs, and rebuilds the benchmark,
|
|
131
|
+
application, report, and static-site outputs offline. These research workflows
|
|
132
|
+
can be expensive; they are not required to use or install the package.
|
|
133
|
+
|
|
134
|
+
## Minimal package example
|
|
135
|
+
|
|
136
|
+
```python
|
|
137
|
+
import numpy as np
|
|
138
|
+
from unibm import estimate_design_life_level, estimate_evi_quantile
|
|
139
|
+
|
|
140
|
+
sample = np.random.default_rng(7).pareto(2.0, 4096) + 1.0
|
|
141
|
+
fit = estimate_evi_quantile(
|
|
142
|
+
sample,
|
|
143
|
+
regression="FGLS",
|
|
144
|
+
quantile=0.5,
|
|
145
|
+
sliding=True,
|
|
146
|
+
bootstrap_reps="adaptive",
|
|
147
|
+
random_state=7,
|
|
148
|
+
)
|
|
149
|
+
design_life = estimate_design_life_level(fit, years=np.array([10.0, 50.0]))
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
See the docs site for API details, returned objects, and worked examples.
|
|
153
|
+
|
|
154
|
+
The example uses the default adaptive policy with checkpoints 128, 256, 512,
|
|
155
|
+
768, and 1024. An explicit integer such as `bootstrap_reps=480` instead fixes R. Inspect
|
|
156
|
+
`bootstrap_reps_used` and `bootstrap_precision_met`: reaching the cap does not
|
|
157
|
+
imply precision was met. Adaptive R controls numerical Monte Carlo error, not
|
|
158
|
+
statistical CI width or coverage. Both EVI/EI FGLS defaults use fixed shrinkage 0.37.
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.27"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "unibm"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Block-maxima inference methods for heavy-tailed time series under serial dependence."
|
|
9
|
+
requires-python = ">=3.11"
|
|
10
|
+
authors = [{ name = "Tuoyuan Cheng", email = "tuoyuan.cheng@nus.edu.sg" }]
|
|
11
|
+
maintainers = [{ name = "Tuoyuan Cheng", email = "tuoyuan.cheng@nus.edu.sg" }]
|
|
12
|
+
readme = "README.md"
|
|
13
|
+
license = "MIT"
|
|
14
|
+
license-files = ["LICENSE"]
|
|
15
|
+
keywords = [
|
|
16
|
+
"block maxima",
|
|
17
|
+
"block-maximum quantiles",
|
|
18
|
+
"design-life levels",
|
|
19
|
+
"environmental extremes",
|
|
20
|
+
"extreme value theory",
|
|
21
|
+
"extremal index",
|
|
22
|
+
"heavy tails",
|
|
23
|
+
"serial dependence",
|
|
24
|
+
"sliding blocks",
|
|
25
|
+
]
|
|
26
|
+
classifiers = [
|
|
27
|
+
"Intended Audience :: Science/Research",
|
|
28
|
+
"Programming Language :: Python :: 3",
|
|
29
|
+
"Programming Language :: Python :: 3.11",
|
|
30
|
+
"Programming Language :: Python :: 3.12",
|
|
31
|
+
"Programming Language :: Python :: 3.13",
|
|
32
|
+
"Programming Language :: Python :: 3.14",
|
|
33
|
+
"Topic :: Scientific/Engineering",
|
|
34
|
+
]
|
|
35
|
+
dependencies = ["matplotlib>=3.8", "numpy>=2", "pandas>=2", "pillow>=12.3.0", "scipy>=1.13"]
|
|
36
|
+
|
|
37
|
+
[project.urls]
|
|
38
|
+
Homepage = "https://github.com/TY-Cheng/UniBM/"
|
|
39
|
+
Repository = "https://github.com/TY-Cheng/UniBM/"
|
|
40
|
+
Documentation = "https://ty-cheng.github.io/UniBM/"
|
|
41
|
+
Issues = "https://github.com/TY-Cheng/UniBM/issues"
|
|
42
|
+
Changelog = "https://github.com/TY-Cheng/UniBM/releases"
|
|
43
|
+
|
|
44
|
+
[dependency-groups]
|
|
45
|
+
dev = [
|
|
46
|
+
"mkdocs>=1.6,<2",
|
|
47
|
+
"mkdocs-autorefs>=1.4",
|
|
48
|
+
"mkdocs-material>=9.7.7",
|
|
49
|
+
"mkdocstrings[python]>=0.29",
|
|
50
|
+
"pymdown-extensions>=11.0.1",
|
|
51
|
+
"pytest",
|
|
52
|
+
"pytest-cov",
|
|
53
|
+
"pytest-testmon",
|
|
54
|
+
"pytest-xdist",
|
|
55
|
+
"python-dotenv",
|
|
56
|
+
"ruff",
|
|
57
|
+
]
|
|
58
|
+
|
|
59
|
+
[tool.hatch.build]
|
|
60
|
+
exclude = ["/**/__pycache__", "/**/.DS_Store"]
|
|
61
|
+
|
|
62
|
+
[tool.hatch.version]
|
|
63
|
+
path = "src/unibm/__about__.py"
|
|
64
|
+
|
|
65
|
+
[tool.hatch.build.targets.wheel]
|
|
66
|
+
packages = ["src/unibm"]
|
|
67
|
+
|
|
68
|
+
[tool.hatch.build.targets.sdist]
|
|
69
|
+
include = ["/LICENSE", "/README.md", "/pyproject.toml", "/src/unibm"]
|
|
70
|
+
|
|
71
|
+
[[tool.uv.index]]
|
|
72
|
+
name = "testpypi"
|
|
73
|
+
url = "https://test.pypi.org/simple/"
|
|
74
|
+
publish-url = "https://test.pypi.org/legacy/"
|
|
75
|
+
explicit = true
|
|
76
|
+
|
|
77
|
+
[tool.pytest.ini_options]
|
|
78
|
+
cache_dir = ".cache/pytest"
|
|
79
|
+
pythonpath = ["src", "scripts"]
|
|
80
|
+
|
|
81
|
+
[tool.ruff]
|
|
82
|
+
cache-dir = ".cache/ruff"
|
|
83
|
+
line-length = 99
|
|
84
|
+
extend-exclude = ["site", "justfile"]
|
|
85
|
+
|
|
86
|
+
[tool.ruff.format]
|
|
87
|
+
quote-style = "double"
|
|
88
|
+
indent-style = "space"
|
|
89
|
+
docstring-code-format = true
|
|
90
|
+
docstring-code-line-length = 99
|
|
91
|
+
|
|
92
|
+
[tool.ruff.lint.pycodestyle]
|
|
93
|
+
max-doc-length = 99
|
|
94
|
+
max-line-length = 99
|
|
95
|
+
|
|
96
|
+
[tool.coverage.run]
|
|
97
|
+
branch = true
|
|
98
|
+
source = ["src/unibm"]
|
|
99
|
+
|
|
100
|
+
[tool.coverage.report]
|
|
101
|
+
show_missing = true
|
|
102
|
+
skip_covered = false
|
|
103
|
+
precision = 2
|
|
104
|
+
fail_under = 89
|
|
105
|
+
exclude_also = ["if __name__ == .__main__.:", "pragma: no cover"]
|
|
106
|
+
|
|
107
|
+
[tool.coverage.html]
|
|
108
|
+
directory = "htmlcov"
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"""Public UniBM package facade.
|
|
2
|
+
|
|
3
|
+
The package exposes grouped public namespaces under ``unibm.evi`` and
|
|
4
|
+
``unibm.ei`` together with the standalone helper module ``unibm.cdf``.
|
|
5
|
+
Repo-local benchmark, application,
|
|
6
|
+
and repository orchestration code lives outside the package under
|
|
7
|
+
``scripts/``.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from typing import TYPE_CHECKING
|
|
11
|
+
|
|
12
|
+
from .__about__ import __version__
|
|
13
|
+
|
|
14
|
+
if TYPE_CHECKING:
|
|
15
|
+
from . import ei, evi
|
|
16
|
+
from .evi.design import estimate_design_life_level
|
|
17
|
+
from .evi.estimation import estimate_evi_quantile
|
|
18
|
+
|
|
19
|
+
__all__ = ["__version__", "ei", "evi", "estimate_design_life_level", "estimate_evi_quantile"]
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def __getattr__(name: str):
|
|
23
|
+
"""Import a public namespace or estimator on first access and cache it.
|
|
24
|
+
|
|
25
|
+
Unknown names raise ``AttributeError``, as for an ordinary module attribute.
|
|
26
|
+
Deferring these imports keeps ``import unibm`` lightweight.
|
|
27
|
+
"""
|
|
28
|
+
import importlib
|
|
29
|
+
|
|
30
|
+
if name in {"ei", "evi"}:
|
|
31
|
+
value = importlib.import_module(f"{__name__}.{name}")
|
|
32
|
+
elif name == "estimate_evi_quantile":
|
|
33
|
+
value = importlib.import_module(f"{__name__}.evi.estimation").estimate_evi_quantile
|
|
34
|
+
elif name == "estimate_design_life_level":
|
|
35
|
+
value = importlib.import_module(f"{__name__}.evi.design").estimate_design_life_level
|
|
36
|
+
else:
|
|
37
|
+
raise AttributeError(f"module 'unibm' has no attribute {name!r}")
|
|
38
|
+
globals()[name] = value
|
|
39
|
+
return value
|