dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #15285
Re: [Bug 427047] Re: Vector indexing in Python with NumPy indices
On Thu, Sep 10, 2009 at 08:56:02AM -0000, Johan Hake wrote:
> This should be fixed now. Unfortunately does not
>
> x[long(0)]
>
> work. When is this needed?
>
> Johan
Does not seem to work for me:
File "reconstruction.py", line 102, in _extract_patch_values
print x[dofs[0]]
File
"/home/logg/scratch/src/fenics-dev/dolfin-dev/local/lib/python2.6/site-packages/dolfin/cpp.py",
line 1843, in __getitem__
return _get_vector_single_item(self, indices)
File
"/home/logg/scratch/src/fenics-dev/dolfin-dev/local/lib/python2.6/site-packages/dolfin/cpp.py",
line 5481, in _get_vector_single_item
return _cpp._get_vector_single_item(*args)
TypeError: expected 'int' for argument 2
When I print type(dofs[0]) I get
<type 'numpy.uint32'>
Even stranger, it still doesn't work when I do
x[int(dofs[0])]
But it does work if I do
x[int(int(dofs[0]))]
int() does not seem to be idempotent!!!
--
Vector indexing in Python with NumPy indices
https://bugs.launchpad.net/bugs/427047
You received this bug notification because you are subscribed to DOLFIN.
Status in DOLFIN: New
Bug description:
The following breaks:
import dolfin, numpy
x = Vector(10)
print x[numpy.int32(0)]
print x[numpy.int64(0)]
print x[numpy.array((0, 1), dtype='I')
The typechecks in la_post.i looks like they can be expanded. (I tried it myself but couldn't get it working correctly.)
Follow ups
References