Skip to content

Commit

Permalink
Merge branch 'master' into warn
Browse files Browse the repository at this point in the history
  • Loading branch information
dswah authored Jul 7, 2018
2 parents d0d7c7a + c3df001 commit 9187445
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
10 changes: 9 additions & 1 deletion pygam/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

from pygam import *
from pygam.utils import check_X, check_y, check_X_y
from pygam.datasets import wage, default, mcycle


# TODO check dtypes works as expected
Expand Down Expand Up @@ -187,3 +186,12 @@ def test_input_data_after_fitting(mcycle_X_y):
with pytest.raises(ValueError):
gam.sample(X, y, weights=weights_nan, n_bootstraps=2)
# # def test_b_spline_basis_clamped_what_we_want():

def test_catch_chol_pos_def_error(default_X_y):
"""
regresion test
doing a gridsearch with a poorly conditioned penalty matrix should not crash
"""
X, y = default_X_y
gam = LogisticGAM().gridsearch(X, y, lam=np.logspace(10, 12, 3))
16 changes: 8 additions & 8 deletions pygam/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ def cholesky(A, sparse=True, verbose=True):
"""
if SKSPIMPORT:
A = sp.sparse.csc_matrix(A)
F = spcholesky(A)

# permutation matrix P
P = sp.sparse.lil_matrix(A.shape)
p = F.P()
P[np.arange(len(p)), p] = 1

# permute
try:
F = spcholesky(A)

# permutation matrix P
P = sp.sparse.lil_matrix(A.shape)
p = F.P()
P[np.arange(len(p)), p] = 1

# permute
L = F.L()
L = P.T.dot(L)
except CholmodNotPositiveDefiniteError as e:
Expand Down

0 comments on commit 9187445

Please sign in to comment.