From 96e366061e523c206990b14befce0135089260d4 Mon Sep 17 00:00:00 2001 From: Elena Mokeeva Date: Mon, 5 Nov 2018 21:00:10 +0100 Subject: [PATCH 1/4] DOC: add a docstring for the function 'compare_chararrays' --- numpy/core/_add_newdocs.py | 41 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/numpy/core/_add_newdocs.py b/numpy/core/_add_newdocs.py index ea472f1b3cd2..6c2decd6b294 100644 --- a/numpy/core/_add_newdocs.py +++ b/numpy/core/_add_newdocs.py @@ -1072,6 +1072,47 @@ def luf(lamdaexpr, *args, **kwargs): """) +add_newdoc('numpy.core.multiarray', 'compare_chararrays', + """ + compare_chararrays(a, b, cmp_op, rstrip) + + Preforms element-wise comparison of two string-arrays using the specified comparison operator. + + Parameters + ---------- + a : array_like + First argument. + b : array_like + Second argument. + cmp_op : "<" or "<=" or "==" or ">=" or ">" or "!=" + Third argument. + rstrip : Boolean + if True, the spaces at the end of Strings are removed before the comparison + + Returns + ------- + out : ndarray + The output array of type Boolean with the same shape as a and b. + + Raises + ------ + ValueError + If cmp_op is neither "<" nor "<=" nor "==" nor ">=" nor ">" nor "!=" + + TypeError + If at least one of the arrays a or b is a non-string array + + Examples + -------- + >>> a = np.array([["a"], ["b"], ["cde"]]) + >>> b = np.array([["a"], ["a"], ["dec"]]) + >>> np.compare_chararrays(a,b,">",True) + array([[False],[True],[False]]) + +""" + + ) + add_newdoc('numpy.core.multiarray', 'fromiter', """ fromiter(iterable, dtype, count=-1) From e13ecbc931d6ad61602bffd8c4eed265d86d31c7 Mon Sep 17 00:00:00 2001 From: Elena Mokeeva Date: Wed, 7 Nov 2018 23:29:04 +0100 Subject: [PATCH 2/4] DOC: changing the example in the docstring for the function 'compare_chararrays' --- numpy/core/_add_newdocs.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/numpy/core/_add_newdocs.py b/numpy/core/_add_newdocs.py index 6c2decd6b294..3507e2193612 100644 --- a/numpy/core/_add_newdocs.py +++ b/numpy/core/_add_newdocs.py @@ -1104,10 +1104,10 @@ def luf(lamdaexpr, *args, **kwargs): Examples -------- - >>> a = np.array([["a"], ["b"], ["cde"]]) - >>> b = np.array([["a"], ["a"], ["dec"]]) + >>> a = np.array(["a", "b", "cde"]) + >>> b = np.array(["a", "a", "dec"]) >>> np.compare_chararrays(a,b,">",True) - array([[False],[True],[False]]) + array([False,True,False]) """ From 0a36e5f8cbf56f4600c27e4ba0dc1a3d74d83e32 Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Tue, 13 Nov 2018 10:52:14 -0700 Subject: [PATCH 3/4] STY: Fix up indentation. [ci skip] --- numpy/core/_add_newdocs.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/numpy/core/_add_newdocs.py b/numpy/core/_add_newdocs.py index 3507e2193612..861812a89f99 100644 --- a/numpy/core/_add_newdocs.py +++ b/numpy/core/_add_newdocs.py @@ -1109,9 +1109,7 @@ def luf(lamdaexpr, *args, **kwargs): >>> np.compare_chararrays(a,b,">",True) array([False,True,False]) -""" - - ) + """) add_newdoc('numpy.core.multiarray', 'fromiter', """ From d6538309351f3138ed1d0c46eb72bc5f68134373 Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Tue, 13 Nov 2018 11:11:00 -0700 Subject: [PATCH 4/4] MAINT: Fix spaces, formatting, and improve explanations. [ci skip] --- numpy/core/_add_newdocs.py | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/numpy/core/_add_newdocs.py b/numpy/core/_add_newdocs.py index 861812a89f99..bb7009801d83 100644 --- a/numpy/core/_add_newdocs.py +++ b/numpy/core/_add_newdocs.py @@ -1076,18 +1076,17 @@ def luf(lamdaexpr, *args, **kwargs): """ compare_chararrays(a, b, cmp_op, rstrip) - Preforms element-wise comparison of two string-arrays using the specified comparison operator. + Performs element-wise comparison of two string arrays using the + comparison operator specified by `cmp_op`. Parameters ---------- - a : array_like - First argument. - b : array_like - Second argument. - cmp_op : "<" or "<=" or "==" or ">=" or ">" or "!=" - Third argument. + a, b : array_like + Arrays to be compared. + cmp_op : {"<", "<=", "==", ">=", ">", "!="} + Type of comparison. rstrip : Boolean - if True, the spaces at the end of Strings are removed before the comparison + If True, the spaces at the end of Strings are removed before the comparison. Returns ------- @@ -1097,17 +1096,16 @@ def luf(lamdaexpr, *args, **kwargs): Raises ------ ValueError - If cmp_op is neither "<" nor "<=" nor "==" nor ">=" nor ">" nor "!=" - + If `cmp_op` is not valid. TypeError - If at least one of the arrays a or b is a non-string array + If at least one of `a` or `b` is a non-string array Examples -------- >>> a = np.array(["a", "b", "cde"]) >>> b = np.array(["a", "a", "dec"]) - >>> np.compare_chararrays(a,b,">",True) - array([False,True,False]) + >>> np.compare_chararrays(a, b, ">", True) + array([False, True, False]) """)