Repository navigation
Closed
Description
If you've been following travis recently, we're getting a lot of warnings about numpy matrix vs. ndarray... there's over 20,000 of them.
The cause is one test (I think):
statsmodels/statsmodels/stats/tests/test_corrpsd.py
Lines 309 to 339 in ec672ec
| @pytest.mark.parametrize('dm', [1, 2]) | |
| def test_corr_nearest_factor_sparse(self, dm): | |
| # Test that result is the same if the input is dense or sparse | |
| d = 100 | |
| # Generate a test matrix of factors | |
| X = np.zeros((d, dm), dtype=np.float64) | |
| x = np.linspace(0, 2 * np.pi, d) | |
| np.random.seed(10) | |
| for j in range(dm): | |
| X[:, j] = np.sin(x * (j + 1)) + 1e-10 * np.random.randn(d) | |
| # Get the correlation matrix | |
| _project_correlation_factors(X) | |
| X *= 0.7 | |
| mat = np.dot(X, X.T) | |
| np.fill_diagonal(mat, 1) | |
| # Threshold it | |
| mat *= (np.abs(mat) >= 0.35) | |
| smat = sparse.csr_matrix(mat) | |
| rslt = corr_nearest_factor(mat, dm, maxiter=10000) | |
| assert rslt.Converged is True | |
| mat_dense = rslt.corr.to_matrix() | |
| rslt = corr_nearest_factor(smat, dm, maxiter=10000) | |
| assert rslt.Converged is True | |
| mat_sparse = rslt.corr.to_matrix() | |
| assert_allclose(mat_dense, mat_sparse, rtol=.25, atol=1e-3) |
Metadata
Metadata
Assignees
Labels
No labels
Activity
josef-pkt commentedon Oct 19, 2018
I think the best would be to set the global warnings filter to warn only once for
PendingDeprecationWarning.numpy will be using more of it for long term "discouraged" features.
If it's only one unit test, then we could catch it locally, but we want to use more scipy sparse without having to catch numpy warnings all the time.
I haven't tried to figure out what has changed so that we get all these warnings suddenly.
josef-pkt commentedon Oct 19, 2018
The warnings are also on appveyor and even the full log file is truncated, at least it was yesterday when I wanted to look at some test failures.
josef-pkt commentedon Oct 19, 2018
@thequackdaddy @bashtage
Do we have somewhere an option to set the pytest filterwarnings?
related usage question:
Is there a way to force pytest to show the warnings immediately instead of at the end?
pytest -s -v path-to-modulestill shows the warning list at the end, and I don't see how I can get the information about which unit tests caused the warning.
bashtage commentedon Oct 20, 2018
Just add a filter here:
https://github.com/statsmodels/statsmodels/blob/master/setup.cfg#L10