Problem
scipy is currently a required dependency, but it's only used by SignRestriction in identification.py (specifically scipy.stats.special_ortho_group for generating random rotation matrices).
Proposed Solution
-
Move scipy from dependencies to [project.optional-dependencies]:
[project.optional-dependencies]
sign = ["scipy>=1.10"]
-
Add a lazy import with a clear error message in SignRestriction:
try:
from scipy.stats import special_ortho_group
except ImportError:
raise ImportError(
"scipy is required for sign restrictions. "
"Install with: pip install litterman[sign]"
)
-
Update documentation to mention the optional dependency.
Impact
Reduces the install footprint for users who only need Cholesky identification.
Labels
enhancement, dependencies
Problem
scipyis currently a required dependency, but it's only used bySignRestrictioninidentification.py(specificallyscipy.stats.special_ortho_groupfor generating random rotation matrices).Proposed Solution
Move
scipyfromdependenciesto[project.optional-dependencies]:Add a lazy import with a clear error message in
SignRestriction:Update documentation to mention the optional dependency.
Impact
Reduces the install footprint for users who only need Cholesky identification.
Labels
enhancement, dependencies