Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 13, 2018
Merged

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

merged 4 commits into from
Nov 13, 2018

Conversation

ryzheboka
Copy link
Contributor

@ryzheboka ryzheboka commented Nov 5, 2018

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
Copy link
Member

mattip commented Nov 6, 2018

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
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
Copy link
Member

mattip commented Nov 6, 2018

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

>>> a = np.array([["a"], ["b"], ["cde"]])
>>> b = np.array([["a"], ["a"], ["dec"]])
>>> np.compare_chararrays(a,b,">",True)
array([[False],[True],[False]])
Copy link
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
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
Copy link
Member

charris commented Nov 13, 2018

@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
Copy link
Member

charris commented Nov 13, 2018

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