[Numpy-discussion] Automatic custom dtype
Charles R Harris
Fri Jun 28 10:47:11 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)
Thanks for tracking that down.
> 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?
I don't know ;) But we do try to keep backward compatibility so unless
there is a good reason it would be a regression. In any case, we should
look for a way to let the previous version work.
> 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