AttributeError: 'Matrix' object has no attribute 'data' (uBlas -> Eigen)

Issue #562 invalid
Andreas Hellander created an issue

After upgrading to 1.6 from 1.5 (switching from uBLAS to Eigen backend), I get this error (where 'M' is an output of dolfin.assemble):

Did you intentionally introduce this change or is this a bug?

/usr/local/pyurdme/pyurdme/pyurdme.pyc in create_system_matrix(self) 636 --> 638 rows, cols, vals = M.data() 639 SM = scipy.sparse.csr_matrix((vals, cols, rows)) 640 vols = SM.sum(axis=1)

AttributeError: 'Matrix' object has no attribute 'data'

Comments (6)

  1. Prof Garth Wells

    This is a deliberate change. Matrix is an abstract wrapper class, so can't make any assumptions as to the underlying data storage.

    To use the data() member function, use an EigenMatrix rather than a Matrix. See ChangeLog for more information.

  2. Christian Clason

    Or cast it explicitly to the backend type (if it supports data access, as Eigen does): rows, cols, vals = as_backend_type(M).data().

  3. Andreas Hellander reporter

    Thanks. And this, rows, cols, vals = as_backend_type(M).data() will work also with 1.5 and the uBLAS backend? (I want to update my API in a backwards compatible way)

    I must have missed the deprecation warning to remove the uBLAS backend in the 1.5 release.

  4. Christian Clason

    Yes, this also works for the uBLAS backend.

    The change is mentioned in the ChangeLog:

    - Remove GenericMatrix/Vector::data() and GenericMatrix/Vector::data()
        (to use backends that support data(), cast first to backend type, e.g.
        A = A.as_backend_type()
    

    As far as I can tell, there's no release notes on the webpage yet -- but this is something that should indeed be mentioned prominently at the very top (under "Backward-incompatible changes" or "Major API changes").

  5. Log in to comment