lattice-doe 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.
Files changed (103) hide show
  1. lattice_doe-0.1.0/CHANGELOG.md +42 -0
  2. lattice_doe-0.1.0/CONTRIBUTING.md +127 -0
  3. lattice_doe-0.1.0/LICENSE +21 -0
  4. lattice_doe-0.1.0/MANIFEST.in +11 -0
  5. lattice_doe-0.1.0/PKG-INFO +1396 -0
  6. lattice_doe-0.1.0/README.md +1329 -0
  7. lattice_doe-0.1.0/lattice_doe/__init__.py +158 -0
  8. lattice_doe-0.1.0/lattice_doe/_request_builder.py +431 -0
  9. lattice_doe-0.1.0/lattice_doe/allocation.py +388 -0
  10. lattice_doe-0.1.0/lattice_doe/analysis.py +2134 -0
  11. lattice_doe-0.1.0/lattice_doe/api.py +2625 -0
  12. lattice_doe-0.1.0/lattice_doe/api_server/__init__.py +17 -0
  13. lattice_doe-0.1.0/lattice_doe/api_server/errors.py +87 -0
  14. lattice_doe-0.1.0/lattice_doe/api_server/jobs.py +201 -0
  15. lattice_doe-0.1.0/lattice_doe/api_server/main.py +133 -0
  16. lattice_doe-0.1.0/lattice_doe/api_server/models/__init__.py +1 -0
  17. lattice_doe-0.1.0/lattice_doe/api_server/models/augment.py +49 -0
  18. lattice_doe-0.1.0/lattice_doe/api_server/models/common.py +385 -0
  19. lattice_doe-0.1.0/lattice_doe/api_server/models/compare.py +44 -0
  20. lattice_doe-0.1.0/lattice_doe/api_server/models/design.py +221 -0
  21. lattice_doe-0.1.0/lattice_doe/api_server/models/power_curve.py +55 -0
  22. lattice_doe-0.1.0/lattice_doe/api_server/models/sensitivity.py +98 -0
  23. lattice_doe-0.1.0/lattice_doe/api_server/routers/__init__.py +1 -0
  24. lattice_doe-0.1.0/lattice_doe/api_server/routers/augment.py +57 -0
  25. lattice_doe-0.1.0/lattice_doe/api_server/routers/compare.py +91 -0
  26. lattice_doe-0.1.0/lattice_doe/api_server/routers/design.py +95 -0
  27. lattice_doe-0.1.0/lattice_doe/api_server/routers/jobs.py +208 -0
  28. lattice_doe-0.1.0/lattice_doe/api_server/routers/power_curve.py +86 -0
  29. lattice_doe-0.1.0/lattice_doe/api_server/routers/sensitivity.py +126 -0
  30. lattice_doe-0.1.0/lattice_doe/api_server/serialization.py +298 -0
  31. lattice_doe-0.1.0/lattice_doe/app/__init__.py +17 -0
  32. lattice_doe-0.1.0/lattice_doe/app/_launcher.py +28 -0
  33. lattice_doe-0.1.0/lattice_doe/app/app.py +76 -0
  34. lattice_doe-0.1.0/lattice_doe/app/components/__init__.py +1 -0
  35. lattice_doe-0.1.0/lattice_doe/app/components/charts.py +59 -0
  36. lattice_doe-0.1.0/lattice_doe/app/components/design_config.py +55 -0
  37. lattice_doe-0.1.0/lattice_doe/app/components/factor_table.py +181 -0
  38. lattice_doe-0.1.0/lattice_doe/app/components/mr_config.py +112 -0
  39. lattice_doe-0.1.0/lattice_doe/app/components/power_params.py +176 -0
  40. lattice_doe-0.1.0/lattice_doe/app/pages/1_Factors.py +140 -0
  41. lattice_doe-0.1.0/lattice_doe/app/pages/2_Power_Config.py +1037 -0
  42. lattice_doe-0.1.0/lattice_doe/app/pages/3_Run_Results.py +761 -0
  43. lattice_doe-0.1.0/lattice_doe/app/pages/4_Analysis.py +951 -0
  44. lattice_doe-0.1.0/lattice_doe/app/state.py +167 -0
  45. lattice_doe-0.1.0/lattice_doe/blocked.py +230 -0
  46. lattice_doe-0.1.0/lattice_doe/candidate.py +668 -0
  47. lattice_doe-0.1.0/lattice_doe/cli.py +1474 -0
  48. lattice_doe-0.1.0/lattice_doe/config.py +1138 -0
  49. lattice_doe-0.1.0/lattice_doe/contrasts.py +865 -0
  50. lattice_doe-0.1.0/lattice_doe/design.py +57 -0
  51. lattice_doe-0.1.0/lattice_doe/diag_export.py +238 -0
  52. lattice_doe-0.1.0/lattice_doe/diag_metrics.py +217 -0
  53. lattice_doe-0.1.0/lattice_doe/diag_plots.py +228 -0
  54. lattice_doe-0.1.0/lattice_doe/diagnostics.py +21 -0
  55. lattice_doe-0.1.0/lattice_doe/excel_template.py +1159 -0
  56. lattice_doe-0.1.0/lattice_doe/iopt_search.py +1979 -0
  57. lattice_doe-0.1.0/lattice_doe/model_matrix.py +169 -0
  58. lattice_doe-0.1.0/lattice_doe/plot_backends.py +426 -0
  59. lattice_doe-0.1.0/lattice_doe/power.py +1279 -0
  60. lattice_doe-0.1.0/lattice_doe/power_curves.py +855 -0
  61. lattice_doe-0.1.0/lattice_doe/progress.py +184 -0
  62. lattice_doe-0.1.0/lattice_doe/py.typed +0 -0
  63. lattice_doe-0.1.0/lattice_doe/report.py +568 -0
  64. lattice_doe-0.1.0/lattice_doe/sheets.py +1478 -0
  65. lattice_doe-0.1.0/lattice_doe/split_plot.py +467 -0
  66. lattice_doe-0.1.0/lattice_doe/templates/report_template.html +474 -0
  67. lattice_doe-0.1.0/lattice_doe/utils.py +469 -0
  68. lattice_doe-0.1.0/lattice_doe/widgets.py +1040 -0
  69. lattice_doe-0.1.0/lattice_doe.egg-info/PKG-INFO +1396 -0
  70. lattice_doe-0.1.0/lattice_doe.egg-info/SOURCES.txt +101 -0
  71. lattice_doe-0.1.0/lattice_doe.egg-info/dependency_links.txt +1 -0
  72. lattice_doe-0.1.0/lattice_doe.egg-info/entry_points.txt +4 -0
  73. lattice_doe-0.1.0/lattice_doe.egg-info/requires.txt +51 -0
  74. lattice_doe-0.1.0/lattice_doe.egg-info/top_level.txt +1 -0
  75. lattice_doe-0.1.0/pyproject.toml +215 -0
  76. lattice_doe-0.1.0/setup.cfg +4 -0
  77. lattice_doe-0.1.0/tests/test_allocation.py +432 -0
  78. lattice_doe-0.1.0/tests/test_api.py +4633 -0
  79. lattice_doe-0.1.0/tests/test_api_server.py +1816 -0
  80. lattice_doe-0.1.0/tests/test_app_state.py +804 -0
  81. lattice_doe-0.1.0/tests/test_blocked.py +1281 -0
  82. lattice_doe-0.1.0/tests/test_cli.py +580 -0
  83. lattice_doe-0.1.0/tests/test_config.py +1239 -0
  84. lattice_doe-0.1.0/tests/test_contrasts.py +1273 -0
  85. lattice_doe-0.1.0/tests/test_design.py +1035 -0
  86. lattice_doe-0.1.0/tests/test_diag_export.py +130 -0
  87. lattice_doe-0.1.0/tests/test_diag_plots.py +109 -0
  88. lattice_doe-0.1.0/tests/test_excel_template.py +1165 -0
  89. lattice_doe-0.1.0/tests/test_factor_specs.py +471 -0
  90. lattice_doe-0.1.0/tests/test_jobs.py +138 -0
  91. lattice_doe-0.1.0/tests/test_matrix_wire_format.py +78 -0
  92. lattice_doe-0.1.0/tests/test_packaging.py +17 -0
  93. lattice_doe-0.1.0/tests/test_plot_backends.py +459 -0
  94. lattice_doe-0.1.0/tests/test_power.py +1424 -0
  95. lattice_doe-0.1.0/tests/test_progress.py +314 -0
  96. lattice_doe-0.1.0/tests/test_readme_smoke.py +47 -0
  97. lattice_doe-0.1.0/tests/test_report.py +575 -0
  98. lattice_doe-0.1.0/tests/test_request_builder.py +492 -0
  99. lattice_doe-0.1.0/tests/test_result_contract.py +395 -0
  100. lattice_doe-0.1.0/tests/test_search_bounds.py +389 -0
  101. lattice_doe-0.1.0/tests/test_sheets.py +1441 -0
  102. lattice_doe-0.1.0/tests/test_split_plot.py +3072 -0
  103. lattice_doe-0.1.0/tests/test_widgets.py +601 -0
@@ -0,0 +1,42 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.1.0] — 2026-12-06
9
+
10
+ Initial public release of `lattice-doe`.
11
+
12
+ ### Added
13
+
14
+ - Power-assured optimal design search for linear models, R² tests, and GLMs (logistic, Poisson)
15
+ - I, D, and A optimality criteria via Fedorov exchange
16
+ - Multi-response designs with `min`, `product`, and `weighted_mean` power combination, plus joint Hotelling T² power
17
+ - Blocked designs and split-plot (hard-to-change factor) designs with η-controlled GLS information
18
+ - Declarative constraint expressions (`constraint_expr`), AST-validated against a restricted operator set
19
+ - Scenario-based contrast construction (`contrast_from_scenarios`)
20
+ - Top-level Python API: `find_optimal_design`, `find_multiresponse_design`, `compare_criteria`, `power_curve_*`, `min_detectable_effect`, `robustness_report`, `augment_design`, `generate_report`
21
+ - Command-line interface (`lattice`) with YAML/JSON config support and a `--template` scaffold generator
22
+ - Streamlit multi-page web UI, packaged with the `[app]` extra (`lattice-app`)
23
+ - FastAPI REST server (`lattice-api`)
24
+ - HTML/PDF report generation, diagnostic plots, and CSV/JSON diagnostic exports
25
+ - Google Sheets and Excel workbook integrations
26
+ - Jupyter `ipywidgets` UI for interactive design exploration
27
+
28
+ ### Fixed
29
+
30
+ - The sample-size search no longer crashes when `max_n` exceeds the candidate
31
+ set size (e.g. default `max_n=2000` with a 1000-point pool requested a
32
+ 1000+-run design on the first bisection step and raised `ValueError`). The
33
+ search upper bound is now capped at what the candidate pool supports; if the
34
+ capped search cannot reach the target power, a warning names both `max_n`
35
+ and `candidate_points`, and a pool too small for the smallest estimable
36
+ design raises an actionable error up front. (TICKET-039)
37
+ - Streamlit app: values entered on one page are no longer lost when
38
+ navigating to another page and back.
39
+ - CLI output is forced to UTF-8 on Windows so `lattice --help` and design
40
+ summaries render instead of raising `UnicodeEncodeError` on legacy consoles.
41
+
42
+ [0.1.0]: https://github.com/mbagalman/lattice-doe/releases/tag/v0.1.0
@@ -0,0 +1,127 @@
1
+ # Contributing to Lattice DOE
2
+
3
+ Thanks for your interest in improving Lattice DOE. This guide covers the
4
+ development setup, the quality gates every change must hold, and what a
5
+ good pull request looks like here.
6
+
7
+ ## Development setup
8
+
9
+ ```bash
10
+ git clone https://github.com/mbagalman/lattice-doe.git
11
+ cd lattice-doe
12
+ pip install -e ".[all]" # or pick extras: [cli], [server], [report], [viz], ...
13
+ pip install pytest pytest-cov pytest-anyio
14
+ ```
15
+
16
+ Python 3.10–3.14 are supported and tested in CI. The core package needs only
17
+ numpy/scipy/pandas/patsy; everything else is an optional extra guarded with
18
+ `try/except ImportError`, and the test suite must pass **without** any extras
19
+ installed (soft-dependency tests skip cleanly).
20
+
21
+ `weasyprint` (PDF export) is deliberately not part of `[all]`-style dev
22
+ setups here: it needs system libraries, and one test asserts the clean
23
+ ImportError guard when it is absent.
24
+
25
+ ## Running the tests
26
+
27
+ ```bash
28
+ pytest -m "not slow" # fast suite (~1,750 tests, ~20 min)
29
+ pytest # full suite (adds 127 slow integration tests)
30
+ pytest tests/test_api.py # one module
31
+ ```
32
+
33
+ - Slow tests live only in `test_api.py`, `test_api_server.py`,
34
+ `test_contrasts.py`, and `test_split_plot.py`, marked `@pytest.mark.slow`.
35
+ - Coverage is **opt-in**: `pytest -m "not slow" --cov=lattice_doe`.
36
+ It is intentionally not in the default pytest options — with it there,
37
+ any pytest invocation (even `--collect-only`) silently overwrites
38
+ `.coverage`. The weekly `slow-suite` CI workflow owns the authoritative
39
+ coverage number.
40
+ - Async API-server tests use `pytest-anyio` and run on both asyncio and
41
+ trio backends. If you add an async test class, give it its own
42
+ `@pytest.mark.anyio` decorator — and take care not to insert a new class
43
+ between an existing decorator and its class.
44
+
45
+ ## Quality gates (CI-enforced)
46
+
47
+ All of these run in CI on every push/PR and must hold:
48
+
49
+ | Gate | Command | Expectation |
50
+ |---|---|---|
51
+ | black | `black --check --line-length 100 lattice_doe/` | clean (the package is fully formatted) |
52
+ | ruff | `ruff check lattice_doe/ tests/` | zero findings |
53
+ | mypy | `mypy lattice_doe/` | no-grow baseline (see below) |
54
+ | tests | `pytest -m "not slow"` | green on Python 3.10–3.14 |
55
+
56
+ The ruff rule set is pinned in `[tool.ruff.lint] select` (pyproject.toml) rather
57
+ than left to ruff's defaults, because those defaults move: ruff 0.16 widened
58
+ them enough that an untouched tree measures 0 findings on the pinned 0.15.12
59
+ and ~1,400 on 0.16.4. If you bump ruff, the gate should stay at 0 — if it
60
+ doesn't, the new findings are a rule-set change, not your code. Enabling any
61
+ further rule family (UP, I, C4, SIM, …) is a deliberate opt-in: each is a
62
+ few-hundred-site mechanical diff that also moves the baseline, so give it its
63
+ own PR rather than folding it into unrelated work.
64
+
65
+ The mypy count is **measurement-environment-dependent** (installed typed
66
+ libraries change it), so CI pins the exact tool and dependency versions in
67
+ the `gates` job of `.github/workflows/ci.yml` and compares against
68
+ `MYPY_BASELINE` there. Two rules:
69
+
70
+ 1. Never let the count grow.
71
+ 2. If your change *lowers* a count, ratchet the corresponding
72
+ `RUFF_BASELINE`/`MYPY_BASELINE` value in `ci.yml` down **in the same PR**.
73
+
74
+ ## Code conventions
75
+
76
+ - Google-style docstrings; MIT license header at the top of every source file.
77
+ - `UPPER_CASE` constants, `PascalCase` classes, `snake_case` functions,
78
+ `_private` for internals.
79
+ - Inputs are typed `@dataclass` configs, not raw dicts.
80
+ - Every stochastic function accepts `random_state` for reproducibility.
81
+ - Public annotations must resolve at runtime: names used in annotations have
82
+ to be importable (no `TYPE_CHECKING`-only annotation imports on public
83
+ callables), and soft-dep types get an `Any` fallback binding in the
84
+ ImportError branch. `get_type_hints()` is swept over every `__all__` export
85
+ by a guard test, because autodoc, Pydantic and dataclass field resolution
86
+ all depend on it. (PEP 604 pipe unions `X | Y` were banned while 3.9 was
87
+ the floor — they broke `get_type_hints()` there. MT-3 raised the floor to
88
+ 3.10, so they are fine now; the codebase simply hasn't been converted, and
89
+ ruff's UP007/UP045 stay unadopted to keep that diff out of unrelated PRs.)
90
+ - Comments referencing ticket IDs (`SR-28`, `UX-57`, `TD-9`, …) are
91
+ deliberate provenance pointing into `docs/planning/ENHANCEMENTS.md` —
92
+ keep them; they have repeatedly been what made later bugs diagnosable.
93
+ - New call sites of the design builder pass `factors=` and never derive
94
+ categorical columns locally (see the TD-9 note in `ENHANCEMENTS.md`).
95
+
96
+ ## Tests for your change
97
+
98
+ - Prefer **exact-value regression tests** over smoke tests: pin computed
99
+ numbers (tolerances of `1e-9` where float math allows), exact counts,
100
+ exact error messages. Pin the *contract*, not whatever the current
101
+ implementation happens to produce.
102
+ - Bug fixes need a test that fails on the pre-fix code.
103
+ - Optional-dependency code paths need both sides tested: the working path
104
+ (skip-guarded with the module's `_HAS_*` flag or `pytest.importorskip`)
105
+ and the degradation path (patch the flag off).
106
+ - No mocking of the core DOE computation — use real calculations at small
107
+ problem sizes (`candidate_points=100`, `starts=1`, small `n`).
108
+
109
+ ## Pull requests
110
+
111
+ - Keep commits focused; explain **why** in the message body, not just what.
112
+ - Run the fast suite and the three gates locally before opening the PR.
113
+ - If your change closes a ledgered finding, update its row in
114
+ `docs/planning/ENHANCEMENTS.md` with the evidence.
115
+ - CI must be fully green — all four Python versions, gates, and the wheel
116
+ smoke-install.
117
+
118
+ ## Where things live
119
+
120
+ | Path | What |
121
+ |---|---|
122
+ | `lattice_doe/` | core package (api, power, search, analysis, connectors) |
123
+ | `lattice_doe/api_server/` | FastAPI REST server (`[server]` extra) |
124
+ | `lattice_doe/app/` | Streamlit UI (`[app]` extra; excluded from mypy by design) |
125
+ | `tests/` | the suite (~1,880 tests incl. slow) |
126
+ | `docs/` | quickstart, recipes, full user guide |
127
+ | `docs/planning/ENHANCEMENTS.md` | the ledger: roadmap, tickets, every review finding with its evidence trail |
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Michael Bagalman
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.
@@ -0,0 +1,11 @@
1
+ # Controls the sdist only — the wheel's contents come from
2
+ # [tool.setuptools.packages.find] / package-data in pyproject.toml.
3
+ #
4
+ # Already included by default, so they are deliberately absent here:
5
+ # README.md (project.readme), LICENSE (project.license-files),
6
+ # pyproject.toml, the lattice_doe package, and tests/.
7
+ #
8
+ # docs/ stays OUT on purpose: it is ~1 MB of user guide that would dominate
9
+ # the sdist, and it is published on GitHub where people actually read it.
10
+ include CHANGELOG.md
11
+ include CONTRIBUTING.md