Skip to content

DOC: Clarify that np.char comparison functions always return ndarrays#17036

Merged
mattip merged 2 commits intonumpy:masterfrom
BvB93:char-doc
Aug 11, 2020
Merged

DOC: Clarify that np.char comparison functions always return ndarrays#17036
mattip merged 2 commits intonumpy:masterfrom
BvB93:char-doc

Conversation

@BvB93
Copy link
Copy Markdown
Member

@BvB93 BvB93 commented Aug 9, 2020

The docstring of np.char.equal(), and all other comparison functions in the np.char module, incorrectly claim that a boolean is returned if two scalars are compared. This is incorrect, as the respective function(s) always return an ndarray (0d in the case of scalar comparisons).

This pull requests thus corrects the docstrings of aforementioned functions.

Examples

In [1]: import numpy as np

In [2]: np.__version__
Out[2]: '1.20.0.dev0+961b56f'

In [3]: np.char.equal('a', 'a')
Out[3]: array(True)  # That's definitely not a bool

In [4]: np.char.equal(['a', 'b'], ['a', 'b'])
Out[4]: array([ True,  True])

@BvB93 BvB93 changed the title DOC: Clarify that np.rec comparison functions always return ndarrays DOC: Clarify that np.char comparison functions always return ndarrays Aug 9, 2020
Copy link
Copy Markdown
Contributor

@rossbar rossbar left a comment

Choose a reason for hiding this comment

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

LGTM - the current docs do seem to be incorrect.

@mattip mattip merged commit 7aced6e into numpy:master Aug 11, 2020
@mattip
Copy link
Copy Markdown
Member

mattip commented Aug 11, 2020

Thanks @BvB93

@BvB93 BvB93 deleted the char-doc branch August 13, 2020 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants