Re: [Numpy-discussion] (Value Based Promotion) Current Behaviour

2019-06-15 Thread Matti Picus
On 14/6/19 1:37 am, Sebastian Berg wrote: For such a scalar object instead what would seem necessary is to call a `dtype.__coerce_pyvalue__(scalar, casting="safe")`, or a `__can_coerce_pyvalue__` method/slot. It would replace the current `PyArray_CanCastArrayTo`, which can only handle the

Re: [Numpy-discussion] (Value Based Promotion) Current Behaviour

2019-06-13 Thread Sebastian Berg
(this may be a bit thinking out loudly...) On Thu, 2019-06-13 at 07:30 +0200, Hameer Abbasi wrote: > Hi Sebastian, > > One way to avoid an ugly lookup table and special cases is to store > the amount of sign bits, the amount of integer/mantissa bits and the > amount of exponent bits for each

Re: [Numpy-discussion] (Value Based Promotion) Current Behaviour

2019-06-12 Thread Hameer Abbasi
Hi Sebastian, One way to avoid an ugly lookup table and special cases is to store the amount of sign bits, the amount of integer/mantissa bits and the amount of exponent bits for each numeric style. A safe cast can only happen if all three are exceeded or equal. Just a thought. Best Regards,

Re: [Numpy-discussion] (Value Based Promotion) Current Behaviour

2019-06-12 Thread Sebastian Berg
On Wed, 2019-06-12 at 12:03 -0500, Sebastian Berg wrote: > On Tue, 2019-06-11 at 22:08 -0400, Marten van Kerkwijk wrote: > > HI Sebastian, > > > > Thanks for the overview! In the value-based casting, what perhaps > > surprises me most is that it is done within a kind; it would seem > > an > >

Re: [Numpy-discussion] (Value Based Promotion) Current Behaviour

2019-06-12 Thread Sebastian Berg
On Tue, 2019-06-11 at 22:08 -0400, Marten van Kerkwijk wrote: > HI Sebastian, > > Thanks for the overview! In the value-based casting, what perhaps > surprises me most is that it is done within a kind; it would seem an > improvement to check whether a given integer scalar is exactly >

Re: [Numpy-discussion] (Value Based Promotion) Current Behaviour

2019-06-11 Thread Marten van Kerkwijk
HI Sebastian, Thanks for the overview! In the value-based casting, what perhaps surprises me most is that it is done within a kind; it would seem an improvement to check whether a given integer scalar is exactly representable in a given float (your example of 1024 in `float16`). If we switch to

Re: [Numpy-discussion] (Value Based Promotion) Current Behaviour

2019-06-11 Thread Sebastian Berg
Hi all, strange, something went wrong sending that email, but in any case... I tried to "summarize" the current behaviour of promotion and value based promotion in numpy (correcting a small error in what I wrote earlier). Since it got a bit long, you can find it here (also copy pasted at the

[Numpy-discussion] (Value Based Promotion) Current Behaviour

2019-06-11 Thread Sebastian Berg
signature.asc Description: This is a digitally signed message part ___ NumPy-Discussion mailing list NumPy-Discussion@python.org https://mail.python.org/mailman/listinfo/numpy-discussion