Skip to content
This repository was archived by the owner on Apr 24, 2024. It is now read-only.

Commit bb0020e

Browse files
committed
rename cond -> rcond
There is a slight mess with the naming condition number in scipy and numpy. scipy uses word `cond` and numpy `rcond`. rcond makes actually more sense because it is a lower bound on the reciprocal condition number.
1 parent 605e7d9 commit bb0020e

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

src/equisolve/numpy/models/linear_model.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def _solve(
106106
y: TensorBlock,
107107
alpha: TensorBlock,
108108
sample_weight: TensorBlock,
109-
cond: Optional[float] = None,
109+
rcond: Optional[float] = None,
110110
) -> TensorBlock:
111111
"""A regularized solver using ``np.linalg.lstsq``."""
112112
self._used_auto_solver = None
@@ -197,9 +197,9 @@ def _solve(
197197
# and b is [y*sqrt(w), 0]
198198
X_eff = np.vstack([sqrt_sw_arr * X_arr, np.diag(np.sqrt(alpha_arr))])
199199
y_eff = np.hstack([y_arr * sqrt_sw_arr.flatten(), np.zeros(num_properties)])
200-
if cond is None:
201-
cond = max(X_arr.shape) * np.finfo(X_arr.dtype.char.lower()).eps
202-
w = scipy.linalg.lstsq(X_eff, y_eff, cond=cond, overwrite_a=True)[0].ravel()
200+
if rcond is None:
201+
rcond = max(X_arr.shape) * np.finfo(X_arr.dtype.char.lower()).eps
202+
w = scipy.linalg.lstsq(X_eff, y_eff, cond=rcond, overwrite_a=True)[0].ravel()
203203
else:
204204
raise ValueError(
205205
f"Unknown solver {self._solver!r} only 'auto', 'cholesky',"
@@ -227,7 +227,7 @@ def fit(
227227
alpha: Union[float, TensorMap] = 1.0,
228228
sample_weight: Union[float, TensorMap] = None,
229229
solver="auto",
230-
cond: Optional[float] = None,
230+
rcond: Optional[float] = None,
231231
) -> None:
232232
"""Fit a regression model to each block in `X`.
233233
@@ -263,7 +263,7 @@ def fit(
263263
on the dual problem (X@X.T) w_dual = y,
264264
the primal weights are obtained by w = X.T @ w_dual
265265
- **"lstsq"**: using :func:`scipy.linalg.lstsq` on the linear system X w = y
266-
:param cond:
266+
:param rcond:
267267
Cut-off ratio for small singular values during the fit. For the purposes of
268268
rank determination, singular values are treated as zero if they are smaller
269269
than `cond` times the largest singular value in "weights" matrix. Only
@@ -306,7 +306,7 @@ def fit(
306306
alpha_block = alpha.block(key)
307307
sw_block = sample_weight.block(key)
308308

309-
weight_block = self._solve(X_block, y_block, alpha_block, sw_block, cond)
309+
weight_block = self._solve(X_block, y_block, alpha_block, sw_block, rcond)
310310

311311
weights_blocks.append(weight_block)
312312

0 commit comments

Comments
 (0)