Skip to content

Commit 4ea4268

Browse files
authored
Merge pull request numpy#26642 from luxedo/DOC/21351/np.char
DOC: Add examples to ``np.char``
2 parents f35d3bd + 195b3ab commit 4ea4268

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

numpy/_core/code_generators/ufunc_docstrings.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4531,6 +4531,15 @@ def add_newdoc(place, name, doc):
45314531
--------
45324532
str.isspace
45334533
4534+
Examples
4535+
--------
4536+
>>> np.char.isspace(list("a b c"))
4537+
array([False, True, False, True, False])
4538+
>>> np.char.isspace(b'\x0a \x0b \x0c')
4539+
np.True_
4540+
>>> np.char.isspace(b'\x0a \x0b \x0c N')
4541+
np.False_
4542+
45344543
""")
45354544

45364545
add_newdoc('numpy._core.umath', 'isalnum',

numpy/_core/strings.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,6 +1373,14 @@ def _splitlines(a, keepends=None):
13731373
--------
13741374
str.splitlines
13751375
1376+
Examples
1377+
--------
1378+
>>> np.char.splitlines("first line\\nsecond line")
1379+
array(list(['first line', 'second line']), dtype=object)
1380+
>>> a = np.array(["first\\nsecond", "third\\nfourth"])
1381+
>>> np.char.splitlines(a)
1382+
array([list(['first', 'second']), list(['third', 'fourth'])], dtype=object)
1383+
13761384
"""
13771385
return _vec_string(
13781386
a, np.object_, 'splitlines', _clean_args(keepends))

0 commit comments

Comments
 (0)