Cast to float of Function(R) fails with 64-bit PETSc
Tests in test/unit/python/function/test_function.py
of the form
def test_real_function_float_conversion1(R):
c = Function(R)
assert float(c) == 0.0
seg fault when PETSc is compiled with 64-bit integers. Last line is the problem.
Comments (12)
-
reporter -
reporter - edited description
-
site-packages/dolfin/functions/function.py
line 493
the dtype='intc' is probably the cause.
-
reporter OK. How should we fix it? The NumPy wrapping is really confusing to me. Would it be better to just use copies for integer arrays?
-
@johanhake - can you take a look at this, or bump the milestone to 1.6 otherwise.
-
Yes, I will suggest a fix for this in my fix for issue 54.
-
-
assigned issue to
-
assigned issue to
-
This should be fixed now. Can someone with 64bit int check that it is?
-
reporter @johanhake Doesn't seem to work with 64-bit PETSc. I get
function/test_function.py:270: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > values = vec.gather(indices) E TypeError: (1) numpy array of 'intc' expected. Make sure that the numpy array use dtype=intc. # Gather value directly from vector in a parallell safe way vec = self.vector() indices = numpy.zeros(1, dtype=cpp.la_index_dtype()) > values = vec.gather(indices)
Buildbot also reports this error (http://fenicsproject.org:8010/builders/dolfin-master-full-mpich/builds/1345/steps/make%20run_unittests_py/logs/stdio)
-
There wasn't any
sizeof(dolfin::la_index)==8
typemap forconst std::vector<dolfin::la_index>&
. I have pushed a fix for this to next. Let see how that works out. -
- changed status to resolved
Fixed in: fdb4d29
-
reporter - removed milestone
Removing milestone: 1.5 (automated comment)
- Log in to comment
@johanhake Can you tell me where the code that implements the cast is?