← Back to team overview

dolfin team mailing list archive

Re: [Merge] lp:~jobh/dolfin/python into lp:dolfin

 

Hi,


> Thanks for the numpy.isscalar patch. I wonder if you know if this is
> related
> to a bug in Python2.6 together with numpy? As there really should not be a
> reason for
>
>  isinstance(float128(1.), float)
>
> to be False. I have implemented our own IsInteger function in the SWIG
> layer
> (not exposed to Python) for checking integer types in typemaps for this
> particular reason.
>

I have no idea, to be honest -- I only have 2.6 installed. But: even without
bug, only the native python sizes (float64 and int32/int64) are subclasses
of the python types, yet all of them are coercible to floats.

What I wanted was to prevent this:

  >>> v = dolfin.Vector(1)
  >>> print type(numpy.float64(1) * v)
  <type 'numpy.ndarray'>

... but it didn't achieve that due to float64.__mul__ being called before
Vector.__rmul__. So this still needs looking at, to ensure the Vector isn't
implicitly converted to an ndarray (so that Vector.__rmul__ is called as it
should).

-j.

Follow ups

References