gamrs 0.1.0a1__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 (112) hide show
  1. gamrs-0.1.0a1/.github/workflows/ci.yml +67 -0
  2. gamrs-0.1.0a1/.github/workflows/release.yml +129 -0
  3. gamrs-0.1.0a1/.gitignore +20 -0
  4. gamrs-0.1.0a1/Cargo.lock +1135 -0
  5. gamrs-0.1.0a1/Cargo.toml +61 -0
  6. gamrs-0.1.0a1/LICENSE +21 -0
  7. gamrs-0.1.0a1/PKG-INFO +150 -0
  8. gamrs-0.1.0a1/README.md +132 -0
  9. gamrs-0.1.0a1/benches/bench_baseline.rs +528 -0
  10. gamrs-0.1.0a1/benches/bench_gaussian.rs +66 -0
  11. gamrs-0.1.0a1/pyproject.toml +29 -0
  12. gamrs-0.1.0a1/python/gamrs/__init__.py +67 -0
  13. gamrs-0.1.0a1/python/gamrs/_coerce.py +0 -0
  14. gamrs-0.1.0a1/python/gamrs/_fitter.py +705 -0
  15. gamrs-0.1.0a1/python/gamrs/_low_level.py +280 -0
  16. gamrs-0.1.0a1/python/gamrs/_persistence.py +103 -0
  17. gamrs-0.1.0a1/python/gamrs/_predictor.py +218 -0
  18. gamrs-0.1.0a1/python/gamrs/_stubs.py +77 -0
  19. gamrs-0.1.0a1/src/basis/cr.rs +451 -0
  20. gamrs-0.1.0a1/src/basis/mod.rs +13 -0
  21. gamrs-0.1.0a1/src/basis/re.rs +196 -0
  22. gamrs-0.1.0a1/src/basis/tensor.rs +472 -0
  23. gamrs-0.1.0a1/src/design/additive.rs +535 -0
  24. gamrs-0.1.0a1/src/design/cr.rs +247 -0
  25. gamrs-0.1.0a1/src/design/mod.rs +244 -0
  26. gamrs-0.1.0a1/src/design/re.rs +95 -0
  27. gamrs-0.1.0a1/src/design/tensor.rs +307 -0
  28. gamrs-0.1.0a1/src/error.rs +15 -0
  29. gamrs-0.1.0a1/src/family/bernoulli.rs +86 -0
  30. gamrs-0.1.0a1/src/family/elf.rs +185 -0
  31. gamrs-0.1.0a1/src/family/gamma.rs +122 -0
  32. gamrs-0.1.0a1/src/family/gaussian.rs +47 -0
  33. gamrs-0.1.0a1/src/family/inverse_gaussian.rs +96 -0
  34. gamrs-0.1.0a1/src/family/link.rs +106 -0
  35. gamrs-0.1.0a1/src/family/mod.rs +89 -0
  36. gamrs-0.1.0a1/src/family/negbin.rs +110 -0
  37. gamrs-0.1.0a1/src/family/ocat.rs +305 -0
  38. gamrs-0.1.0a1/src/family/poisson.rs +82 -0
  39. gamrs-0.1.0a1/src/family/quasi.rs +92 -0
  40. gamrs-0.1.0a1/src/family/tdist.rs +122 -0
  41. gamrs-0.1.0a1/src/family/tweedie.rs +280 -0
  42. gamrs-0.1.0a1/src/fit/canonical.rs +321 -0
  43. gamrs-0.1.0a1/src/fit/driver.rs +286 -0
  44. gamrs-0.1.0a1/src/fit/family_impls.rs +526 -0
  45. gamrs-0.1.0a1/src/fit/gaussian.rs +99 -0
  46. gamrs-0.1.0a1/src/fit/mod.rs +518 -0
  47. gamrs-0.1.0a1/src/fit/persistence.rs +145 -0
  48. gamrs-0.1.0a1/src/fit/quantile.rs +199 -0
  49. gamrs-0.1.0a1/src/inner/armijo.rs +314 -0
  50. gamrs-0.1.0a1/src/inner/closed_form.rs +182 -0
  51. gamrs-0.1.0a1/src/inner/gam_fit5.rs +269 -0
  52. gamrs-0.1.0a1/src/inner/linalg.rs +318 -0
  53. gamrs-0.1.0a1/src/inner/mod.rs +332 -0
  54. gamrs-0.1.0a1/src/inner/pirls.rs +603 -0
  55. gamrs-0.1.0a1/src/lib.rs +48 -0
  56. gamrs-0.1.0a1/src/outer.rs +308 -0
  57. gamrs-0.1.0a1/src/python.rs +644 -0
  58. gamrs-0.1.0a1/src/score/envelope.rs +370 -0
  59. gamrs-0.1.0a1/src/score/mod.rs +47 -0
  60. gamrs-0.1.0a1/src/score/profile.rs +146 -0
  61. gamrs-0.1.0a1/src/score/shape_aware.rs +696 -0
  62. gamrs-0.1.0a1/src/special.rs +405 -0
  63. gamrs-0.1.0a1/src/traits.rs +352 -0
  64. gamrs-0.1.0a1/src/transform.rs +415 -0
  65. gamrs-0.1.0a1/tests/binomial_smoke.rs +81 -0
  66. gamrs-0.1.0a1/tests/canonical_api.rs +208 -0
  67. gamrs-0.1.0a1/tests/diag_low_signal.rs +111 -0
  68. gamrs-0.1.0a1/tests/family_tests.rs +540 -0
  69. gamrs-0.1.0a1/tests/fixtures/1d_bernoulli_logit_n1000_k10_cr.json +6779 -0
  70. gamrs-0.1.0a1/tests/fixtures/1d_bernoulli_logit_n300_k10_cr.json +2579 -0
  71. gamrs-0.1.0a1/tests/fixtures/1d_gamma_log_n300_k10_cr.json +2584 -0
  72. gamrs-0.1.0a1/tests/fixtures/1d_gaussian_low_signal_n1000_k10_cr.json +6786 -0
  73. gamrs-0.1.0a1/tests/fixtures/1d_gaussian_near_linear_n500_k10_cr.json +3787 -0
  74. gamrs-0.1.0a1/tests/fixtures/1d_gaussian_sigmoid_n300_k10_cr.json +2583 -0
  75. gamrs-0.1.0a1/tests/fixtures/1d_gaussian_smooth_n1000_k50_cr.json +9303 -0
  76. gamrs-0.1.0a1/tests/fixtures/1d_gaussian_smooth_n100_k10_cr.json +1383 -0
  77. gamrs-0.1.0a1/tests/fixtures/1d_gaussian_smooth_n2000_k30_cr.json +13643 -0
  78. gamrs-0.1.0a1/tests/fixtures/1d_gaussian_smooth_n500_k10_cr.json +3784 -0
  79. gamrs-0.1.0a1/tests/fixtures/1d_gaussian_sparse_edges_n400_k10_cr.json +3183 -0
  80. gamrs-0.1.0a1/tests/fixtures/1d_gaussian_step_n500_k10_cr.json +3784 -0
  81. gamrs-0.1.0a1/tests/fixtures/1d_gaussian_wiggly_n500_k20_cr.json +4115 -0
  82. gamrs-0.1.0a1/tests/fixtures/1d_invgauss_log_n300_k10_cr.json +2584 -0
  83. gamrs-0.1.0a1/tests/fixtures/1d_nb_log_n300_k10_cr.json +2583 -0
  84. gamrs-0.1.0a1/tests/fixtures/1d_poisson_log_n300_k10_cr.json +2579 -0
  85. gamrs-0.1.0a1/tests/fixtures/1d_quasibinomial_logit_n300_k10_cr.json +2585 -0
  86. gamrs-0.1.0a1/tests/fixtures/1d_quasipoisson_log_n300_k10_cr.json +2584 -0
  87. gamrs-0.1.0a1/tests/fixtures/1d_scat_unweighted_n300_k10_cr.json +2589 -0
  88. gamrs-0.1.0a1/tests/fixtures/1d_tweedie_log_n300_k10_cr.json +2587 -0
  89. gamrs-0.1.0a1/tests/fixtures/2d_gaussian_additive_n500_k10_cr.json +4699 -0
  90. gamrs-0.1.0a1/tests/fixtures/2d_gaussian_te_n1000_k5x5.json +8482 -0
  91. gamrs-0.1.0a1/tests/fixtures/2d_gaussian_te_n300_k5x5.json +3581 -0
  92. gamrs-0.1.0a1/tests/inner_tests.rs +85 -0
  93. gamrs-0.1.0a1/tests/parity_additive.rs +129 -0
  94. gamrs-0.1.0a1/tests/parity_binomial.rs +123 -0
  95. gamrs-0.1.0a1/tests/parity_gamma.rs +77 -0
  96. gamrs-0.1.0a1/tests/parity_gaussian.rs +171 -0
  97. gamrs-0.1.0a1/tests/parity_gaussian_lu.rs +201 -0
  98. gamrs-0.1.0a1/tests/parity_gaussian_stable.rs +175 -0
  99. gamrs-0.1.0a1/tests/parity_invgauss.rs +80 -0
  100. gamrs-0.1.0a1/tests/parity_negbin.rs +75 -0
  101. gamrs-0.1.0a1/tests/parity_ocat.rs +139 -0
  102. gamrs-0.1.0a1/tests/parity_poisson.rs +87 -0
  103. gamrs-0.1.0a1/tests/parity_quasibinomial.rs +90 -0
  104. gamrs-0.1.0a1/tests/parity_quasipoisson.rs +95 -0
  105. gamrs-0.1.0a1/tests/parity_re.rs +185 -0
  106. gamrs-0.1.0a1/tests/parity_scat.rs +105 -0
  107. gamrs-0.1.0a1/tests/parity_tensor.rs +141 -0
  108. gamrs-0.1.0a1/tests/parity_tweedie.rs +77 -0
  109. gamrs-0.1.0a1/tests/persistence_roundtrip.rs +296 -0
  110. gamrs-0.1.0a1/tests/quantile_smoke.rs +181 -0
  111. gamrs-0.1.0a1/tests/score_tests.rs +363 -0
  112. gamrs-0.1.0a1/tests/tdist_smoke.rs +125 -0
@@ -0,0 +1,67 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [master, main]
6
+ pull_request:
7
+ branches: [master, main]
8
+
9
+ env:
10
+ CARGO_TERM_COLOR: always
11
+
12
+ jobs:
13
+ test-linux:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ - uses: dtolnay/rust-toolchain@stable
18
+ with:
19
+ components: clippy, rustfmt
20
+ - name: Install OpenBLAS
21
+ run: sudo apt-get update && sudo apt-get install -y libopenblas-dev gfortran
22
+ - name: Cache cargo
23
+ uses: Swatinem/rust-cache@v2
24
+ - name: cargo fmt
25
+ run: cargo fmt --all -- --check
26
+ - name: cargo clippy
27
+ run: cargo clippy --all-targets -- -D warnings
28
+ - name: cargo test (release)
29
+ run: cargo test --release
30
+
31
+ test-python:
32
+ runs-on: ubuntu-latest
33
+ steps:
34
+ - uses: actions/checkout@v4
35
+ - uses: dtolnay/rust-toolchain@stable
36
+ - uses: actions/setup-python@v5
37
+ with:
38
+ python-version: "3.11"
39
+ - name: Install OpenBLAS
40
+ run: sudo apt-get update && sudo apt-get install -y libopenblas-dev gfortran
41
+ - name: Create venv + install deps
42
+ run: |
43
+ python -m venv .venv
44
+ source .venv/bin/activate
45
+ python -m pip install --upgrade pip maturin numpy pandas pytest
46
+ - name: maturin develop
47
+ run: |
48
+ source .venv/bin/activate
49
+ maturin develop --release --features python
50
+ - name: Python smoke test
51
+ run: |
52
+ source .venv/bin/activate
53
+ python -c "
54
+ import numpy as np
55
+ import pandas as pd
56
+ from gamrs import Gam, CrTerm
57
+ rng = np.random.default_rng(0)
58
+ n = 200
59
+ x = rng.uniform(0, 1, n)
60
+ y = np.sin(2 * np.pi * x) + rng.normal(0, 0.2, n)
61
+ df = pd.DataFrame({'x': x, 'y': y})
62
+ g = Gam(terms=[CrTerm('x', k=10)])
63
+ g.fit(df, 'y')
64
+ mu = g.predict(df)
65
+ assert mu.shape == (n,)
66
+ print('python smoke OK')
67
+ "
@@ -0,0 +1,129 @@
1
+ name: Release
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+ workflow_dispatch:
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ jobs:
12
+ linux:
13
+ runs-on: ubuntu-latest
14
+ strategy:
15
+ matrix:
16
+ target: [x86_64]
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+ - uses: actions/setup-python@v5
20
+ with:
21
+ python-version: "3.11"
22
+ - name: Build wheels
23
+ uses: PyO3/maturin-action@v1
24
+ env:
25
+ PYO3_USE_ABI3_FORWARD_COMPATIBILITY: "1"
26
+ OPENBLAS_STATIC: "1"
27
+ with:
28
+ target: ${{ matrix.target }}
29
+ args: --release --out dist --find-interpreter --no-default-features --features python
30
+ sccache: "true"
31
+ manylinux: auto
32
+ before-script-linux: |
33
+ set -e
34
+ if command -v yum &> /dev/null; then
35
+ yum install -y gcc-gfortran openssl-devel pkgconfig make cmake perl
36
+ else
37
+ apt-get update && apt-get install -y gfortran libssl-dev pkg-config make cmake perl
38
+ fi
39
+ - name: Validate wheel imports
40
+ run: |
41
+ python -m pip install --upgrade pip numpy pytest
42
+ python -m pip install --no-index --find-links dist/ gamrs
43
+ python -c "import gamrs; print(gamrs.__version__ if hasattr(gamrs, '__version__') else 'imported OK')"
44
+ - uses: actions/upload-artifact@v4
45
+ with:
46
+ name: wheels-linux-${{ matrix.target }}
47
+ path: dist
48
+
49
+ macos:
50
+ runs-on: ${{ matrix.runner }}
51
+ strategy:
52
+ fail-fast: false
53
+ matrix:
54
+ include:
55
+ - target: aarch64
56
+ runner: macos-latest
57
+ steps:
58
+ - uses: actions/checkout@v4
59
+ - uses: actions/setup-python@v5
60
+ with:
61
+ python-version: "3.11"
62
+ - name: Build wheels
63
+ uses: PyO3/maturin-action@v1
64
+ env:
65
+ PYO3_USE_ABI3_FORWARD_COMPATIBILITY: "1"
66
+ with:
67
+ target: ${{ matrix.target }}
68
+ args: --release --out dist --find-interpreter --no-default-features --features python
69
+ sccache: "true"
70
+ - uses: actions/upload-artifact@v4
71
+ with:
72
+ name: wheels-macos-${{ matrix.target }}
73
+ path: dist
74
+
75
+ windows:
76
+ runs-on: windows-latest
77
+ strategy:
78
+ matrix:
79
+ target: [x64]
80
+ steps:
81
+ - uses: actions/checkout@v4
82
+ - uses: actions/setup-python@v5
83
+ with:
84
+ python-version: "3.11"
85
+ architecture: ${{ matrix.target }}
86
+ - name: Build wheels
87
+ uses: PyO3/maturin-action@v1
88
+ env:
89
+ PYO3_USE_ABI3_FORWARD_COMPATIBILITY: "1"
90
+ with:
91
+ target: ${{ matrix.target }}
92
+ args: --release --out dist --find-interpreter --no-default-features --features python
93
+ sccache: "true"
94
+ - uses: actions/upload-artifact@v4
95
+ with:
96
+ name: wheels-windows-${{ matrix.target }}
97
+ path: dist
98
+
99
+ sdist:
100
+ runs-on: ubuntu-latest
101
+ steps:
102
+ - uses: actions/checkout@v4
103
+ - name: Build sdist
104
+ uses: PyO3/maturin-action@v1
105
+ with:
106
+ command: sdist
107
+ args: --out dist
108
+ - uses: actions/upload-artifact@v4
109
+ with:
110
+ name: sdist
111
+ path: dist
112
+
113
+ publish-pypi:
114
+ needs: [linux, macos, windows, sdist]
115
+ runs-on: ubuntu-latest
116
+ steps:
117
+ - uses: actions/download-artifact@v4
118
+ with:
119
+ path: dist
120
+ merge-multiple: true
121
+ - name: Publish to PyPI
122
+ uses: PyO3/maturin-action@v1
123
+ env:
124
+ MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
125
+ with:
126
+ command: upload
127
+ args: --non-interactive --skip-existing dist/*
128
+
129
+ # crates.io publish deferred — wire up later. Tracked in TODO.
@@ -0,0 +1,20 @@
1
+ /target
2
+ **/*.rs.bk
3
+ *.so
4
+ *.dylib
5
+ *.dll
6
+ *.pyd
7
+ __pycache__/
8
+ *.py[cod]
9
+ *.egg-info/
10
+ dist/
11
+ build/
12
+ .venv/
13
+ venv/
14
+ .pytest_cache/
15
+ .mypy_cache/
16
+ .ruff_cache/
17
+ .idea/
18
+ .vscode/
19
+ *.swp
20
+