@@ -7188,6 +7188,73 @@ def test_impl(A, idx):
71887188 msg = 'The index of boolean indexer is not comparable to Series index.'
71897189 self .assertIn (msg , str (raises .exception ))
71907190
7191+ def test_series_skew (self ):
7192+ def test_impl (series , axis , skipna ):
7193+ return series .skew (axis = axis , skipna = skipna )
7194+
7195+ hpat_func = self .jit (test_impl )
7196+ test_data = [[6 , 6 , 2 , 1 , 3 , 3 , 2 , 1 , 2 ],
7197+ [1.1 , 0.3 , 2.1 , 1 , 3 , 0.3 , 2.1 , 1.1 , 2.2 ],
7198+ [6 , 6.1 , 2.2 , 1 , 3 , 3 , 2.2 , 1 , 2 ],
7199+ [],
7200+ [6 , 6 , np .nan , 2 , np .nan , 1 , 3 , 3 , np .inf , 2 , 1 , 2 , np .inf ],
7201+ [1.1 , 0.3 , np .nan , 1.0 , np .inf , 0.3 , 2.1 , np .nan , 2.2 , np .inf ],
7202+ [1.1 , 0.3 , np .nan , 1 , np .inf , 0 , 1.1 , np .nan , 2.2 , np .inf , 2 , 2 ],
7203+ [np .nan , np .nan , np .nan ],
7204+ [np .nan , np .nan , np .inf ],
7205+ [np .inf , 0 , np .inf , 1 , 2 , 3 , 4 , 5 ]
7206+ ]
7207+ all_test_data = test_data + test_global_input_data_float64
7208+ for data in all_test_data :
7209+ with self .subTest (data = data ):
7210+ s = pd .Series (data )
7211+ for axis in [0 , None ]:
7212+ with self .subTest (axis = axis ):
7213+ for skipna in [None , False , True ]:
7214+ with self .subTest (skipna = skipna ):
7215+ res1 = test_impl (s , axis , skipna )
7216+ res2 = hpat_func (s , axis , skipna )
7217+ np .testing .assert_allclose (res1 , res2 )
7218+
7219+ def test_series_skew_default (self ):
7220+ def test_impl ():
7221+ s = pd .Series ([np .nan , - 2. , 3. , 9.1 ])
7222+ return s .skew ()
7223+
7224+ hpat_func = self .jit (test_impl )
7225+ np .testing .assert_allclose (test_impl (), hpat_func ())
7226+
7227+ def test_series_skew_not_supported (self ):
7228+ def test_impl (series , axis = None , skipna = None , level = None , numeric_only = None ):
7229+ return series .skew (axis = axis , skipna = skipna , level = level , numeric_only = numeric_only )
7230+
7231+ hpat_func = self .jit (test_impl )
7232+ s = pd .Series ([1.1 , 0.3 , np .nan , 1 , np .inf , 0 , 1.1 , np .nan , 2.2 , np .inf , 2 , 2 ])
7233+ with self .assertRaises (TypingError ) as raises :
7234+ hpat_func (s , axis = 0.75 )
7235+ msg = 'TypingError: Method Series.skew() The object axis\n given: float64\n expected: int64'
7236+ self .assertIn (msg , str (raises .exception ))
7237+
7238+ with self .assertRaises (TypingError ) as raises :
7239+ hpat_func (s , skipna = 0 )
7240+ msg = 'TypingError: Method Series.skew() The object skipna\n given: int64\n expected: bool'
7241+ self .assertIn (msg , str (raises .exception ))
7242+
7243+ with self .assertRaises (TypingError ) as raises :
7244+ hpat_func (s , level = 0 )
7245+ msg = 'TypingError: Method Series.skew() The object level\n given: int64\n expected: None'
7246+ self .assertIn (msg , str (raises .exception ))
7247+
7248+ with self .assertRaises (TypingError ) as raises :
7249+ hpat_func (s , numeric_only = 0 )
7250+ msg = 'TypingError: Method Series.skew() The object numeric_only\n given: int64\n expected: None'
7251+ self .assertIn (msg , str (raises .exception ))
7252+
7253+ with self .assertRaises (ValueError ) as raises :
7254+ hpat_func (s , axis = 5 )
7255+ msg = 'Parameter axis must be only 0 or None.'
7256+ self .assertIn (msg , str (raises .exception ))
7257+
71917258
71927259if __name__ == "__main__" :
71937260 unittest .main ()
0 commit comments