15 Jun
2019
15 Jun
'19
5:58 p.m.
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