forestgeom 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 (62) hide show
  1. forestgeom-0.1.0/.github/workflows/deploy.yml +76 -0
  2. forestgeom-0.1.0/.github/workflows/test.yml +100 -0
  3. forestgeom-0.1.0/.gitignore +152 -0
  4. forestgeom-0.1.0/CONTRIBUTING.md +192 -0
  5. forestgeom-0.1.0/LICENSE +674 -0
  6. forestgeom-0.1.0/PKG-INFO +433 -0
  7. forestgeom-0.1.0/README.md +370 -0
  8. forestgeom-0.1.0/constraints/lowest-boosted.txt +5 -0
  9. forestgeom-0.1.0/constraints/lowest-core.txt +3 -0
  10. forestgeom-0.1.0/constraints/sklearn-1.3.txt +1 -0
  11. forestgeom-0.1.0/constraints/sklearn-1.4.txt +1 -0
  12. forestgeom-0.1.0/constraints/sklearn-1.5.txt +1 -0
  13. forestgeom-0.1.0/constraints/sklearn-1.6.txt +1 -0
  14. forestgeom-0.1.0/constraints/sklearn-1.7.txt +1 -0
  15. forestgeom-0.1.0/dataset.py +245 -0
  16. forestgeom-0.1.0/demos/demo_boosted.ipynb +329 -0
  17. forestgeom-0.1.0/demos/demo_iris.ipynb +2565 -0
  18. forestgeom-0.1.0/demos/demo_leaf_pca.ipynb +939 -0
  19. forestgeom-0.1.0/experiments/ablations.py +1014 -0
  20. forestgeom-0.1.0/experiments/baselines/__init__.py +1 -0
  21. forestgeom-0.1.0/experiments/baselines/naive_dense.py +121 -0
  22. forestgeom-0.1.0/experiments/baselines/pagerank_phate.py +46 -0
  23. forestgeom-0.1.0/experiments/baselines/rfgap.py +570 -0
  24. forestgeom-0.1.0/experiments/dataset_summary_table.tex +20 -0
  25. forestgeom-0.1.0/experiments/leaf_embedding.py +1234 -0
  26. forestgeom-0.1.0/experiments/notebooks/ablation.ipynb +1307 -0
  27. forestgeom-0.1.0/experiments/notebooks/embeddings.ipynb +753 -0
  28. forestgeom-0.1.0/experiments/notebooks/sanity_check_kernel_predict.ipynb +210 -0
  29. forestgeom-0.1.0/experiments/notebooks/separable_oob.ipynb +268 -0
  30. forestgeom-0.1.0/experiments/quick_benchmark.py +285 -0
  31. forestgeom-0.1.0/experiments/runtime_utils.py +423 -0
  32. forestgeom-0.1.0/experiments/separable_oob_check.py +460 -0
  33. forestgeom-0.1.0/experiments/summary_datasets.py +165 -0
  34. forestgeom-0.1.0/pyproject.toml +72 -0
  35. forestgeom-0.1.0/pytest.ini +6 -0
  36. forestgeom-0.1.0/src/forestgeom/__init__.py +3 -0
  37. forestgeom-0.1.0/src/forestgeom/adapters/__init__.py +88 -0
  38. forestgeom-0.1.0/src/forestgeom/adapters/base.py +92 -0
  39. forestgeom-0.1.0/src/forestgeom/adapters/gbt.py +134 -0
  40. forestgeom-0.1.0/src/forestgeom/adapters/lgbm.py +178 -0
  41. forestgeom-0.1.0/src/forestgeom/adapters/rf_et.py +81 -0
  42. forestgeom-0.1.0/src/forestgeom/adapters/xgb.py +185 -0
  43. forestgeom-0.1.0/src/forestgeom/maps/__init__.py +18 -0
  44. forestgeom-0.1.0/src/forestgeom/maps/builders.py +451 -0
  45. forestgeom-0.1.0/src/forestgeom/maps/cache.py +60 -0
  46. forestgeom-0.1.0/src/forestgeom/maps/sparse_utils.py +81 -0
  47. forestgeom-0.1.0/src/forestgeom/proximity.py +502 -0
  48. forestgeom-0.1.0/tests/__init__.py +0 -0
  49. forestgeom-0.1.0/tests/conftest.py +2 -0
  50. forestgeom-0.1.0/tests/fixtures/constants.py +65 -0
  51. forestgeom-0.1.0/tests/fixtures/data_fixtures.py +53 -0
  52. forestgeom-0.1.0/tests/fixtures/forest_fixtures.py +95 -0
  53. forestgeom-0.1.0/tests/integration/test_boosted_integration.py +34 -0
  54. forestgeom-0.1.0/tests/integration/test_prediction_integration.py +61 -0
  55. forestgeom-0.1.0/tests/prediction_helpers.py +22 -0
  56. forestgeom-0.1.0/tests/unit/test_fit_forest_fake_estimator.py +21 -0
  57. forestgeom-0.1.0/tests/unit/test_maps.py +145 -0
  58. forestgeom-0.1.0/tests/unit/test_optional_dependencies.py +42 -0
  59. forestgeom-0.1.0/tests/unit/test_prediction.py +52 -0
  60. forestgeom-0.1.0/tests/unit/test_proximity.py +133 -0
  61. forestgeom-0.1.0/tox.ini +95 -0
  62. forestgeom-0.1.0/uv.lock +1715 -0
@@ -0,0 +1,76 @@
1
+ name: Publish Python 🐍 distributions to PyPI 📦
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+ - "test-v*"
8
+
9
+ jobs:
10
+ build-publish-release:
11
+ name: Build, publish, and create GitHub release
12
+ runs-on: ubuntu-latest
13
+
14
+ environment:
15
+ name: ${{ startsWith(github.ref_name, 'test-v') && 'testpypi' || 'pypi' }}
16
+
17
+ permissions:
18
+ id-token: write
19
+ contents: write
20
+
21
+ steps:
22
+ - name: Check out tagged commit
23
+ uses: actions/checkout@v6
24
+ with:
25
+ fetch-depth: 0
26
+
27
+ - name: Install uv
28
+ uses: astral-sh/setup-uv@v7
29
+
30
+ - name: Verify tag matches pyproject.toml version
31
+ run: |
32
+ VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
33
+ TAG="${GITHUB_REF_NAME}"
34
+
35
+ if [[ "${TAG}" == test-v* ]]; then
36
+ EXPECTED_TAG="test-v${VERSION}"
37
+ else
38
+ EXPECTED_TAG="v${VERSION}"
39
+ fi
40
+
41
+ if [ "${TAG}" != "${EXPECTED_TAG}" ]; then
42
+ echo "Tag ${TAG} does not match pyproject.toml version ${VERSION}."
43
+ echo "Expected tag: ${EXPECTED_TAG}"
44
+ exit 1
45
+ fi
46
+
47
+ - name: Build package
48
+ run: uv build
49
+
50
+ - name: Publish to TestPyPI
51
+ if: startsWith(github.ref_name, 'test-v')
52
+ run: uv publish --publish-url https://test.pypi.org/legacy/
53
+
54
+ - name: Publish to PyPI
55
+ if: startsWith(github.ref_name, 'v')
56
+ run: uv publish
57
+
58
+ - name: Create GitHub prerelease
59
+ if: startsWith(github.ref_name, 'test-v')
60
+ uses: softprops/action-gh-release@v2
61
+ with:
62
+ generate_release_notes: true
63
+ prerelease: true
64
+ files: |
65
+ dist/*.whl
66
+ dist/*.tar.gz
67
+
68
+ - name: Create GitHub release
69
+ if: startsWith(github.ref_name, 'v')
70
+ uses: softprops/action-gh-release@v2
71
+ with:
72
+ generate_release_notes: true
73
+ prerelease: false
74
+ files: |
75
+ dist/*.whl
76
+ dist/*.tar.gz
@@ -0,0 +1,100 @@
1
+ name: Tests
2
+
3
+ on:
4
+ # push:
5
+ # pull_request:
6
+ workflow_dispatch:
7
+
8
+ jobs:
9
+ tox:
10
+ name: ${{ matrix.os }} / ${{ matrix.tox-env }}
11
+ runs-on: ${{ matrix.os }}
12
+
13
+ strategy:
14
+ fail-fast: false
15
+ matrix:
16
+ include:
17
+ # Lower-bound discovery: oldest supported Python with oldest
18
+ # candidate dependency stack.
19
+ - os: ubuntu-latest
20
+ python: "3.10"
21
+ tox-env: py310-lowest-core
22
+
23
+ # Latest dependency stack across supported Python versions.
24
+ - os: ubuntu-latest
25
+ python: "3.10"
26
+ tox-env: py310-latest
27
+ - os: ubuntu-latest
28
+ python: "3.11"
29
+ tox-env: py311-latest
30
+ - os: ubuntu-latest
31
+ python: "3.12"
32
+ tox-env: py312-latest
33
+ - os: ubuntu-latest
34
+ python: "3.13"
35
+ tox-env: py313-latest
36
+ - os: ubuntu-latest
37
+ python: "3.14"
38
+ tox-env: py314-latest
39
+
40
+ # Cross-machine smoke coverage. Full dependency sweeps stay on Linux
41
+ # to keep CI time reasonable.
42
+ - os: macos-latest
43
+ python: "3.12"
44
+ tox-env: py312-latest
45
+ - os: windows-latest
46
+ python: "3.12"
47
+ tox-env: py312-latest
48
+
49
+ # scikit-learn compatibility sweep. sklearn is the highest-risk core
50
+ # dependency because forest adapters use sklearn forest internals.
51
+ - os: ubuntu-latest
52
+ python: "3.10"
53
+ tox-env: py310-sklearn-1.3
54
+ - os: ubuntu-latest
55
+ python: "3.10"
56
+ tox-env: py310-sklearn-1.4
57
+ - os: ubuntu-latest
58
+ python: "3.10"
59
+ tox-env: py310-sklearn-1.5
60
+ - os: ubuntu-latest
61
+ python: "3.10"
62
+ tox-env: py310-sklearn-1.6
63
+ - os: ubuntu-latest
64
+ python: "3.10"
65
+ tox-env: py310-sklearn-1.7
66
+
67
+ # Optional boosted adapters.
68
+ - os: ubuntu-latest
69
+ python: "3.10"
70
+ tox-env: py310-lowest-boosted
71
+ - os: ubuntu-latest
72
+ python: "3.10"
73
+ tox-env: py310-latest-boosted
74
+ - os: ubuntu-latest
75
+ python: "3.11"
76
+ tox-env: py311-latest-boosted
77
+ - os: ubuntu-latest
78
+ python: "3.12"
79
+ tox-env: py312-latest-boosted
80
+ - os: ubuntu-latest
81
+ python: "3.13"
82
+ tox-env: py313-latest-boosted
83
+
84
+ steps:
85
+ - name: Check out repository
86
+ uses: actions/checkout@v6
87
+
88
+ - name: Install uv
89
+ uses: astral-sh/setup-uv@v7
90
+ with:
91
+ enable-cache: true
92
+ cache-suffix: ${{ matrix.tox-env }}
93
+
94
+ - name: Set up Python ${{ matrix.python }}
95
+ uses: actions/setup-python@v6
96
+ with:
97
+ python-version: ${{ matrix.python }}
98
+
99
+ - name: Run tox scenario
100
+ run: uvx tox -e ${{ matrix.tox-env }}
@@ -0,0 +1,152 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # vscode
10
+ .vscode/
11
+
12
+ # conda
13
+ .condaenv/
14
+
15
+ # Data and results
16
+ experiments/results/
17
+ datasets/
18
+ data/
19
+ experiments/notebooks/compiled_embedding_figure/
20
+ experiments/notebooks/compiled_ablation_figures/
21
+ experiments/notebooks/compiled_oob_figure/
22
+
23
+
24
+ nohup.out
25
+
26
+ # macOS system files
27
+ .DS_Store
28
+ **/.DS_Store
29
+
30
+ # Distribution / packaging
31
+ .Python
32
+ build/
33
+ develop-eggs/
34
+ dist/
35
+ downloads/
36
+ eggs/
37
+ .eggs/
38
+ lib/
39
+ lib64/
40
+ parts/
41
+ sdist/
42
+ var/
43
+ wheels/
44
+ pip-wheel-metadata/
45
+ share/python-wheels/
46
+ *.egg-info/
47
+ .installed.cfg
48
+ *.egg
49
+ MANIFEST
50
+
51
+ # PyInstaller
52
+ # Usually these files are written by a python script from a template
53
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
54
+ *.manifest
55
+ *.spec
56
+
57
+ # Installer logs
58
+ pip-log.txt
59
+ pip-delete-this-directory.txt
60
+
61
+ # Unit test / coverage reports
62
+ htmlcov/
63
+ .tox/
64
+ .nox/
65
+ .coverage
66
+ .coverage.*
67
+ .cache
68
+ nosetests.xml
69
+ coverage.xml
70
+ *.cover
71
+ *.py,cover
72
+ .hypothesis/
73
+ .pytest_cache/
74
+
75
+ # Translations
76
+ *.mo
77
+ *.pot
78
+
79
+ # Django stuff:
80
+ *.log
81
+ local_settings.py
82
+ db.sqlite3
83
+ db.sqlite3-journal
84
+
85
+ # Flask stuff:
86
+ instance/
87
+ .webassets-cache
88
+
89
+ # Scrapy stuff:
90
+ .scrapy
91
+
92
+ # Sphinx documentation
93
+ docs/_build/
94
+
95
+ # PyBuilder
96
+ target/
97
+
98
+ # Jupyter Notebook
99
+ .ipynb_checkpoints
100
+
101
+ # IPython
102
+ profile_default/
103
+ ipython_config.py
104
+
105
+ # pyenv
106
+ .python-version
107
+
108
+ # pipenv
109
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
110
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
111
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
112
+ # install all needed dependencies.
113
+ #Pipfile.lock
114
+
115
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
116
+ __pypackages__/
117
+
118
+ # Celery stuff
119
+ celerybeat-schedule
120
+ celerybeat.pid
121
+
122
+ # SageMath parsed files
123
+ *.sage.py
124
+
125
+ # Environments
126
+ .env
127
+ .venv
128
+ env/
129
+ venv/
130
+ ENV/
131
+ env.bak/
132
+ venv.bak/
133
+
134
+ # Spyder project settings
135
+ .spyderproject
136
+ .spyproject
137
+
138
+ # Rope project settings
139
+ .ropeproject
140
+
141
+ # mkdocs documentation
142
+ /site
143
+
144
+ # mypy
145
+ .mypy_cache/
146
+ .dmypy.json
147
+ dmypy.json
148
+
149
+ # Pyre type checker
150
+ .pyre/
151
+
152
+
@@ -0,0 +1,192 @@
1
+ # Contributing
2
+
3
+ Thank you for contributing to `forestgeom`!
4
+
5
+ ## Clone the repository
6
+
7
+ ```bash
8
+ git clone https://github.com/JakeSRhodesLab/ForestGeom.git
9
+ cd ForestGeom
10
+ ```
11
+
12
+ ## Create a development environment
13
+
14
+ We recommend [`uv`](https://docs.astral.sh/uv/) for development. From the
15
+ repository root, create a local environment and install the project with test
16
+ dependencies:
17
+
18
+ ```bash
19
+ uv sync --extra test
20
+ ```
21
+
22
+ Install optional dependency groups only when needed:
23
+
24
+ ```bash
25
+ # boosted tree support
26
+ uv sync --extra boosted --extra test
27
+
28
+ # visualization dependencies
29
+ uv sync --extra viz --extra test
30
+
31
+ # experiment dependencies
32
+ uv sync --extra experiments --extra test
33
+ ```
34
+
35
+ `uv sync` installs the project in editable mode, so local source changes are
36
+ immediately importable.
37
+
38
+ <details>
39
+ <summary>pip also works</summary>
40
+
41
+ ```bash
42
+ python -m venv .venv
43
+ source .venv/bin/activate
44
+ python -m pip install -U pip
45
+ python -m pip install -e ".[test]"
46
+ python -m pip install -e ".[boosted]"
47
+ python -m pip install -e ".[viz]"
48
+ python -m pip install -e ".[experiments]"
49
+ ```
50
+
51
+ </details>
52
+
53
+ ## Build distributions
54
+
55
+ The project uses Hatchling as its PEP 517 build backend. To verify that the
56
+ source distribution and wheel build correctly, run:
57
+
58
+ ```bash
59
+ uv build
60
+ ```
61
+
62
+ Build artifacts are written to `dist/`.
63
+
64
+ If you are preparing a release, clean old artifacts before building:
65
+
66
+ ```bash
67
+ rm -rf dist/
68
+ uv build
69
+ ```
70
+
71
+ ## Release publishing
72
+
73
+ Releases are tag-driven. The GitHub deploy workflow in
74
+ `.github/workflows/deploy.yml` runs only when a tag is pushed, and it uses the
75
+ tag name to decide whether to publish to TestPyPI or PyPI.
76
+
77
+ Release tag conventions:
78
+
79
+ - `test-v<version>` publishes to TestPyPI and creates a GitHub prerelease.
80
+ - `v<version>` publishes to PyPI and creates a normal GitHub release.
81
+
82
+ The workflow checks that the pushed tag matches `project.version` in
83
+ `pyproject.toml` before publishing.
84
+
85
+ GitHub environment protection is enabled for both `testpypi` and `pypi`, so
86
+ selected approved maintainers must review the deploy before publication.
87
+
88
+ Recommended release steps:
89
+
90
+ 1. Bump `project.version` in `pyproject.toml`.
91
+ 2. Build and test locally.
92
+ 3. Create the release tag that matches the version:
93
+
94
+ ```bash
95
+ git tag -a test-v0.0.4 -m "Release v0.0.4 to TestPyPI"
96
+ git push origin test-v0.0.4
97
+
98
+ # or, for the final PyPI release
99
+ git tag -a v0.0.4 -m "Release v0.0.4"
100
+ git push origin v0.0.4
101
+ ```
102
+
103
+ 4. Approve the deploy in GitHub if your environment requires review.
104
+
105
+ The workflow will then build the package, publish to the correct index, and
106
+ attach the release artifacts to GitHub.
107
+
108
+ ## Run tests
109
+
110
+ The project uses three levels of testing. Use the lowest level that answers the
111
+ question you have, and run broader checks before releases or dependency changes.
112
+
113
+ ### 1. Current development environment
114
+
115
+ For ordinary local development, run pytest in your active `uv` environment:
116
+
117
+ ```bash
118
+ uv run pytest
119
+ ```
120
+
121
+ This is the fastest feedback loop. It tests the code against the exact Python
122
+ interpreter and dependency versions installed in your local `.venv`.
123
+
124
+ To include optional boosted-tree adapters in this local environment, sync the
125
+ extra first:
126
+
127
+ ```bash
128
+ uv sync --extra boosted --extra test
129
+ uv run pytest
130
+ ```
131
+
132
+ ### 2. Local compatibility sweep
133
+
134
+ Use `tox` when you need to check package metadata against multiple Python and
135
+ dependency scenarios on your machine. The tox environments are defined in
136
+ `tox.ini`, and dependency lower-bound scenarios are pinned with files in
137
+ `constraints/`.
138
+
139
+ Run one scenario:
140
+
141
+ ```bash
142
+ uvx tox -e py310-lowest-core
143
+ uvx tox -e py310-latest-boosted
144
+ ```
145
+
146
+ Run the full local sweep:
147
+
148
+ ```bash
149
+ uvx tox
150
+ ```
151
+
152
+ Run the full local sweep in parallel with live output:
153
+
154
+ ```bash
155
+ uvx tox -p auto --parallel-live
156
+ ```
157
+
158
+ The sweep covers:
159
+
160
+ - lowest supported core dependency stack on Python 3.10
161
+ - latest core dependency stack across supported Python versions
162
+ - scikit-learn compatibility scenarios from 1.3 through 1.7
163
+ - lowest and latest optional boosted dependency stacks
164
+
165
+ If a scenario is skipped, the corresponding Python interpreter is probably not
166
+ installed locally. GitHub Actions installs the requested Python versions
167
+ explicitly.
168
+
169
+ ### 3. GitHub Actions matrix
170
+
171
+ The highest-level check is the GitHub Actions test workflow in
172
+ `.github/workflows/test.yml`. It runs the tox compatibility matrix on CI: Linux
173
+ handles the full Python/dependency sweep, while macOS and Windows run selected
174
+ smoke scenarios to catch machine-specific issues without duplicating the entire
175
+ matrix.
176
+
177
+ Use the GitHub workflow as the final source of truth before publishing or
178
+ merging dependency-bound changes.
179
+
180
+ ## Notes
181
+
182
+ - Use a virtual environment for development work.
183
+ - `uv sync` is recommended for contributors; pip editable installs remain
184
+ supported.
185
+ - Use `uv run pytest` for day-to-day checks, `uvx tox` for local
186
+ compatibility sweeps, and the GitHub Actions workflow for the full remote
187
+ matrix.
188
+ - Hatchling is configured in `pyproject.toml`; contributors do not need a
189
+ `setup.py` or `setup.cfg`.
190
+ - Some optional dependencies (e.g. `lightgbm` or `xgboost`) may require
191
+ additional system-level installation steps. Refer to the corresponding
192
+ project documentation if needed.