8000 PendingDeprecationWarning: the matrix subclass is not the recommended way to represent matrices · Issue #12327 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content
PendingDeprecationWarning: the matrix subclass is not the recommended way to represent matrices #12327
Closed
@rth

Description

@rth

When running a the test suite we get a number PendingDeprecationWarning,

PendingDeprecationWarning: the matrix subclass is not the recommended way to represent matrices or deal with linear algebra (see https://docs.scipy.org/doc/numpy/user/numpy-for-matlab-users.html). Please adjust your code to use regular ndarray.
  return matrix(data, dtype=dtype, copy=False)

See for instance https://ci.appveyor.com/project/sklearn-ci/scikit-learn/builds/19341228/job/q6rysq7flma8hi6v Warnings seems to be hidden on Travis so we don't see those there.

This typically happens when we have a sparse matrix, sum along one axis to get a dense one, than do some mathematical operation with this matrix. It should be explicitly converted to an array first.

This has also been reported by @drorata in #11251 (comment). There was previous discussion about this in #11251 but it doesn't look like it's fixed. I also saw this recently when running PyPy CI.

To investigate where this happen it's sufficient to run pytest tests with -Werror::PendingDeprecationWarning to error on those warnings, as they don't seem to be raised with the right stacklevel (see also #7963 (comment) for workarounds)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0