Spurious deprecation warning of vector array interface
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)
-
-
Tested now. With the fix this does not print any warning. Will merge to next and master
-
- changed status to resolved
Fix in master
-
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)
-
C = obj.array()
should be kept sinceobj
is a meshfunctionI will fix
C = fvec.array()
-
- changed status to resolved
Fix issue
#961Hopefully last time, grep shows nothing suspicious in ./dolfin/swig, ./python or ./site-packages after this
→ <<cset bbfa212d7247>>
-
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)
-
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?
-
reporter Sure, if all these cases are to be ditched with SWIG deletion, then it is fine.
-
reporter - changed status to resolved
- Log in to comment
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