Coverage for src/cvxcla/builder.py: 100%
4 statements
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-11 09:58 +0000
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-11 09:58 +0000
1"""Backward-compatible re-export of the fluent problem builders.
3The builders are co-located with the objects they construct -- to keep the
4internal import graph acyclic, :class:`ProblemBuilder` lives with
5:class:`cvxcla.cla.CLA` in :mod:`cvxcla.cla` and :class:`LassoBuilder` lives with
6:class:`cvxcla.lasso.Lasso` in :mod:`cvxcla.lasso`. This module re-exports both so
7the historical import path ``cvxcla.builder.ProblemBuilder`` keeps working.
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()``.
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"""
25from __future__ import annotations
27from .cla import ProblemBuilder
28from .lasso import LassoBuilder
30__all__ = ["LassoBuilder", "ProblemBuilder"]