Skip to content

Conversation

ngoldbaum
Copy link
Member

First, this refactors the string casting setup a bit to make it more general and have a little less boilerplate. Second, it adds a cast from string to bool, which notably makes np.any and np.all work correctly.

Comment on lines +436 to +451
get_cast_spec(const char *name, NPY_CASTING casting,
NPY_ARRAYMETHOD_FLAGS flags, PyArray_DTypeMeta **dtypes,
PyType_Slot *slots)
{
PyArrayMethod_Spec *ret = malloc(sizeof(PyArrayMethod_Spec));

ret->name = name;
ret->nin = 1;
ret->nout = 1;
ret->casting = casting;
ret->flags = flags;
ret->dtypes = dtypes;
ret->slots = slots;

return ret;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this, reduces a lot of duplication.

Copy link
Contributor

@peytondmurray peytondmurray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, only minor stuff. Thanks!

@ngoldbaum ngoldbaum merged commit a5e9efc into numpy:main Mar 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants