@@ -2424,6 +2424,67 @@ 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_center_default_fillchar (self ):
2428+ def test_impl (series , width ):
2429+ return series .str .center (width )
2430+
2431+ hpat_func = self .jit (test_impl )
2432+
2433+ data = test_global_input_data_unicode_kind1
2434+ series = pd .Series (data )
2435+ width = max (len (s ) for s in data ) + 10
2436+
2437+ pd .testing .assert_series_equal (hpat_func (series , width ),
2438+ test_impl (series , width ))
2439+
2440+ def test_series_str_center (self ):
2441+ def test_impl (series , width , fillchar ):
2442+ return series .str .center (width , fillchar )
2443+
2444+ hpat_func = self .jit (test_impl )
2445+
2446+ data = test_global_input_data_unicode_kind1
2447+ data_lengths = [len (s ) for s in data ]
2448+ widths = [max (data_lengths ) + 10 , min (data_lengths )]
2449+
2450+ for index in [None , list (range (len (data )))[::- 1 ], data [::- 1 ]]:
2451+ series = pd .Series (data , index , name = 'A' )
2452+ for width , fillchar in product (widths , ['\t ' ]):
2453+ jit_result = hpat_func (series , width , fillchar )
2454+ ref_result = test_impl (series , width , fillchar )
2455+ pd .testing .assert_series_equal (jit_result , ref_result )
2456+
2457+ def test_series_str_center_exception_unsupported_fillchar (self ):
2458+ def test_impl (series , width , fillchar ):
2459+ return series .str .center (width , fillchar )
2460+
2461+ hpat_func = self .jit (test_impl )
2462+
2463+ data = test_global_input_data_unicode_kind1
2464+ series = pd .Series (data )
2465+ width = max (len (s ) for s in data ) + 10
2466+
2467+ with self .assertRaises (TypingError ) as raises :
2468+ hpat_func (series , width , 10 )
2469+ msg_tmpl = 'Method center(). The object fillchar\n {}'
2470+ msg = msg_tmpl .format ('given: int64\n expected: str' )
2471+ self .assertIn (msg , str (raises .exception ))
2472+
2473+ def test_series_str_center_exception_unsupported_kind4 (self ):
2474+ def test_impl (series , width ):
2475+ return series .str .center (width )
2476+
2477+ hpat_func = self .jit (test_impl )
2478+
2479+ data = test_global_input_data_unicode_kind4
2480+ series = pd .Series (data )
2481+ width = max (len (s ) for s in data ) + 10
2482+
2483+ with self .assertRaises (SystemError ) as raises :
2484+ hpat_func (series , width )
2485+ msg = 'NULL object passed to Py_BuildValue'
2486+ self .assertIn (msg , str (raises .exception ))
2487+
24272488 def test_series_str_endswith (self ):
24282489 def test_impl (series , pat ):
24292490 return series .str .endswith (pat )
0 commit comments