diff --git a/nltools/data/design_matrix.py b/nltools/data/design_matrix.py index 036b2d46..a8b83404 100644 --- a/nltools/data/design_matrix.py +++ b/nltools/data/design_matrix.py @@ -782,6 +782,8 @@ def clean(self, fill_na=0, exclude_polys=False, thresh=0.95, verbose=True): ) old_settings = np.seterr(all="ignore") + + out = self.copy() if fill_na is not None: out = self.fillna(fill_na) diff --git a/nltools/tests/test_design_matrix.py b/nltools/tests/test_design_matrix.py index 5c65dcb9..e6adbb17 100644 --- a/nltools/tests/test_design_matrix.py +++ b/nltools/tests/test_design_matrix.py @@ -138,6 +138,10 @@ def test_clean(sim_design_matrix): out = corr_cols.clean(verbose=True) assert out.shape[1] < corr_cols.shape[1] + # Test for bug #413 about args combinations + out = corr_cols.clean(fill_na=None, exclude_polys=True, verbose=True) + assert out.shape[1] < corr_cols.shape[1] + # Raise an error if try to clean with an input matrix that has duplicate column names dup_cols = pd.concat([sim_design_matrix, sim_design_matrix], axis=1) with pytest.raises(ValueError):