Skip to content

Lots of warnings in travis from scipy sparse matrix test #5329

Closed

Description

@thequackdaddy

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):

@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)

Activity

  1. josef-pkt commented on Oct 19, 2018

    @josef-pkt
    Member

    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.

  2. josef-pkt commented on Oct 19, 2018

    @josef-pkt
    Member

    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.

  3. josef-pkt commented on Oct 19, 2018

    @josef-pkt
    Member

    @thequackdaddy @bashtage
    Do we have somewhere an option to set the pytest filterwarnings?

    [pytest]
    filterwarnings =
                    once::PendingDeprecationWarning
    

    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-module
    still 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.

  4. bashtage commented on Oct 20, 2018

    @bashtage
    Member

    Just add a filter here:

    https://github.com/statsmodels/statsmodels/blob/master/setup.cfg#L10

    ignore:the matrix subclass:numpy.matrixlib.defmatrix:PendingDeprecationWarning
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions