Skip to content

Make scipy an optional dependency #3

@thomaspinder

Description

@thomaspinder

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

  1. Move scipy from dependencies to [project.optional-dependencies]:

    [project.optional-dependencies]
    sign = ["scipy>=1.10"]
  2. 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]"
        )
  3. Update documentation to mention the optional dependency.

Impact

Reduces the install footprint for users who only need Cholesky identification.

Labels

enhancement, dependencies

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions