Skip to content
This repository was archived by the owner on Feb 2, 2024. It is now read-only.

Commit 50178e8

Browse files
Rubtsowadensmirn
authored andcommitted
Correction doc for some Series.str methods (#462)
* correction doc * correction doc * use of cycle * correction doc, add captions * correction dict for doc * correction problem with PEP8
1 parent 433fa97 commit 50178e8

File tree

2 files changed

+34
-257
lines changed

2 files changed

+34
-257
lines changed

sdc/datatypes/hpat_pandas_series_functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ def hpat_pandas_series_setitem(self, idx, value):
311311
"""
312312
Intel Scalable Dataframe Compiler User Guide
313313
********************************************
314-
Pandas API: pandas.Series.set
314+
Pandas API: pandas.Series.__setitem__
315315
316316
Examples
317317
--------

sdc/datatypes/hpat_pandas_stringmethods_functions.py

Lines changed: 33 additions & 256 deletions
Original file line numberDiff line numberDiff line change
@@ -913,27 +913,25 @@ def _hpat_pandas_stringmethods_autogen(method_name):
913913
return _hpat_pandas_stringmethods_autogen_global_dict[global_dict_name]
914914

915915

916-
@overload_method(StringMethodsType, 'istitle')
917-
def hpat_pandas_stringmethods_istitle(self):
918-
"""
916+
sdc_pandas_series_str_docstring_template = """
919917
Intel Scalable Dataframe Compiler User Guide
920918
********************************************
921-
Pandas API: pandas.Series.str.istitle
919+
Pandas API: pandas.Series.str.{method_name}
922920
923921
Limitations
924922
-----------
925923
Series elements are expected to be Unicode strings. Elements cannot be NaN.
926924
927925
Examples
928926
--------
929-
.. literalinclude:: ../../../examples/series/str/series_str_istitle.py
927+
.. literalinclude:: ../../../examples/series/str/series_str_{method_name}.py
930928
:language: python
931929
:lines: 27-
932-
:caption: Check if each word start with an upper case letter
933-
:name: ex_series_str_istitle
930+
:caption: {caption}
931+
:name: ex_series_str_{method_name}
934932
935-
.. command-output:: python ./series/str/series_str_istitle.py
936-
:cwd: ../../../examples
933+
.. command-output:: python ./series/str/series_str_{method_name}.py
934+
:cwd: ../../../examples
937935
938936
.. seealso::
939937
:ref:`Series.str.isalpha <pandas.Series.str.isalpha>`
@@ -958,13 +956,13 @@ def hpat_pandas_stringmethods_istitle(self):
958956
Intel Scalable Dataframe Compiler Developer Guide
959957
*************************************************
960958
961-
Pandas Series method :meth:`pandas.core.strings.StringMethods.istitle()` implementation.
959+
Pandas Series method :meth:`pandas.core.strings.StringMethods.{method_name}()` implementation.
962960
963961
Note: Unicode type of list elements are supported only. Numpy.NaN is not supported as elements.
964962
965963
.. only:: developer
966964
967-
Test: python -m sdc.runtests sdc.tests.test_series.TestSeries.test_series_istitle_str
965+
Test: python -m sdc.runtests sdc.tests.test_series.TestSeries.test_series_{method_name}_str
968966
969967
Parameters
970968
----------
@@ -975,7 +973,11 @@ def hpat_pandas_stringmethods_istitle(self):
975973
-------
976974
:obj:`pandas.Series`
977975
returns :obj:`pandas.Series` object
978-
"""
976+
"""
977+
978+
979+
@overload_method(StringMethodsType, 'istitle')
980+
def hpat_pandas_stringmethods_istitle(self):
979981

980982
ty_checker = TypeChecker('Method istitle().')
981983
ty_checker.check(self, StringMethodsType)
@@ -993,67 +995,6 @@ def hpat_pandas_stringmethods_istitle_impl(self):
993995

994996
@overload_method(StringMethodsType, 'isspace')
995997
def hpat_pandas_stringmethods_isspace(self):
996-
"""
997-
Intel Scalable Dataframe Compiler User Guide
998-
********************************************
999-
Pandas API: pandas.Series.str.isspace
1000-
1001-
Limitations
1002-
-----------
1003-
Series elements are expected to be Unicode strings. Elements cannot be NaN.
1004-
1005-
Examples
1006-
--------
1007-
.. literalinclude:: ../../../examples/series/str/series_str_isspace.py
1008-
:language: python
1009-
:lines: 27-
1010-
:caption: Check if all the characters in the text are whitespaces
1011-
:name: ex_series_str_isspace
1012-
1013-
.. command-output:: python ./series/str/series_str_isspace.py
1014-
:cwd: ../../../examples
1015-
1016-
.. seealso::
1017-
:ref:`Series.str.isalpha <pandas.Series.str.isalpha>`
1018-
Check whether all characters are alphabetic.
1019-
:ref:`Series.str.isnumeric <pandas.Series.str.isnumeric>`
1020-
Check whether all characters are numeric.
1021-
:ref:`Series.str.isalnum <pandas.Series.str.isalnum>`
1022-
Check whether all characters are alphanumeric.
1023-
:ref:`Series.str.isdigit <pandas.Series.str.isdigit>`
1024-
Check whether all characters are digits.
1025-
:ref:`Series.str.isdecimal <pandas.Series.str.isdecimal>`
1026-
Check whether all characters are decimal.
1027-
:ref:`Series.str.isspace <pandas.Series.str.isspace>`
1028-
Check whether all characters are whitespace.
1029-
:ref:`Series.str.islower <pandas.Series.str.islower>`
1030-
Check whether all characters are lowercase.
1031-
:ref:`Series.str.isupper <pandas.Series.str.isupper>`
1032-
Check whether all characters are uppercase.
1033-
:ref:`Series.str.istitle <pandas.Series.str.istitle>`
1034-
Check whether all characters are titlecase.
1035-
1036-
Intel Scalable Dataframe Compiler Developer Guide
1037-
*************************************************
1038-
1039-
Pandas Series method :meth:`pandas.core.strings.StringMethods.isspace()` implementation.
1040-
1041-
Note: Unicode type of list elements are supported only. Numpy.NaN is not supported as elements.
1042-
1043-
.. only:: developer
1044-
1045-
Test: python -m sdc.runtests sdc.tests.test_series.TestSeries.test_series_isspace_str
1046-
1047-
Parameters
1048-
----------
1049-
self: :class:`pandas.core.strings.StringMethods`
1050-
input arg
1051-
1052-
Returns
1053-
-------
1054-
:obj:`pandas.Series`
1055-
returns :obj:`pandas.Series` object
1056-
"""
1057998

1058999
ty_checker = TypeChecker('Method isspace().')
10591000
ty_checker.check(self, StringMethodsType)
@@ -1071,67 +1012,6 @@ def hpat_pandas_stringmethods_isspace_impl(self):
10711012

10721013
@overload_method(StringMethodsType, 'isalpha')
10731014
def hpat_pandas_stringmethods_isalpha(self):
1074-
"""
1075-
Intel Scalable Dataframe Compiler User Guide
1076-
********************************************
1077-
Pandas API: pandas.Series.str.isalpha
1078-
1079-
Limitations
1080-
-----------
1081-
Series elements are expected to be Unicode strings. Elements cannot be NaN.
1082-
1083-
Examples
1084-
--------
1085-
.. literalinclude:: ../../../examples/series/str/series_str_isalpha.py
1086-
:language: python
1087-
:lines: 27-
1088-
:caption: Check whether all characters in each string are alphabetic.
1089-
:name: ex_series_str_isalpha
1090-
1091-
.. command-output:: python ./series/str/series_str_isalpha.py
1092-
:cwd: ../../../examples
1093-
1094-
.. seealso::
1095-
:ref:`Series.str.isalpha <pandas.Series.str.isalpha>`
1096-
Check whether all characters are alphabetic.
1097-
:ref:`Series.str.isnumeric <pandas.Series.str.isnumeric>`
1098-
Check whether all characters are numeric.
1099-
:ref:`Series.str.isalnum <pandas.Series.str.isalnum>`
1100-
Check whether all characters are alphanumeric.
1101-
:ref:`Series.str.isdigit <pandas.Series.str.isdigit>`
1102-
Check whether all characters are digits.
1103-
:ref:`Series.str.isdecimal <pandas.Series.str.isdecimal>`
1104-
Check whether all characters are decimal.
1105-
:ref:`Series.str.isspace <pandas.Series.str.isspace>`
1106-
Check whether all characters are whitespace.
1107-
:ref:`Series.str.islower <pandas.Series.str.islower>`
1108-
Check whether all characters are lowercase.
1109-
:ref:`Series.str.isupper <pandas.Series.str.isupper>`
1110-
Check whether all characters are uppercase.
1111-
:ref:`Series.str.istitle <pandas.Series.str.istitle>`
1112-
Check whether all characters are titlecase.
1113-
1114-
Intel Scalable Dataframe Compiler Developer Guide
1115-
*************************************************
1116-
1117-
Pandas Series method :meth:`pandas.core.strings.StringMethods.isalpha()` implementation.
1118-
1119-
Note: Unicode type of list elements are supported only. Numpy.NaN is not supported as elements.
1120-
1121-
.. only:: developer
1122-
1123-
Test: python -m sdc.runtests sdc.tests.test_series.TestSeries.test_series_isalpha_str
1124-
1125-
Parameters
1126-
----------
1127-
self: :class:`pandas.core.strings.StringMethods`
1128-
input arg
1129-
1130-
Returns
1131-
-------
1132-
:obj:`pandas.Series`
1133-
returns :obj:`pandas.Series` object
1134-
"""
11351015

11361016
ty_checker = TypeChecker('Method isalpha().')
11371017
ty_checker.check(self, StringMethodsType)
@@ -1149,67 +1029,6 @@ def hpat_pandas_stringmethods_isalpha_impl(self):
11491029

11501030
@overload_method(StringMethodsType, 'islower')
11511031
def hpat_pandas_stringmethods_islower(self):
1152-
"""
1153-
Intel Scalable Dataframe Compiler User Guide
1154-
********************************************
1155-
Pandas API: pandas.Series.str.islower
1156-
1157-
Limitations
1158-
-----------
1159-
Series elements are expected to be Unicode strings. Elements cannot be NaN.
1160-
1161-
Examples
1162-
--------
1163-
.. literalinclude:: ../../../examples/series/str/series_str_islower.py
1164-
:language: python
1165-
:lines: 27-
1166-
:caption: Check if all the characters in the text are alphanumeric
1167-
:name: ex_series_str_islower
1168-
1169-
.. command-output:: python ./series/str/series_str_islower.py
1170-
:cwd: ../../../examples
1171-
1172-
.. seealso::
1173-
:ref:`Series.str.isalpha <pandas.Series.str.isalpha>`
1174-
Check whether all characters are alphabetic.
1175-
:ref:`Series.str.isnumeric <pandas.Series.str.isnumeric>`
1176-
Check whether all characters are numeric.
1177-
:ref:`Series.str.isalnum <pandas.Series.str.isalnum>`
1178-
Check whether all characters are alphanumeric.
1179-
:ref:`Series.str.isdigit <pandas.Series.str.isdigit>`
1180-
Check whether all characters are digits.
1181-
:ref:`Series.str.isdecimal <pandas.Series.str.isdecimal>`
1182-
Check whether all characters are decimal.
1183-
:ref:`Series.str.isspace <pandas.Series.str.isspace>`
1184-
Check whether all characters are whitespace.
1185-
:ref:`Series.str.islower <pandas.Series.str.islower>`
1186-
Check whether all characters are lowercase.
1187-
:ref:`Series.str.isupper <pandas.Series.str.isupper>`
1188-
Check whether all characters are uppercase.
1189-
:ref:`Series.str.istitle <pandas.Series.str.istitle>`
1190-
Check whether all characters are titlecase.
1191-
1192-
Intel Scalable Dataframe Compiler Developer Guide
1193-
*************************************************
1194-
1195-
Pandas Series method :meth:`pandas.core.strings.StringMethods.islower()` implementation.
1196-
1197-
Note: Unicode type of list elements are supported only. Numpy.NaN is not supported as elements.
1198-
1199-
.. only:: developer
1200-
1201-
Test: python -m sdc.runtests sdc.tests.test_series.TestSeries.test_series_islower_str
1202-
1203-
Parameters
1204-
----------
1205-
self: :class:`pandas.core.strings.StringMethods`
1206-
input arg
1207-
1208-
Returns
1209-
-------
1210-
:obj:`pandas.Series`
1211-
returns :obj:`pandas.Series` object
1212-
"""
12131032

12141033
ty_checker = TypeChecker('Method islower().')
12151034
ty_checker.check(self, StringMethodsType)
@@ -1227,67 +1046,6 @@ def hpat_pandas_stringmethods_islower_impl(self):
12271046

12281047
@overload_method(StringMethodsType, 'isalnum')
12291048
def hpat_pandas_stringmethods_isalnum(self):
1230-
"""
1231-
Intel Scalable Dataframe Compiler User Guide
1232-
********************************************
1233-
Pandas API: pandas.Series.str.isalnum
1234-
1235-
Limitations
1236-
-----------
1237-
Series elements are expected to be Unicode strings. Elements cannot be NaN.
1238-
1239-
Examples
1240-
--------
1241-
.. literalinclude:: ../../../examples/series/str/series_str_isalnum.py
1242-
:language: python
1243-
:lines: 27-
1244-
:caption: Check if all the characters in the text are alphanumeric
1245-
:name: ex_series_str_isalnum
1246-
1247-
.. command-output:: python ./series/str/series_str_isalnum.py
1248-
:cwd: ../../../examples
1249-
1250-
.. seealso::
1251-
:ref:`Series.str.isalpha <pandas.Series.str.isalpha>`
1252-
Check whether all characters are alphabetic.
1253-
:ref:`Series.str.isnumeric <pandas.Series.str.isnumeric>`
1254-
Check whether all characters are numeric.
1255-
:ref:`Series.str.isalnum <pandas.Series.str.isalnum>`
1256-
Check whether all characters are alphanumeric.
1257-
:ref:`Series.str.isdigit <pandas.Series.str.isdigit>`
1258-
Check whether all characters are digits.
1259-
:ref:`Series.str.isdecimal <pandas.Series.str.isdecimal>`
1260-
Check whether all characters are decimal.
1261-
:ref:`Series.str.isspace <pandas.Series.str.isspace>`
1262-
Check whether all characters are whitespace.
1263-
:ref:`Series.str.islower <pandas.Series.str.islower>`
1264-
Check whether all characters are lowercase.
1265-
:ref:`Series.str.isupper <pandas.Series.str.isupper>`
1266-
Check whether all characters are uppercase.
1267-
:ref:`Series.str.istitle <pandas.Series.str.istitle>`
1268-
Check whether all characters are titlecase.
1269-
1270-
Intel Scalable Dataframe Compiler Developer Guide
1271-
*************************************************
1272-
1273-
Pandas Series method :meth:`pandas.core.strings.StringMethods.isalnum()` implementation.
1274-
1275-
Note: Unicode type of list elements are supported only. Numpy.NaN is not supported as elements.
1276-
1277-
.. only:: developer
1278-
1279-
Test: python -m sdc.runtests sdc.tests.test_series.TestSeries.test_series_isalnum_str
1280-
1281-
Parameters
1282-
----------
1283-
self: :class:`pandas.core.strings.StringMethods`
1284-
input arg
1285-
1286-
Returns
1287-
-------
1288-
:obj:`pandas.Series`
1289-
returns :obj:`pandas.Series` object
1290-
"""
12911049

12921050
ty_checker = TypeChecker('Method isalnum().')
12931051
ty_checker.check(self, StringMethodsType)
@@ -1303,6 +1061,25 @@ def hpat_pandas_stringmethods_isalnum_impl(self):
13031061
return hpat_pandas_stringmethods_isalnum_impl
13041062

13051063

1064+
stringmethods_funcs = {
1065+
'istitle': {'method': hpat_pandas_stringmethods_istitle,
1066+
'caption': 'Check if each word start with an upper case letter'},
1067+
'isspace': {'method': hpat_pandas_stringmethods_isspace,
1068+
'caption': 'Check if all the characters in the text are whitespaces'},
1069+
'isalpha': {'method': hpat_pandas_stringmethods_isalpha,
1070+
'caption': 'Check whether all characters in each string are alphabetic'},
1071+
'islower': {'method': hpat_pandas_stringmethods_islower,
1072+
'caption': 'Check if all the characters in the text are alphanumeric'},
1073+
'isalnum': {'method': hpat_pandas_stringmethods_isalnum,
1074+
'caption': 'Check if all the characters in the text are alphanumeric'}
1075+
}
1076+
1077+
1078+
for name, data in stringmethods_funcs.items():
1079+
data['method'].__doc__ = sdc_pandas_series_str_docstring_template.format(**{'method_name': name,
1080+
'caption': data['caption']})
1081+
1082+
13061083
# _hpat_pandas_stringmethods_autogen_methods = sorted(dir(numba.types.misc.UnicodeType.__getattribute__.__qualname__))
13071084
_hpat_pandas_stringmethods_autogen_methods = ['upper', 'lower', 'lstrip', 'rstrip', 'strip']
13081085
"""

0 commit comments

Comments
 (0)