Warning: use `arr[tuple(seq)]` instead of `arr[seq]`

18 days ago by
Dear all,

I ran the script below:
from dolfin import *

mesh = UnitSquareMesh(10, 10)

class Left(SubDomain):
    def inside(self, x, on_boundary):
        return near(x[0], 0.0)

class Right(SubDomain):
    def inside(self, x, on_boundary):
        return near(x[0], 1.0)

class Bottom(SubDomain):
    def inside(self, x, on_boundary):
        return near(x[1], 0.0)

class Top(SubDomain):
    def inside(self, x, on_boundary):
        return near(x[1], 1.0)

left = Left()
top = Top()
right = Right()
bottom = Bottom()

domains = MeshFunction("size_t", mesh, mesh.topology().dim())

boundaries = MeshFunction("size_t", mesh, mesh.topology().dim() - 1)
left.mark(boundaries, 1)
top.mark(boundaries, 2)
right.mark(boundaries, 3)
bottom.mark(boundaries, 4)

g_B = Expression("sin(x[0])", degree=2)
g_T = Expression("cos(x[0])", degree=2)

V = FunctionSpace(mesh, "CG", 1)

ul = Constant(0.1)
bc_L = DirichletBC(V, ul, boundaries,1)

ur = Constant(0.5)
bc_R = DirichletBC(V, ur, boundaries,3)

bcs = [bc_L, bc_R]

dx = Measure('dx', domain=mesh, subdomain_data=domains)
ds = Measure('ds', domain=mesh, subdomain_data=boundaries)

u = TrialFunction(V)
v = TestFunction(V)

f = Expression("10*exp(-(pow(x[0] - 0.5, 2) + pow(x[1] - 0.5, 2)) / 0.02)", degree=2)

a = inner(grad(u), grad(v))*dx
L = f*v*dx + g_T*v*ds(2) + g_B*v*ds(4)

A,b = assemble_system(a,L,bcs)

u = Function(V)
solve(A, u.vector(), b)

file = File("poisson.pvd")
file << u​

Then this warning showed up:

FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[seq]`. In the future this will be interpreted as an array index, `arr[np.array(seq)]`, which will result either in an error or a different result.
  active[targets] = 1

I was wondering which parts of the script that this warning refers to and how should I fix them?

Thank you very much.


Community: FEniCS Project

1 Answer

15 days ago by
This is (most probably) not a problem with your script but caused by internal FEniCS components (FFC). Will be fixed in a future release.
Thank you very much!!
written 15 days ago by Teeratorn Kadeethum  
Please login to add an answer/comment or follow this question.

Similar posts:
Search »