[Numpy-discussion] recarray fun

Anne Archibald peridot.faceted at gmail.com
Thu May 1 01:39:51 EDT 2008


2008/5/1 Travis E. Oliphant <oliphant at enthought.com>:
> Stéfan van der Walt wrote:
>  > 2008/4/30 Christopher Barker <Chris.Barker at noaa.gov>:
>  >
>  >> Stéfan van der Walt wrote:
>  >>  > That's the way, or just rgba_image.view(numpy.int32).
>  >>
>  >>  ah -- interestingly, I tried:
>  >>
>  >>  rgba_image.view(dtype=numpy.int32)
>  >>
>  >>  and got:
>  >>
>  >>  Traceback (most recent call last):
>  >>    File "<stdin>", line 1, in <module>
>  >>  TypeError: view() takes no keyword arguments
>  >>
>  >>  Since it is optional, shouldn't it be keyword argument?
>  >>
>  >
>  > Thanks, fixed in r5115.
>  >
>  >
>  This was too hasty.   I had considered this before.
>
>  The problem with this is that the object can be either a type object or
>  a data-type object.  You can use view to both re-cast a numpy array as
>  another subtype or as another data-type.
>
>  So, please revert the change until a better solution is posted.

If we're going to support keyword arguments, shouldn't those two
options be *different* keywords (dtype and ndarray_subclass, say)?
Then a single non-keyword argument tells numpy to guess which one you
wanted...

Anne


More information about the NumPy-Discussion mailing list