Skip to content

Commit e014162

Browse files
committed
Fix and complete the canonical vignette ports
Repair the failures in the full R vignette port suite: - 01_overview: replace the thin delegate shim with a full nine-section instructional port of NNSvignette_01_Overview.Rmd, including figures for the partial-moment decomposition, mode estimation, copula surfaces, nonlinear regression, ARMA forecasting, and Monte Carlo replicates. - 04_normalization: pass a list instead of a generator to np.column_stack, which numpy rejects at runtime. - 05_sampling: replace the assertion-style smoke script with a full section-by-section port of NNSvignette_05_Sampling.Rmd with CDF, inverse-CDF, Monte Carlo, and dependence-transfer figures. - 06_comparing_distributions: replace the smoke script with a full port of NNSvignette_06_Comparing_Distributions.Rmd, reconstructing the R ANOVA plot side effects from the returned statistics and adding superiority, dominance, and SD-cluster figures. - 07_clustering_and_regression: restore the file body that was committed truncated after its module docstring, porting every R section including partition orders, X-only partitioning, multivariate regression over the full grid, dimension reduction, stacking, smoothing, and imputation. - 08_classification and _vignette_support: stop rounding non-numeric arrays in the compact result renderer, and display rhs.partitions now that the multivariate result exposes it (correcting the stale gap note). - PARITY.md: update the 07/08 ledger entries to match the ports. - Lint compliance for ruff check across the examples tree, with a scoped E402 ignore for the sys.path bootstrap in instructional scripts, and ignore the generated figure output directory. All nine canonical scripts pass tests/docs/test_vignette_examples.py in fast mode and run clean in full mode; ruff and mypy pass. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014q6V4fJ7zz6KLAgu3ddhDp
1 parent 6fe73da commit e014162

13 files changed

Lines changed: 1596 additions & 99 deletions

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,6 @@ Rplots.pdf
3535

3636
# MkDocs build output
3737
/site/
38+
39+
# Generated vignette figures
40+
/examples/vignettes/output/

examples/_vignette_support.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99

1010
import csv
1111
import os
12+
from collections.abc import Iterable, Sequence
1213
from pathlib import Path
1314
from pprint import pformat
14-
from typing import Any, Iterable, Sequence
15+
from typing import Any
1516

1617
import matplotlib
1718

@@ -68,12 +69,17 @@ def show(label: str, value: Any, *, precision: int = 6) -> None:
6869

6970
def _compact(value: Any) -> Any:
7071
if isinstance(value, np.ndarray):
72+
numeric = np.issubdtype(value.dtype, np.number)
7173
if value.size <= 20:
72-
return np.round(value, 6).tolist()
74+
return np.round(value, 6).tolist() if numeric else value.tolist()
75+
flat = value.reshape(-1)
76+
head, tail = flat[:5], flat[-5:]
77+
if numeric:
78+
head, tail = np.round(head, 6), np.round(tail, 6)
7379
return {
7480
"shape": list(value.shape),
75-
"head": np.round(value.reshape(-1)[:5], 6).tolist(),
76-
"tail": np.round(value.reshape(-1)[-5:], 6).tolist(),
81+
"head": head.tolist(),
82+
"tail": tail.tolist(),
7783
}
7884
if isinstance(value, dict):
7985
return {key: _compact(item) for key, item in value.items()}
@@ -86,12 +92,17 @@ def table(headers: Sequence[str], rows: Iterable[Sequence[Any]], *, precision: i
8692
rendered = []
8793
for row in rows:
8894
rendered.append(
89-
[f"{item:.{precision}f}" if isinstance(item, (float, np.floating)) else str(item) for item in row]
95+
[
96+
f"{item:.{precision}f}" if isinstance(item, (float, np.floating)) else str(item)
97+
for item in row
98+
]
9099
)
91100
widths = [len(str(header)) for header in headers]
92101
for row in rendered:
93102
widths = [max(width, len(cell)) for width, cell in zip(widths, row, strict=True)]
94-
print(" ".join(str(header).ljust(width) for header, width in zip(headers, widths, strict=True)))
103+
print(
104+
" ".join(str(header).ljust(width) for header, width in zip(headers, widths, strict=True))
105+
)
95106
print(" ".join("-" * width for width in widths))
96107
for row in rendered:
97108
print(" ".join(cell.ljust(width) for cell, width in zip(row, widths, strict=True)))

0 commit comments

Comments
 (0)