Skip to content

DOC: add a docstring for the function 'compare_chararrays' (See #10106) - #12338

Merged
charris merged 4 commits into
numpy:masterfrom
ryzheboka:docs-for-compare_chararrays
Nov 13, 2018
Merged

charris merged 4 commits into
numpy:masterfrom
ryzheboka:docs-for-compare_chararrays

Conversation

@ryzheboka

@ryzheboka ryzheboka commented Nov 5, 2018 •

Copy link
Copy Markdown
Contributor

That's my first contribution, so I feel quit unsure.

@ryzheboka ryzheboka changed the title DOC: add a docstring for the function 'compare_chararrays' DOC: add a docstring for the function 'compare_chararrays' (See #10106) Nov 5, 2018
@mattip

mattip commented Nov 6, 2018

Copy link
Copy Markdown
Member

I wonder why that function is public in the first place. Do you have a reason for using compare_chararrays(a, b, <op>) rather than using a <op> b?

@tylerjereddy

Copy link
Copy Markdown
Contributor

I'm actually surprised you can do the operations without that function -- the string / unicode operations often seem to require their own functions for simple operations instead of assuming that i.e., + and so on will "just work."

@mattip

mattip commented Nov 6, 2018

Copy link
Copy Markdown
Member

This is specifically for the chararray class which is a (deprecated?) subclass of ndarray, and the function is used in the implementation of the equivalent dunder operations

Comment thread numpy/core/_add_newdocs.py Outdated
>>> a = np.array([["a"], ["b"], ["cde"]])
>>> b = np.array([["a"], ["a"], ["dec"]])
>>> np.compare_chararrays(a,b,">",True)
array([[False],[True],[False]])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not just make these 1D arrays?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thank you, I hadn't thought about that, so just changed it.

@charris

charris commented Nov 13, 2018

Copy link
Copy Markdown
Member

@mattip It looks like the name is outdated and misleading, it works for string arrays in general.

@charris
charris merged commit 9a63851 into numpy:master Nov 13, 2018
@charris

charris commented Nov 13, 2018

Copy link
Copy Markdown
Member

Thanks @ryzheboka .

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.

5 participants