Skip to content

Lazy scipy imports#486

Merged
dweindl merged 2 commits into
PEtab-dev:mainfrom
dweindl:fix_483_lazy_stats
Jun 9, 2026
Merged

Lazy scipy imports#486
dweindl merged 2 commits into
PEtab-dev:mainfrom
dweindl:fix_483_lazy_stats

Conversation

@dweindl

@dweindl dweindl commented Jun 9, 2026

Copy link
Copy Markdown
Member

For now, keep scipy optional, unless probability distributions are really needed.

Fixes #483.

@codecov-commenter

codecov-commenter commented Jun 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 26 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.33%. Comparing base (f674bd5) to head (e2bb2da).

Files with missing lines Patch % Lines
petab/v1/distributions.py 66.66% 26 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #486      +/-   ##
==========================================
- Coverage   75.43%   75.33%   -0.11%     
==========================================
  Files          62       62              
  Lines        6901     6946      +45     
  Branches     1229     1229              
==========================================
+ Hits         5206     5233      +27     
- Misses       1223     1241      +18     
  Partials      472      472              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dweindl dweindl marked this pull request as ready for review June 9, 2026 09:17
@dweindl dweindl requested a review from a team as a code owner June 9, 2026 09:17

@dilpath dilpath left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment thread petab/v1/distributions.py
Comment on lines +335 to +342
try:
from scipy.stats import norm
except ImportError as e:
raise ImportError(
"scipy is required for this functionality. "
"Install it with: pip install scipy"
) from e
self._dist = norm

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turn into function

@dweindl dweindl Jun 9, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current way enables better static analysis which I'd prefer here. I'll dereplicate the message, though.

For now, keep scipy optional, unless probability distributions are really needed.

Fixes PEtab-dev#483.
@dweindl dweindl force-pushed the fix_483_lazy_stats branch from 094b235 to 7ce0bdd Compare June 9, 2026 10:02
@dweindl dweindl merged commit 1292091 into PEtab-dev:main Jun 9, 2026
7 checks passed
@dweindl dweindl deleted the fix_483_lazy_stats branch June 9, 2026 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot import petab.v2 without scipy installed

3 participants