[Numpy-discussion] Automatic custom dtype
Charles R Harris
Fri Jun 28 11:33:48 CDT 2013
On Fri, Jun 28, 2013 at 5:27 AM, Richard Hattersley
> On 21 June 2013 19:57, Charles R Harris <firstname.lastname@example.org> wrote:
> > You could check the numpy/core/src/umath/test_rational.c.src code to see
> > you are missing something.
> In v1.7+ the difference in behaviour between my code and the rational
> test case is because my scalar type doesn't subclass np.generic (aka.
> In v1.6 this requirement doesn't exist ... mostly ... In other words,
> it works as long as the supplied scalars are contained within a
> np.array([scalar]) => np.array([scalar], dtype=my_dtype)
> np.array(scalar) => np.array(scalar, dtype=object)
So the scalar case (0 dimensional array) doesn't work right. Hmm, what
happens when you index the first array? Does subclassing the generic type
work in 1.6?
My impression is that subclassing the generic type should be required, but
I don't see where it is documented :( Anyway, what is the problem with the
third party code? Is there no chance that you can get hold of it to fix it?
> For one of my scalar/dtype combos I can easily workaround the 1.7+
> issue by just adding the subclass relationship. But another of my
> dtypes is wrapping a third-party type so I can't modify the subclass
> relationship. :-(
> So I guess I have three questions.
> Firstly, is there some cunning workaround when defining a dtype for a
> third-party type?
> Secondly, is the subclass-generic requirement in v1.7+ desirable
> and/or intended? Or just an accidental regression?
> And thirdly, assuming it's desirable to remove the subclass-generic
> requirement, would it also make sense to make it work for scalars
> which are not within a sequence?
> NB. If we decide there's some work which needs doing here, then I
> should be able to put time on it.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion