Spurious deprecation warning of vector array interface

Issue #961 resolved
Jan Blechta created an issue

Pull request #403 introduced some deprecation warnings which are spurious. Note also of double implementation of GenericVector.__iter__ which is probably related to this problem.

from dolfin import *
import numpy as np

mesh = UnitSquareMesh(8, 8)
V = FunctionSpace(mesh, 'P', 1)
u = Function(V)

u.vector()[:] *= u.vector()  # Ok
u.vector()[:] *= np.ones((u.vector().size(),))  # Deprecated?
u.vector()[:] * np.ones((u.vector().size(),))  # Deprecated?

Thanks Sigvald Marholm for reporting https://www.allanswered.com/post/rejvg/#vnmbo.

Comments (10)

  1. Tormod Landet

    I am testing the fix now (3c92512). Don't know how I missed that routine, pretty sure I grepped through all the code to find instances of array() ... Good that this was caught before release

  2. Jan Blechta reporter
    • changed status to open

    Usage of deprecated code still in plotting:

    dolfin$ grep -r array\(\) site-packages/dolfin/ python/dolfin
    site-packages/dolfin/compilemodules/compilemodule.py:import_array();
    site-packages/dolfin/mesh/boundarysubdomainfinder.py:            subdomains[boundary_cell_map.array()[key]] =  counter
    site-packages/dolfin/common/plotting.py:        C = fvec.array()  # NB! Assuming here dof ordering matching cell numbering
    site-packages/dolfin/common/plotting.py:        C = obj.array()
    python/dolfin/common/plotting.py:        C = obj.array()
    dolfin$ python3 demo/documented/mixed-poisson/python/demo_mixed-poisson.py 
    Solving linear variational problem.
    /home/jan/dev/fenics-master/src/dolfin/local.master/lib/python3.6/site-packages/dolfin/cpp/la.py:1331: DeprecationWarning: GenericVector.array() is being deprecated, use GenericVector.get_local()
      "use GenericVector.get_local()", DeprecationWarning)
    
  3. Jan Blechta reporter
    • changed status to open

    grep -r array\(\) test/ shows few suspicious items and CI shows warnings:

    python/jit/test_jit.py::test_compile_extension_module
      /usr/lib/python3/dist-packages/dolfin/cpp/la.py:1331: DeprecationWarning: GenericVector.array() is being deprecated, use GenericVector.get_local()
        "use GenericVector.get_local()", DeprecationWarning)
      /usr/lib/python3/dist-packages/dolfin/cpp/la.py:1331: DeprecationWarning: GenericVector.array() is being deprecated, use GenericVector.get_local()
        "use GenericVector.get_local()", DeprecationWarning)
      /usr/lib/python3/dist-packages/dolfin/cpp/la.py:1331: DeprecationWarning: GenericVector.array() is being deprecated, use GenericVector.get_local()
        "use GenericVector.get_local()", DeprecationWarning)
      /usr/lib/python3/dist-packages/dolfin/cpp/la.py:1331: DeprecationWarning: GenericVector.array() is being deprecated, use GenericVector.get_local()
        "use GenericVector.get_local()", DeprecationWarning)
    
    python/multimesh/test_volume.py::test_volume_2d
      /usr/lib/python3/dist-packages/dolfin/cpp/la.py:1331: DeprecationWarning: GenericVector.array() is being deprecated, use GenericVector.get_local()
        "use GenericVector.get_local()", DeprecationWarning)
    
    python/multimesh/test_volume.py::test_volume_2d_4_meshes
      /usr/lib/python3/dist-packages/dolfin/cpp/la.py:1331: DeprecationWarning: GenericVector.array() is being deprecated, use GenericVector.get_local()
        "use GenericVector.get_local()", DeprecationWarning)
    
    python/multimesh/test_volume.py::test_volume_2d_six_meshes
      /usr/lib/python3/dist-packages/dolfin/cpp/la.py:1331: DeprecationWarning: GenericVector.array() is being deprecated, use GenericVector.get_local()
        "use GenericVector.get_local()", DeprecationWarning)
    
  4. Tormod Landet

    I only updated the tests that are relevant on pybind11. Are anyone going to run the unit tests with SWIG after the 2017.2 release? I thought all that code would be deleted ASAP?

  5. Log in to comment