MAINT: Move array-prep and type resolution to earlier#19257
MAINT: Move array-prep and type resolution to earlier#19257mattip merged 2 commits intonumpy:mainfrom
Conversation
| /* Initialize all arrays (we usually only need a small part) */ | ||
| memset(operands, 0, nop * sizeof(*operands)); | ||
| memset(operation_descrs, 0, nop * sizeof(*operation_descrs)); | ||
| memset(output_array_prepare, 0, nout * sizeof(*output_array_prepare)); |
There was a problem hiding this comment.
Not NULL'ing everything seemed a small but noticable micro-optimization. This could probably be continued to use alloca (which would make this a single large memset).
Moves around wheremask which should be a ref-count fix for stranger error paths.
56d2743 to
f897d10
Compare
This also fixes a bug in the masked handling of array prep, that was seems to have been simply completely broken. Note that the long term goal is to unify the masked and non-masked, but that is tricky right now due to the different signatures.
f897d10 to
d60d607
Compare
| */ | ||
| op[i] = op_tmp; | ||
| Py_DECREF(op_tmp); | ||
| op[i+nin] = op_tmp; |
There was a problem hiding this comment.
It is a bit annoying, but just to note that the whole execute_fancy_ufunc_loop is deleted in the follow-up.
| assert_raises(TypeError, self.matmul, np.int8(5), np.int8(5)) | ||
| assert_raises(TypeError, self.matmul, np.void(b'abc'), np.void(b'abc')) | ||
| assert_raises(ValueError, self.matmul, np.arange(10), np.void(b'abc')) | ||
| assert_raises(TypeError, self.matmul, np.arange(10), np.void(b'abc')) |
There was a problem hiding this comment.
Does this user-facing change require a release note?
There was a problem hiding this comment.
This just changes the order of errors, so no. If you do np.matmul(np.arange(10), np.void([b'abc'] * 10)) you already get the type error right now.
| x = np.add(a, a, where=np.array(True)) | ||
| return | ||
| else: | ||
| x = np.add(a, a) |
There was a problem hiding this comment.
Well... It is a bug fix in a sense. Previously __array_prepare__ wasn't called, which is why it didn't fail with where (although we never tested where=).
Co-authored-by: Matti Picus <matti.picus@gmail.com>
|
Thanks @seberg |
This also fixes a bug in the masked handling of array prep, that
was seems to have been simply completely broken.
Note that the long term goal is to unify the masked and non-masked,
but that is tricky right now due to the different signatures.
Based off (and includes) gh-19254. So merge that before reviewing this one.