Skip to content

Make scipy an optional dependency #3

Closed

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

Activity

  1. thomaspinder commented on Jul 29, 2026

    @thomaspinder
    CollaboratorAuthor

    Obsolete by evolution. scipy is no longer confined to SignRestriction: it is imported at module level by the conjugate estimator (src/impulso/_conjugate.py:32-33 — multigammaln, invwishart), its hyperparameter sampler (src/impulso/_conjugate_sampler.py:31-33 — optimize, special.expit, stats.gamma), and the pandemic-break hyperpriors (src/impulso/conjugate_volatility.py:28), with scipy.stats.chi2 also used in fitted.py:256 and identified.py:629. Making it optional would push ConjugateVAR behind an extra for no meaningful install-footprint win. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions