From 0d46c6e67da58a87a7c65c1e0808f5304d3b9644 Mon Sep 17 00:00:00 2001 From: mrubtsov Date: Mon, 30 Dec 2019 17:07:47 +0300 Subject: [PATCH 1/6] correction doc --- sdc/datatypes/hpat_pandas_series_functions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdc/datatypes/hpat_pandas_series_functions.py b/sdc/datatypes/hpat_pandas_series_functions.py index 1cb36463c..8d55de8c1 100644 --- a/sdc/datatypes/hpat_pandas_series_functions.py +++ b/sdc/datatypes/hpat_pandas_series_functions.py @@ -146,7 +146,7 @@ def hpat_pandas_series_setitem(self, idx, value): """ Intel Scalable Dataframe Compiler User Guide ******************************************** - Pandas API: pandas.Series.set + Pandas API: pandas.Series.__setitem__ Examples -------- From d1dd95a651a1f02502e2e15e4104628544a2779f Mon Sep 17 00:00:00 2001 From: mrubtsov Date: Mon, 30 Dec 2019 17:25:16 +0300 Subject: [PATCH 2/6] correction doc --- .../hpat_pandas_stringmethods_functions.py | 291 +++--------------- 1 file changed, 37 insertions(+), 254 deletions(-) diff --git a/sdc/datatypes/hpat_pandas_stringmethods_functions.py b/sdc/datatypes/hpat_pandas_stringmethods_functions.py index 5002ade66..50ef27181 100644 --- a/sdc/datatypes/hpat_pandas_stringmethods_functions.py +++ b/sdc/datatypes/hpat_pandas_stringmethods_functions.py @@ -913,12 +913,10 @@ def _hpat_pandas_stringmethods_autogen(method_name): return _hpat_pandas_stringmethods_autogen_global_dict[global_dict_name] -@overload_method(StringMethodsType, 'istitle') -def hpat_pandas_stringmethods_istitle(self): - """ +hpat_pandas_series_str_is_docstring_tmpl = """ Intel Scalable Dataframe Compiler User Guide ******************************************** - Pandas API: pandas.Series.str.istitle + Pandas API: pandas.Series.str.{method_name} Limitations ----------- @@ -926,14 +924,14 @@ def hpat_pandas_stringmethods_istitle(self): Examples -------- - .. literalinclude:: ../../../examples/series/str/series_str_istitle.py + .. literalinclude:: ../../../examples/series/str/series_str_{method_name}.py :language: python :lines: 27- :caption: Check if each word start with an upper case letter - :name: ex_series_str_istitle + :name: ex_series_str_{method_name} - .. command-output:: python ./series/str/series_str_istitle.py - :cwd: ../../../examples + .. command-output:: python ./series/str/series_str_{method_name}.py + :cwd: ../../../examples .. seealso:: :ref:`Series.str.isalpha ` @@ -958,13 +956,13 @@ def hpat_pandas_stringmethods_istitle(self): Intel Scalable Dataframe Compiler Developer Guide ************************************************* - Pandas Series method :meth:`pandas.core.strings.StringMethods.istitle()` implementation. + Pandas Series method :meth:`pandas.core.strings.StringMethods.{method_name}()` implementation. Note: Unicode type of list elements are supported only. Numpy.NaN is not supported as elements. .. only:: developer - Test: python -m sdc.runtests sdc.tests.test_series.TestSeries.test_series_istitle_str + Test: python -m sdc.runtests sdc.tests.test_series.TestSeries.test_series_{method_name}_str Parameters ---------- @@ -975,7 +973,11 @@ def hpat_pandas_stringmethods_istitle(self): ------- :obj:`pandas.Series` returns :obj:`pandas.Series` object - """ +""" + + +@overload_method(StringMethodsType, 'istitle') +def hpat_pandas_stringmethods_istitle(self): ty_checker = TypeChecker('Method istitle().') ty_checker.check(self, StringMethodsType) @@ -993,67 +995,6 @@ def hpat_pandas_stringmethods_istitle_impl(self): @overload_method(StringMethodsType, 'isspace') def hpat_pandas_stringmethods_isspace(self): - """ - Intel Scalable Dataframe Compiler User Guide - ******************************************** - Pandas API: pandas.Series.str.isspace - - Limitations - ----------- - Series elements are expected to be Unicode strings. Elements cannot be NaN. - - Examples - -------- - .. literalinclude:: ../../../examples/series/str/series_str_isspace.py - :language: python - :lines: 27- - :caption: Check if all the characters in the text are whitespaces - :name: ex_series_str_isspace - - .. command-output:: python ./series/str/series_str_isspace.py - :cwd: ../../../examples - - .. seealso:: - :ref:`Series.str.isalpha ` - Check whether all characters are alphabetic. - :ref:`Series.str.isnumeric ` - Check whether all characters are numeric. - :ref:`Series.str.isalnum ` - Check whether all characters are alphanumeric. - :ref:`Series.str.isdigit ` - Check whether all characters are digits. - :ref:`Series.str.isdecimal ` - Check whether all characters are decimal. - :ref:`Series.str.isspace ` - Check whether all characters are whitespace. - :ref:`Series.str.islower ` - Check whether all characters are lowercase. - :ref:`Series.str.isupper ` - Check whether all characters are uppercase. - :ref:`Series.str.istitle ` - Check whether all characters are titlecase. - - Intel Scalable Dataframe Compiler Developer Guide - ************************************************* - - Pandas Series method :meth:`pandas.core.strings.StringMethods.isspace()` implementation. - - Note: Unicode type of list elements are supported only. Numpy.NaN is not supported as elements. - - .. only:: developer - - Test: python -m sdc.runtests sdc.tests.test_series.TestSeries.test_series_isspace_str - - Parameters - ---------- - self: :class:`pandas.core.strings.StringMethods` - input arg - - Returns - ------- - :obj:`pandas.Series` - returns :obj:`pandas.Series` object - """ ty_checker = TypeChecker('Method isspace().') ty_checker.check(self, StringMethodsType) @@ -1071,67 +1012,6 @@ def hpat_pandas_stringmethods_isspace_impl(self): @overload_method(StringMethodsType, 'isalpha') def hpat_pandas_stringmethods_isalpha(self): - """ - Intel Scalable Dataframe Compiler User Guide - ******************************************** - Pandas API: pandas.Series.str.isalpha - - Limitations - ----------- - Series elements are expected to be Unicode strings. Elements cannot be NaN. - - Examples - -------- - .. literalinclude:: ../../../examples/series/str/series_str_isalpha.py - :language: python - :lines: 27- - :caption: Check whether all characters in each string are alphabetic. - :name: ex_series_str_isalpha - - .. command-output:: python ./series/str/series_str_isalpha.py - :cwd: ../../../examples - - .. seealso:: - :ref:`Series.str.isalpha ` - Check whether all characters are alphabetic. - :ref:`Series.str.isnumeric ` - Check whether all characters are numeric. - :ref:`Series.str.isalnum ` - Check whether all characters are alphanumeric. - :ref:`Series.str.isdigit ` - Check whether all characters are digits. - :ref:`Series.str.isdecimal ` - Check whether all characters are decimal. - :ref:`Series.str.isspace ` - Check whether all characters are whitespace. - :ref:`Series.str.islower ` - Check whether all characters are lowercase. - :ref:`Series.str.isupper ` - Check whether all characters are uppercase. - :ref:`Series.str.istitle ` - Check whether all characters are titlecase. - - Intel Scalable Dataframe Compiler Developer Guide - ************************************************* - - Pandas Series method :meth:`pandas.core.strings.StringMethods.isalpha()` implementation. - - Note: Unicode type of list elements are supported only. Numpy.NaN is not supported as elements. - - .. only:: developer - - Test: python -m sdc.runtests sdc.tests.test_series.TestSeries.test_series_isalpha_str - - Parameters - ---------- - self: :class:`pandas.core.strings.StringMethods` - input arg - - Returns - ------- - :obj:`pandas.Series` - returns :obj:`pandas.Series` object - """ ty_checker = TypeChecker('Method isalpha().') ty_checker.check(self, StringMethodsType) @@ -1149,67 +1029,6 @@ def hpat_pandas_stringmethods_isalpha_impl(self): @overload_method(StringMethodsType, 'islower') def hpat_pandas_stringmethods_islower(self): - """ - Intel Scalable Dataframe Compiler User Guide - ******************************************** - Pandas API: pandas.Series.str.islower - - Limitations - ----------- - Series elements are expected to be Unicode strings. Elements cannot be NaN. - - Examples - -------- - .. literalinclude:: ../../../examples/series/str/series_str_islower.py - :language: python - :lines: 27- - :caption: Check if all the characters in the text are alphanumeric - :name: ex_series_str_islower - - .. command-output:: python ./series/str/series_str_islower.py - :cwd: ../../../examples - - .. seealso:: - :ref:`Series.str.isalpha ` - Check whether all characters are alphabetic. - :ref:`Series.str.isnumeric ` - Check whether all characters are numeric. - :ref:`Series.str.isalnum ` - Check whether all characters are alphanumeric. - :ref:`Series.str.isdigit ` - Check whether all characters are digits. - :ref:`Series.str.isdecimal ` - Check whether all characters are decimal. - :ref:`Series.str.isspace ` - Check whether all characters are whitespace. - :ref:`Series.str.islower ` - Check whether all characters are lowercase. - :ref:`Series.str.isupper ` - Check whether all characters are uppercase. - :ref:`Series.str.istitle ` - Check whether all characters are titlecase. - - Intel Scalable Dataframe Compiler Developer Guide - ************************************************* - - Pandas Series method :meth:`pandas.core.strings.StringMethods.islower()` implementation. - - Note: Unicode type of list elements are supported only. Numpy.NaN is not supported as elements. - - .. only:: developer - - Test: python -m sdc.runtests sdc.tests.test_series.TestSeries.test_series_islower_str - - Parameters - ---------- - self: :class:`pandas.core.strings.StringMethods` - input arg - - Returns - ------- - :obj:`pandas.Series` - returns :obj:`pandas.Series` object - """ ty_checker = TypeChecker('Method islower().') ty_checker.check(self, StringMethodsType) @@ -1227,80 +1046,44 @@ def hpat_pandas_stringmethods_islower_impl(self): @overload_method(StringMethodsType, 'isalnum') def hpat_pandas_stringmethods_isalnum(self): - """ - Intel Scalable Dataframe Compiler User Guide - ******************************************** - Pandas API: pandas.Series.str.isalnum - - Limitations - ----------- - Series elements are expected to be Unicode strings. Elements cannot be NaN. - Examples - -------- - .. literalinclude:: ../../../examples/series/str/series_str_isalnum.py - :language: python - :lines: 27- - :caption: Check if all the characters in the text are alphanumeric - :name: ex_series_str_isalnum + ty_checker = TypeChecker('Method isalnum().') + ty_checker.check(self, StringMethodsType) - .. command-output:: python ./series/str/series_str_isalnum.py - :cwd: ../../../examples + def hpat_pandas_stringmethods_isalnum_impl(self): + item_count = len(self._data) + result = numpy.empty(item_count, numba.types.boolean) + for idx, item in enumerate(self._data._data): + result[idx] = item.isalnum() - .. seealso:: - :ref:`Series.str.isalpha ` - Check whether all characters are alphabetic. - :ref:`Series.str.isnumeric ` - Check whether all characters are numeric. - :ref:`Series.str.isalnum ` - Check whether all characters are alphanumeric. - :ref:`Series.str.isdigit ` - Check whether all characters are digits. - :ref:`Series.str.isdecimal ` - Check whether all characters are decimal. - :ref:`Series.str.isspace ` - Check whether all characters are whitespace. - :ref:`Series.str.islower ` - Check whether all characters are lowercase. - :ref:`Series.str.isupper ` - Check whether all characters are uppercase. - :ref:`Series.str.istitle ` - Check whether all characters are titlecase. + return pandas.Series(result, self._data._index, name=self._data._name) - Intel Scalable Dataframe Compiler Developer Guide - ************************************************* + return hpat_pandas_stringmethods_isalnum_impl - Pandas Series method :meth:`pandas.core.strings.StringMethods.isalnum()` implementation. - Note: Unicode type of list elements are supported only. Numpy.NaN is not supported as elements. +hpat_pandas_stringmethods_istitle.__doc__ = hpat_pandas_series_str_is_docstring_tmpl.format(**{ + 'method_name': 'istitle' +}) - .. only:: developer - Test: python -m sdc.runtests sdc.tests.test_series.TestSeries.test_series_isalnum_str +hpat_pandas_stringmethods_isspace.__doc__ = hpat_pandas_series_str_is_docstring_tmpl.format(**{ + 'method_name': 'isspace' +}) - Parameters - ---------- - self: :class:`pandas.core.strings.StringMethods` - input arg - Returns - ------- - :obj:`pandas.Series` - returns :obj:`pandas.Series` object - """ +hpat_pandas_stringmethods_isalpha.__doc__ = hpat_pandas_series_str_is_docstring_tmpl.format(**{ + 'method_name': 'isalpha' +}) - ty_checker = TypeChecker('Method isalnum().') - ty_checker.check(self, StringMethodsType) - def hpat_pandas_stringmethods_isalnum_impl(self): - item_count = len(self._data) - result = numpy.empty(item_count, numba.types.boolean) - for idx, item in enumerate(self._data._data): - result[idx] = item.isalnum() +hpat_pandas_stringmethods_islower.__doc__ = hpat_pandas_series_str_is_docstring_tmpl.format(**{ + 'method_name': 'islower' +}) - return pandas.Series(result, self._data._index, name=self._data._name) - return hpat_pandas_stringmethods_isalnum_impl +hpat_pandas_stringmethods_isalnum.__doc__ = hpat_pandas_series_str_is_docstring_tmpl.format(**{ + 'method_name': 'isalnum' +}) # _hpat_pandas_stringmethods_autogen_methods = sorted(dir(numba.types.misc.UnicodeType.__getattribute__.__qualname__)) From 33f9c2812f443e1eaf43454fff555373dc55ea0e Mon Sep 17 00:00:00 2001 From: mrubtsov Date: Tue, 31 Dec 2019 09:47:35 +0300 Subject: [PATCH 3/6] use of cycle --- .../hpat_pandas_stringmethods_functions.py | 32 ++++++------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/sdc/datatypes/hpat_pandas_stringmethods_functions.py b/sdc/datatypes/hpat_pandas_stringmethods_functions.py index 50ef27181..15ce9f033 100644 --- a/sdc/datatypes/hpat_pandas_stringmethods_functions.py +++ b/sdc/datatypes/hpat_pandas_stringmethods_functions.py @@ -913,7 +913,7 @@ def _hpat_pandas_stringmethods_autogen(method_name): return _hpat_pandas_stringmethods_autogen_global_dict[global_dict_name] -hpat_pandas_series_str_is_docstring_tmpl = """ +sdc_pandas_series_str_docstring_template = """ Intel Scalable Dataframe Compiler User Guide ******************************************** Pandas API: pandas.Series.str.{method_name} @@ -1061,29 +1061,17 @@ def hpat_pandas_stringmethods_isalnum_impl(self): return hpat_pandas_stringmethods_isalnum_impl -hpat_pandas_stringmethods_istitle.__doc__ = hpat_pandas_series_str_is_docstring_tmpl.format(**{ - 'method_name': 'istitle' -}) - - -hpat_pandas_stringmethods_isspace.__doc__ = hpat_pandas_series_str_is_docstring_tmpl.format(**{ - 'method_name': 'isspace' -}) - - -hpat_pandas_stringmethods_isalpha.__doc__ = hpat_pandas_series_str_is_docstring_tmpl.format(**{ - 'method_name': 'isalpha' -}) - - -hpat_pandas_stringmethods_islower.__doc__ = hpat_pandas_series_str_is_docstring_tmpl.format(**{ - 'method_name': 'islower' -}) +stringmethods_funcs = { + 'istitle': hpat_pandas_stringmethods_istitle, + 'isspace': hpat_pandas_stringmethods_isspace, + 'isalpha': hpat_pandas_stringmethods_isalpha, + 'islower': hpat_pandas_stringmethods_islower, + 'isalnum': hpat_pandas_stringmethods_isalnum +} -hpat_pandas_stringmethods_isalnum.__doc__ = hpat_pandas_series_str_is_docstring_tmpl.format(**{ - 'method_name': 'isalnum' -}) +for name, method in stringmethods_funcs.items(): + method.__doc__ = sdc_pandas_series_str_docstring_template.format(**{'method_name': name}) # _hpat_pandas_stringmethods_autogen_methods = sorted(dir(numba.types.misc.UnicodeType.__getattribute__.__qualname__)) From cab1d66bf3dec717252e03eb310c041f8326cf7f Mon Sep 17 00:00:00 2001 From: mrubtsov Date: Tue, 31 Dec 2019 14:06:39 +0300 Subject: [PATCH 4/6] correction doc, add captions --- .../hpat_pandas_stringmethods_functions.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/sdc/datatypes/hpat_pandas_stringmethods_functions.py b/sdc/datatypes/hpat_pandas_stringmethods_functions.py index 15ce9f033..ad5dccdd2 100644 --- a/sdc/datatypes/hpat_pandas_stringmethods_functions.py +++ b/sdc/datatypes/hpat_pandas_stringmethods_functions.py @@ -927,7 +927,7 @@ def _hpat_pandas_stringmethods_autogen(method_name): .. literalinclude:: ../../../examples/series/str/series_str_{method_name}.py :language: python :lines: 27- - :caption: Check if each word start with an upper case letter + :caption: {caption} :name: ex_series_str_{method_name} .. command-output:: python ./series/str/series_str_{method_name}.py @@ -1069,9 +1069,18 @@ def hpat_pandas_stringmethods_isalnum_impl(self): 'isalnum': hpat_pandas_stringmethods_isalnum } +stringmethods_captions = { + 'istitle': 'Check if each word start with an upper case letter', + 'isspace': 'Check if all the characters in the text are whitespaces', + 'isalpha': 'Check whether all characters in each string are alphabetic', + 'islower': 'Check if all the characters in the text are alphanumeric', + 'isalnum': 'Check if all the characters in the text are alphanumeric' +} + for name, method in stringmethods_funcs.items(): - method.__doc__ = sdc_pandas_series_str_docstring_template.format(**{'method_name': name}) + method.__doc__ = sdc_pandas_series_str_docstring_template.format(**{'method_name': name, + 'caption': stringmethods_captions[name]}) # _hpat_pandas_stringmethods_autogen_methods = sorted(dir(numba.types.misc.UnicodeType.__getattribute__.__qualname__)) From 70235cfd8e66afd135de0aa0816ac7148b1d72c0 Mon Sep 17 00:00:00 2001 From: mrubtsov Date: Tue, 31 Dec 2019 15:05:59 +0300 Subject: [PATCH 5/6] correction dict for doc --- .../hpat_pandas_stringmethods_functions.py | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/sdc/datatypes/hpat_pandas_stringmethods_functions.py b/sdc/datatypes/hpat_pandas_stringmethods_functions.py index ad5dccdd2..5a8e9bb68 100644 --- a/sdc/datatypes/hpat_pandas_stringmethods_functions.py +++ b/sdc/datatypes/hpat_pandas_stringmethods_functions.py @@ -1062,25 +1062,22 @@ def hpat_pandas_stringmethods_isalnum_impl(self): stringmethods_funcs = { - 'istitle': hpat_pandas_stringmethods_istitle, - 'isspace': hpat_pandas_stringmethods_isspace, - 'isalpha': hpat_pandas_stringmethods_isalpha, - 'islower': hpat_pandas_stringmethods_islower, - 'isalnum': hpat_pandas_stringmethods_isalnum -} - -stringmethods_captions = { - 'istitle': 'Check if each word start with an upper case letter', - 'isspace': 'Check if all the characters in the text are whitespaces', - 'isalpha': 'Check whether all characters in each string are alphabetic', - 'islower': 'Check if all the characters in the text are alphanumeric', - 'isalnum': 'Check if all the characters in the text are alphanumeric' + 'istitle': {'method': hpat_pandas_stringmethods_istitle, + 'caption': 'Check if each word start with an upper case letter'}, + 'isspace': {'method': hpat_pandas_stringmethods_isspace, + 'caption': 'Check if all the characters in the text are whitespaces'}, + 'isalpha': {'method': hpat_pandas_stringmethods_isalpha, + 'caption': 'Check whether all characters in each string are alphabetic'}, + 'islower': {'method': hpat_pandas_stringmethods_islower, + 'caption': 'Check if all the characters in the text are alphanumeric'}, + 'isalnum': {'method': hpat_pandas_stringmethods_isalnum, + 'caption': 'Check if all the characters in the text are alphanumeric'} } -for name, method in stringmethods_funcs.items(): - method.__doc__ = sdc_pandas_series_str_docstring_template.format(**{'method_name': name, - 'caption': stringmethods_captions[name]}) +for name, data in stringmethods_funcs.items(): + data['method'].__doc__ = sdc_pandas_series_str_docstring_template.format(**{'method_name': name, + 'caption': data['caption']}) # _hpat_pandas_stringmethods_autogen_methods = sorted(dir(numba.types.misc.UnicodeType.__getattribute__.__qualname__)) From 8ec8195faaf438c20b82cef0692576a99fa8bc02 Mon Sep 17 00:00:00 2001 From: mrubtsov Date: Tue, 31 Dec 2019 15:08:14 +0300 Subject: [PATCH 6/6] correction problem with PEP8 --- sdc/datatypes/hpat_pandas_stringmethods_functions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdc/datatypes/hpat_pandas_stringmethods_functions.py b/sdc/datatypes/hpat_pandas_stringmethods_functions.py index 5a8e9bb68..2bf902102 100644 --- a/sdc/datatypes/hpat_pandas_stringmethods_functions.py +++ b/sdc/datatypes/hpat_pandas_stringmethods_functions.py @@ -1077,7 +1077,7 @@ def hpat_pandas_stringmethods_isalnum_impl(self): for name, data in stringmethods_funcs.items(): data['method'].__doc__ = sdc_pandas_series_str_docstring_template.format(**{'method_name': name, - 'caption': data['caption']}) + 'caption': data['caption']}) # _hpat_pandas_stringmethods_autogen_methods = sorted(dir(numba.types.misc.UnicodeType.__getattribute__.__qualname__))