Coverage for src/cvxcla/builder.py: 100%

3 statements  

« prev     ^ index     » next       coverage.py v7.16.2, created at 2026-09-29 05:24 +0000

1"""Backward-compatible re-export of the fluent problem builders. 

2 

3Both builders live in the leaf module :mod:`cvxcla._builders`, which imports 

4neither :mod:`cvxcla.cla` nor :mod:`cvxcla.lasso` -- each solver injects itself 

5into its builder via ``.problem(...)``, so the dependency runs one way and the 

6internal import graph stays acyclic. This module re-exports both so the 

7historical import path ``cvxcla.builder.ProblemBuilder`` keeps working. 

8 

9Each builder is a thin, chainable convenience layer over its solver's explicit 

10constructor. Construct one via :meth:`cvxcla.cla.CLA.problem` / 

11:meth:`cvxcla.lasso.Lasso.problem`, chain the constraint methods, and finish with 

12``.trace()``. 

13 

14Examples: 

15 >>> import numpy as np 

16 >>> from cvxcla import CLA 

17 >>> rng = np.random.default_rng(0) 

18 >>> mean = rng.uniform(0.0, 1.0, 4) 

19 >>> covariance = np.eye(4) 

20 >>> cla = CLA.problem(mean, covariance).long_only().budget().trace() 

21 >>> len(cla) > 0 

22 True 

23""" 

24 

25from __future__ import annotations 

26 

27from ._builders import LassoBuilder, ProblemBuilder 

28 

29__all__ = ["LassoBuilder", "ProblemBuilder"]