@@ -2424,6 +2424,59 @@ def test_impl(S1, S2):
24242424 hpat_func (S1 , S2 ), test_impl (S1 , S2 ),
24252425 err_msg = 'S1={}\n S2={}' .format (S1 , S2 ))
24262426
2427+ def test_series_str_find (self ):
2428+ def test_impl (series , sub ):
2429+ return series .str .find (sub )
2430+ hpat_func = self .jit (test_impl )
2431+
2432+ data = test_global_input_data_unicode_kind4
2433+ subs = ['' ] + [s [:min (len (s ) for s in data )] for s in data ] + data
2434+ indices = [None , list (range (len (data )))[::- 1 ], data [::- 1 ]]
2435+ names = [None , 'A' ]
2436+ for index , name in product (indices , names ):
2437+ series = pd .Series (data , index , name = name )
2438+ for sub in subs :
2439+ pd .testing .assert_series_equal (hpat_func (series , sub ),
2440+ test_impl (series , sub ))
2441+
2442+ def test_series_str_find_exception_unsupported_start (self ):
2443+ def test_impl (series , sub , start ):
2444+ return series .str .find (sub , start )
2445+ hpat_func = self .jit (test_impl )
2446+
2447+ series = pd .Series (test_global_input_data_unicode_kind4 )
2448+ msg_tmpl = 'Method {}(). The object {}\n {}'
2449+
2450+ with self .assertRaises (TypingError ) as raises :
2451+ hpat_func (series , '' , '0' )
2452+ msg = msg_tmpl .format ('find' , 'start' , 'given: unicode_type\n '
2453+ 'expected: None, int' )
2454+ self .assertIn (msg , str (raises .exception ))
2455+
2456+ with self .assertRaises (ValueError ) as raises :
2457+ hpat_func (series , '' , 1 )
2458+ msg = msg_tmpl .format ('find' , 'start' , 'expected: 0' )
2459+ self .assertIn (msg , str (raises .exception ))
2460+
2461+ def test_series_str_find_exception_unsupported_end (self ):
2462+ def test_impl (series , sub , start , end ):
2463+ return series .str .find (sub , start , end )
2464+ hpat_func = self .jit (test_impl )
2465+
2466+ series = pd .Series (test_global_input_data_unicode_kind4 )
2467+ msg_tmpl = 'Method {}(). The object {}\n {}'
2468+
2469+ with self .assertRaises (TypingError ) as raises :
2470+ hpat_func (series , '' , 0 , 'None' )
2471+ msg = msg_tmpl .format ('find' , 'end' , 'given: unicode_type\n '
2472+ 'expected: None, int' )
2473+ self .assertIn (msg , str (raises .exception ))
2474+
2475+ with self .assertRaises (ValueError ) as raises :
2476+ hpat_func (series , '' , 0 , 0 )
2477+ msg = msg_tmpl .format ('find' , 'end' , 'expected: None' )
2478+ self .assertIn (msg , str (raises .exception ))
2479+
24272480 def test_series_str_len1 (self ):
24282481 def test_impl (S ):
24292482 return S .str .len ()
0 commit comments