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

Matti Picus matti.picus at gmail.com
Sat Jun 15 13:58:13 EDT 2019


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 current hardcoded
> special "minimum value" rules.


This makes sense to me since it makes the problem explicit, rather than 
trying to generalize for some properties.

I would suggest changing the first argument from "scalar" to "obj" to 
indicate it is not necessarily a np.scalar but could be any non-ndarray 
object, although I would exclude sequences.


Matti





More information about the NumPy-Discussion mailing list