[Numpy-discussion] python user defined type

Robert Kern robert.kern@gmail....
Fri Jul 11 02:31:55 CDT 2008


On Thu, Jul 10, 2008 at 16:45, Nicolas Rougier <Nicolas.Rougier@loria.fr> wrote:

> Ideally, I would like to be able to write
>
> z = N.array (a, dtype=Unit)
>
> and would expect numpy to make a copy of the array by calling my type
> with each element of a. Then, if my type accepts the argument during
> creation, everything's fine, else it raises an error.

Just use dtype=object and make any copies you need yourself.
Encapsulate this logic in a function if you need it frequently.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
 -- Umberto Eco


More information about the Numpy-discussion mailing list