<br><br><div class="gmail_quote">On Fri, Jun 28, 2013 at 5:27 AM, Richard Hattersley <span dir="ltr"><<a href="mailto:rhattersley@gmail.com" target="_blank">rhattersley@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On 21 June 2013 19:57, Charles R Harris <<a href="mailto:charlesr.harris@gmail.com">charlesr.harris@gmail.com</a>> wrote:<br>
> You could check the numpy/core/src/umath/test_rational.c.src code to see if<br>
> you are missing something.<br>
<br>
</div>In v1.7+ the difference in behaviour between my code and the rational<br>
test case is because my scalar type doesn't subclass np.generic (aka.<br>
PyGenericArrType_Type).<br>
<br>
In v1.6 this requirement doesn't exist ... mostly ... In other words,<br>
it works as long as the supplied scalars are contained within a<br>
sequence.<br>
So:<br>
np.array([scalar]) => np.array([scalar], dtype=my_dtype)<br>
But:<br>
np.array(scalar) => np.array(scalar, dtype=object)<br></blockquote><div> </div><div>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?<br>
<br>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?<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
For one of my scalar/dtype combos I can easily workaround the 1.7+<br>
issue by just adding the subclass relationship. But another of my<br>
dtypes is wrapping a third-party type so I can't modify the subclass<br>
relationship. :-(<br>
<br>
So I guess I have three questions.<br>
<br>
Firstly, is there some cunning workaround when defining a dtype for a<br>
third-party type?<br>
<br>
Secondly, is the subclass-generic requirement in v1.7+ desirable<br>
and/or intended? Or just an accidental regression?<br>
<br>
And thirdly, assuming it's desirable to remove the subclass-generic<br>
requirement, would it also make sense to make it work for scalars<br>
which are not within a sequence?<br>
<br>
NB. If we decide there's some work which needs doing here, then I<br>
should be able to put time on it.<br></blockquote><div><br>Chuck <br></div><br></div>