4040
4141 @overload_method(StringMethodsType, 'upper')
4242 def hpat_pandas_stringmethods_upper(self):
43- _func_name = 'Method stringmethods.upper().'
4443
45- if not isinstance(self, StringMethodsType):
46- raise TypingError('{} The object must be a pandas.core.strings. Given: {}'.format(_func_name, self) )
44+ ty_checker = TypeChecker('Method stringmethods.upper().')
45+ ty_checker.check(self, StringMethodsType )
4746
4847 def hpat_pandas_stringmethods_upper_parallel_impl(self):
4948 from numba.parfor import (init_prange, min_checker, internal_prange)
@@ -83,16 +82,17 @@ def hpat_pandas_stringmethods_upper_impl(self):
8382
8483import numba
8584from numba .extending import overload_method
86- from numba .errors import TypingError
8785
86+ from sdc .datatypes .common_functions import TypeChecker
8887from sdc .datatypes .hpat_pandas_stringmethods_types import StringMethodsType
8988
9089
9190_hpat_pandas_stringmethods_autogen_global_dict = {
9291 'pandas' : pandas ,
9392 'numpy' : numpy ,
9493 'numba' : numba ,
95- 'StringMethodsType' : StringMethodsType
94+ 'StringMethodsType' : StringMethodsType ,
95+ 'TypeChecker' : TypeChecker
9696}
9797
9898_hpat_pandas_stringmethods_functions_params = {
@@ -166,8 +166,8 @@ def hpat_pandas_stringmethods_{methodname}(self{methodparams}):
166166 returns :obj:`pandas.Series` object
167167 \" \" \"
168168
169- if not isinstance(self, StringMethodsType):
170- raise TypingError('Method {methodname}(). The object must be a pandas.core.strings. Given: ' % self)
169+ ty_checker = TypeChecker('Method {methodname}().')
170+ ty_checker.check( self, StringMethodsType )
171171
172172 def hpat_pandas_stringmethods_{methodname}_impl(self{methodparams}):
173173 item_count = len(self._data)
@@ -181,12 +181,48 @@ def hpat_pandas_stringmethods_{methodname}_impl(self{methodparams}):
181181 else:
182182 result[it] = item
183183
184- return pandas.Series(result, name=self._data._name)
184+ return pandas.Series(result, self._data._index, name=self._data._name)
185185
186186 return hpat_pandas_stringmethods_{methodname}_impl
187187"""
188188
189189
190+ @overload_method (StringMethodsType , 'isupper' )
191+ def hpat_pandas_stringmethods_isupper (self ):
192+ """
193+ Pandas Series method :meth:`pandas.core.strings.StringMethods.isupper()` implementation.
194+
195+ Note: Unicode type of list elements are supported only. Numpy.NaN is not supported as elements.
196+
197+ .. only:: developer
198+
199+ Test: python -m sdc.runtests sdc.tests.test_series.TestSeries.test_series_str2str
200+
201+ Parameters
202+ ----------
203+ self: :class:`pandas.core.strings.StringMethods`
204+ input arg
205+
206+ Returns
207+ -------
208+ :obj:`pandas.Series`
209+ returns :obj:`pandas.Series` object
210+ """
211+
212+ ty_checker = TypeChecker ('Method isupper().' )
213+ ty_checker .check (self , StringMethodsType )
214+
215+ def hpat_pandas_stringmethods_isupper_impl (self ):
216+ item_count = len (self ._data )
217+ result = numpy .empty (item_count , numba .types .boolean )
218+ for idx , item in enumerate (self ._data ._data ):
219+ result [idx ] = item .isupper ()
220+
221+ return pandas .Series (result , self ._data ._index , name = self ._data ._name )
222+
223+ return hpat_pandas_stringmethods_isupper_impl
224+
225+
190226@overload_method (StringMethodsType , 'len' )
191227def hpat_pandas_stringmethods_len (self ):
192228 """
@@ -209,16 +245,16 @@ def hpat_pandas_stringmethods_len(self):
209245 returns :obj:`pandas.Series` object
210246 """
211247
212- if not isinstance ( self , StringMethodsType ):
213- raise TypingError ( 'Method len(). The object must be a pandas.core.strings. Given: {}' . format (self ) )
248+ ty_checker = TypeChecker ( 'Method len().' )
249+ ty_checker . check (self , StringMethodsType )
214250
215251 def hpat_pandas_stringmethods_len_impl (self ):
216252 item_count = len (self ._data )
217253 result = numpy .empty (item_count , numba .types .int64 )
218254 for idx , item in enumerate (self ._data ._data ):
219255 result [idx ] = len (item )
220256
221- return pandas .Series (result , name = self ._data ._name )
257+ return pandas .Series (result , self . _data . _index , name = self ._data ._name )
222258
223259 return hpat_pandas_stringmethods_len_impl
224260
0 commit comments