fix: replace numpy/scipy with pure Python in experiment analytics#6830
Merged
Conversation
Removes significant per-worker RSS overhead by replacing numpy and scipy with stdlib math and random modules. The experiment analytics endpoint is demo-only code, so the minor latency trade-off is well worth the memory savings. - Implement G-test via log-likelihood ratio + incomplete gamma function - Use random.betavariate for Bayesian Monte Carlo (10k samples) - Remove numpy and scipy from pyproject.toml and poetry.lock - Convert tests from class-based to function-based
|
The latest updates on your projects. Learn more about Vercel for GitHub. 3 Skipped Deployments
|
for more information, see https://pre-commit.ci
Contributor
Docker builds report
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6830 +/- ##
==========================================
+ Coverage 98.30% 98.32% +0.02%
==========================================
Files 1331 1331
Lines 49332 49394 +62
==========================================
+ Hits 48494 48568 +74
+ Misses 838 826 -12 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Cover all new code paths through the public calculate_statistics API and mark unreachable numerical guards with pragma: no cover.
for more information, see https://pre-commit.ci
Zaimwa9
approved these changes
Mar 3, 2026
Contributor
Zaimwa9
left a comment
There was a problem hiding this comment.
Thanks, that's a lot of maths for fake graphs 😄
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Removes numpy and scipy dependencies from the API, replacing them with pure Python (stdlib
mathandrandom) implementations. These libraries added significant per-worker RSS overhead but are only used by the demo experiment analytics endpoint.random.betavariatefor Bayesian Monte Carlo simulation (10k samples)pyproject.tomland regeneratepoetry.lockHow did you test this code?
pytest tests/unit/app_analytics/test_experiments.py)