# Converting dolfin vector dtype object to float

I am getting output in object datatype. I wanted float data output, but that gives “ValueError: setting an array element with a sequence” error. The extract of code is shown below

``````W = FunctionSpace(mesh, MixedElement([Ve, Re]))
dv = TrialFunction(W)
w=Function(W)
(v, lamb) = split(w)
dx = Measure('dx')(subdomain_data=subdomains)
def eps(v):
return as_vector([0,v[1].dx(0),v[1].dx(0),v[1].dx(0),v[1].dx(0),v[0].dx(0)])

lmbda=2*10^9
mu=3*10^9
C1=2*lmbda+mu
C=Constant([(C1,lmbda,lmbda,0,0,0),(lmbda,C1,lmbda,0,0,0),(lmbda,lmbda,C1,0,0,0),(0,0,0,mu,0,0),(0,0,0,0,mu,0),(0,0,0,0,0,mu)])

solve (a==L,w)

DD = np.zeros((6,),dtype =object)
for p in range(6):
DD[p]=assemble(sum([dot(C,eps(dv))[p]*dx]))/vol

print(DD[0])

<dolfin.cpp.la.Vector at 0x7f6d5fa2e7a0>

print(DD[0]+100)

<dolfin.cpp.la.Vector at 0x7f6d64b65f80>
``````

I wanted to get float values of DD matrix. If I add some number like 100, then it shows different location as shown above.

If I remove the dtype from DD, it gives the following error

``````DD = np.zeros((6,))
for p in range(6):
DD[p]=assemble(sum([dot(C,eps(dv))[p]*dx]))/vol

TypeError                                 Traceback (most recent call last)
TypeError: float() argument must be a string or a real number, not 'dolfin.cpp.la.Vector'

The above exception was the direct cause of the following exception:

ValueError                                Traceback (most recent call last)
/tmp/ipykernel_238/738355618.py in <module>
2 for p in range(6):
3     for q in range(6):
----> 4         DD[p,q]=assemble(sum([outer(dot(Com(i),eps(dv)),V)[p,q]*dx(i) for i in range(nphases)]))/vol
5

ValueError: setting an array element with a sequence.

``````

Kindly help me for getting DD in float/ real number output.

Please format the code with 3x` encapsulation.

`````````python

```
``````

I have edited the code with sugessted encapsulation. Thanks @dokken.

You code is not complete, as in there is no way to reproduce your erro message as the code currently stands.
Also, it is unclear to me if this is your actual code, as:

contains a trial function, and no test function, which does not make sense to be.
Are you trying to compute something with your solution (`w`) here?