diff --git a/pygam/penalties.py b/pygam/penalties.py old mode 100644 new mode 100755 index aee1d2a0..c2bf354c --- a/pygam/penalties.py +++ b/pygam/penalties.py @@ -257,7 +257,7 @@ def none(n, coef): ------- penalty matrix : sparse csc matrix of shape (n,n) """ - return sp.sparse.csc_matrix(np.zeros((n, n))) + return sp.sparse.csc_matrix((n, n)) def wrap_penalty(p, fit_linear, linear_penalty=0.): """ diff --git a/pygam/terms.py b/pygam/terms.py old mode 100644 new mode 100755 index 117584b4..3843f3bf --- a/pygam/terms.py +++ b/pygam/terms.py @@ -625,7 +625,7 @@ def __init__(self, feature, n_splines=20, spline_order=3, lam=0.6, Type of basis function to use in the term. 'ps' : p-spline basis - + 'cp' : cyclic p-spline basis, useful for building periodic functions. by default, the maximum and minimum of the feature values are used to determine the function's period. @@ -1315,7 +1315,7 @@ def build_penalties(self): ------- P : sparse CSC matrix containing the model penalties in quadratic form """ - P = sp.sparse.csc_matrix(np.zeros((self.n_coefs, self.n_coefs))) + P = sp.sparse.csc_matrix((self.n_coefs, self.n_coefs)) for i in range(len(self._terms)): P += self._build_marginal_penalties(i) @@ -1361,7 +1361,7 @@ def build_constraints(self, coef, constraint_lam, constraint_l2): ------- C : sparse CSC matrix containing the model constraints in quadratic form """ - C = sp.sparse.csc_matrix(np.zeros((self.n_coefs, self.n_coefs))) + C = sp.sparse.csc_matrix((self.n_coefs, self.n_coefs)) for i in range(len(self._terms)): C += self._build_marginal_constraints(i, coef, constraint_lam, constraint_l2) @@ -1397,7 +1397,7 @@ def _build_marginal_constraints(self, i, coef, constraint_lam, constraint_l2): C : sparse CSC matrix containing the model constraints in quadratic form """ - composite_C = np.zeros((len(coef), len(coef))) + composite_C = sp.sparse.csc_matrix((len(coef), len(coef))) for slice_ in self._iterate_marginal_coef_slices(i): # get the slice of coefficient vector