|
41 | 41 | from sdc.tests.test_series import gen_frand_array
|
42 | 42 | from sdc.tests.test_utils import (count_array_REPs, count_parfor_REPs,
|
43 | 43 | skip_numba_jit, skip_sdc_jit,
|
44 |
| - test_global_input_data_float64) |
| 44 | + test_global_input_data_float64, |
| 45 | + assert_raises_ty_checker) |
45 | 46 |
|
46 | 47 |
|
47 | 48 | LONG_TEST = (int(os.environ['SDC_LONG_ROLLING_TEST']) != 0
|
@@ -480,42 +481,42 @@ def test_impl(obj, window, min_periods, center,
|
480 | 481 | win_type, on, axis, closed).min()
|
481 | 482 |
|
482 | 483 | hpat_func = self.jit(test_impl)
|
483 |
| - msg_tmpl = 'Method rolling(). The object {}\n given: {}\n expected: {}' |
484 | 484 |
|
485 |
| - with self.assertRaises(TypingError) as raises: |
486 |
| - hpat_func(obj, '1', None, False, None, None, 0, None) |
487 |
| - msg = msg_tmpl.format('window', 'unicode_type', 'int') |
488 |
| - self.assertIn(msg, str(raises.exception)) |
489 |
| - |
490 |
| - with self.assertRaises(TypingError) as raises: |
491 |
| - hpat_func(obj, 1, '1', False, None, None, 0, None) |
492 |
| - msg = msg_tmpl.format('min_periods', 'unicode_type', 'None, int') |
493 |
| - self.assertIn(msg, str(raises.exception)) |
494 |
| - |
495 |
| - with self.assertRaises(TypingError) as raises: |
496 |
| - hpat_func(obj, 1, None, 0, None, None, 0, None) |
497 |
| - msg = msg_tmpl.format('center', 'int64', 'bool') |
498 |
| - self.assertIn(msg, str(raises.exception)) |
499 |
| - |
500 |
| - with self.assertRaises(TypingError) as raises: |
501 |
| - hpat_func(obj, 1, None, False, -1, None, 0, None) |
502 |
| - msg = msg_tmpl.format('win_type', 'int64', 'str') |
503 |
| - self.assertIn(msg, str(raises.exception)) |
504 |
| - |
505 |
| - with self.assertRaises(TypingError) as raises: |
506 |
| - hpat_func(obj, 1, None, False, None, -1, 0, None) |
507 |
| - msg = msg_tmpl.format('on', 'int64', 'str') |
508 |
| - self.assertIn(msg, str(raises.exception)) |
509 |
| - |
510 |
| - with self.assertRaises(TypingError) as raises: |
511 |
| - hpat_func(obj, 1, None, False, None, None, None, None) |
512 |
| - msg = msg_tmpl.format('axis', 'none', 'int, str') |
513 |
| - self.assertIn(msg, str(raises.exception)) |
514 |
| - |
515 |
| - with self.assertRaises(TypingError) as raises: |
516 |
| - hpat_func(obj, 1, None, False, None, None, 0, -1) |
517 |
| - msg = msg_tmpl.format('closed', 'int64', 'str') |
518 |
| - self.assertIn(msg, str(raises.exception)) |
| 485 | + method_name = 'Method rolling().' |
| 486 | + assert_raises_ty_checker(self, |
| 487 | + [method_name, 'window', 'unicode_type', 'int'], |
| 488 | + hpat_func, |
| 489 | + obj, '1', None, False, None, None, 0, None) |
| 490 | + |
| 491 | + assert_raises_ty_checker(self, |
| 492 | + [method_name, 'min_periods', 'unicode_type', 'None, int'], |
| 493 | + hpat_func, |
| 494 | + obj, 1, '1', False, None, None, 0, None) |
| 495 | + |
| 496 | + assert_raises_ty_checker(self, |
| 497 | + [method_name, 'center', 'int64', 'bool'], |
| 498 | + hpat_func, |
| 499 | + obj, 1, None, 0, None, None, 0, None) |
| 500 | + |
| 501 | + assert_raises_ty_checker(self, |
| 502 | + [method_name, 'win_type', 'int64', 'str'], |
| 503 | + hpat_func, |
| 504 | + obj, 1, None, False, -1, None, 0, None) |
| 505 | + |
| 506 | + assert_raises_ty_checker(self, |
| 507 | + [method_name, 'on', 'int64', 'str'], |
| 508 | + hpat_func, |
| 509 | + obj, 1, None, False, None, -1, 0, None) |
| 510 | + |
| 511 | + assert_raises_ty_checker(self, |
| 512 | + [method_name, 'axis', 'none', 'int, str'], |
| 513 | + hpat_func, |
| 514 | + obj, 1, None, False, None, None, None, None) |
| 515 | + |
| 516 | + assert_raises_ty_checker(self, |
| 517 | + [method_name, 'closed', 'int64', 'str'], |
| 518 | + hpat_func, |
| 519 | + obj, 1, None, False, None, None, 0, -1) |
519 | 520 |
|
520 | 521 | def _test_rolling_apply_mean(self, obj):
|
521 | 522 | def test_impl(obj, window, min_periods):
|
@@ -548,10 +549,10 @@ def func(x):
|
548 | 549 |
|
549 | 550 | hpat_func = self.jit(test_impl)
|
550 | 551 |
|
551 |
| - with self.assertRaises(TypingError) as raises: |
552 |
| - hpat_func(obj, 1) |
553 |
| - msg = 'Method rolling.apply(). The object raw\n given: int64\n expected: bool' |
554 |
| - self.assertIn(msg, str(raises.exception)) |
| 552 | + assert_raises_ty_checker(self, |
| 553 | + ['Method rolling.apply().', 'raw', 'int64', 'bool'], |
| 554 | + hpat_func, |
| 555 | + obj, 1) |
555 | 556 |
|
556 | 557 | def _test_rolling_apply_args(self, obj):
|
557 | 558 | def test_impl(obj, window, min_periods, q):
|
@@ -610,10 +611,10 @@ def test_impl(obj, pairwise):
|
610 | 611 |
|
611 | 612 | hpat_func = self.jit(test_impl)
|
612 | 613 |
|
613 |
| - with self.assertRaises(TypingError) as raises: |
614 |
| - hpat_func(obj, 1) |
615 |
| - msg = 'Method rolling.corr(). The object pairwise\n given: int64\n expected: bool' |
616 |
| - self.assertIn(msg, str(raises.exception)) |
| 614 | + assert_raises_ty_checker(self, |
| 615 | + ['Method rolling.corr().', 'pairwise', 'int64', 'bool'], |
| 616 | + hpat_func, |
| 617 | + obj, 1) |
617 | 618 |
|
618 | 619 | def _test_rolling_count(self, obj):
|
619 | 620 | def test_impl(obj, window, min_periods):
|
@@ -666,17 +667,16 @@ def test_impl(obj, pairwise, ddof):
|
666 | 667 |
|
667 | 668 | hpat_func = self.jit(test_impl)
|
668 | 669 |
|
669 |
| - msg_tmpl = 'Method rolling.cov(). The object {}\n given: {}\n expected: {}' |
| 670 | + method_name = 'Method rolling.cov().' |
| 671 | + assert_raises_ty_checker(self, |
| 672 | + [method_name, 'pairwise', 'int64', 'bool'], |
| 673 | + hpat_func, |
| 674 | + obj, 1, 1) |
670 | 675 |
|
671 |
| - with self.assertRaises(TypingError) as raises: |
672 |
| - hpat_func(obj, 1, 1) |
673 |
| - msg = msg_tmpl.format('pairwise', 'int64', 'bool') |
674 |
| - self.assertIn(msg, str(raises.exception)) |
675 |
| - |
676 |
| - with self.assertRaises(TypingError) as raises: |
677 |
| - hpat_func(obj, None, '1') |
678 |
| - msg = msg_tmpl.format('ddof', 'unicode_type', 'int') |
679 |
| - self.assertIn(msg, str(raises.exception)) |
| 676 | + assert_raises_ty_checker(self, |
| 677 | + [method_name, 'ddof', 'unicode_type', 'int'], |
| 678 | + hpat_func, |
| 679 | + obj, None, '1') |
680 | 680 |
|
681 | 681 | def _test_rolling_kurt(self, obj):
|
682 | 682 | def test_impl(obj, window, min_periods):
|
@@ -777,17 +777,16 @@ def test_impl(obj, quantile, interpolation):
|
777 | 777 |
|
778 | 778 | hpat_func = self.jit(test_impl)
|
779 | 779 |
|
780 |
| - msg_tmpl = 'Method rolling.quantile(). The object {}\n given: {}\n expected: {}' |
| 780 | + method_name = 'Method rolling.quantile().' |
| 781 | + assert_raises_ty_checker(self, |
| 782 | + [method_name, 'quantile', 'unicode_type', 'float'], |
| 783 | + hpat_func, |
| 784 | + obj, '0.5', 'linear') |
781 | 785 |
|
782 |
| - with self.assertRaises(TypingError) as raises: |
783 |
| - hpat_func(obj, '0.5', 'linear') |
784 |
| - msg = msg_tmpl.format('quantile', 'unicode_type', 'float') |
785 |
| - self.assertIn(msg, str(raises.exception)) |
786 |
| - |
787 |
| - with self.assertRaises(TypingError) as raises: |
788 |
| - hpat_func(obj, 0.5, None) |
789 |
| - msg = msg_tmpl.format('interpolation', 'none', 'str') |
790 |
| - self.assertIn(msg, str(raises.exception)) |
| 786 | + assert_raises_ty_checker(self, |
| 787 | + [method_name, 'interpolation', 'none', 'str'], |
| 788 | + hpat_func, |
| 789 | + obj, 0.5, None) |
791 | 790 |
|
792 | 791 | def _test_rolling_quantile_exception_unsupported_values(self, obj):
|
793 | 792 | def test_impl(obj, quantile, interpolation):
|
@@ -836,10 +835,10 @@ def _test_rolling_std_exception_unsupported_ddof(self, obj):
|
836 | 835 | hpat_func = self.jit(test_impl)
|
837 | 836 |
|
838 | 837 | window, min_periods, invalid_ddof = 3, 2, '1'
|
839 |
| - with self.assertRaises(TypingError) as raises: |
840 |
| - hpat_func(obj, window, min_periods, invalid_ddof) |
841 |
| - msg = 'Method rolling.std(). The object ddof\n given: unicode_type\n expected: int' |
842 |
| - self.assertIn(msg, str(raises.exception)) |
| 838 | + assert_raises_ty_checker(self, |
| 839 | + ['Method rolling.std().', 'ddof', 'unicode_type', 'int'], |
| 840 | + hpat_func, |
| 841 | + obj, window, min_periods, invalid_ddof) |
843 | 842 |
|
844 | 843 | def _test_rolling_sum(self, obj):
|
845 | 844 | def test_impl(obj, window, min_periods):
|
@@ -874,10 +873,10 @@ def _test_rolling_var_exception_unsupported_ddof(self, obj):
|
874 | 873 | hpat_func = self.jit(test_impl)
|
875 | 874 |
|
876 | 875 | window, min_periods, invalid_ddof = 3, 2, '1'
|
877 |
| - with self.assertRaises(TypingError) as raises: |
878 |
| - hpat_func(obj, window, min_periods, invalid_ddof) |
879 |
| - msg = 'Method rolling.var(). The object ddof\n given: unicode_type\n expected: int' |
880 |
| - self.assertIn(msg, str(raises.exception)) |
| 876 | + assert_raises_ty_checker(self, |
| 877 | + ['Method rolling.var().', 'ddof', 'unicode_type', 'int'], |
| 878 | + hpat_func, |
| 879 | + obj, window, min_periods, invalid_ddof) |
881 | 880 |
|
882 | 881 | @skip_sdc_jit('DataFrame.rolling.min() unsupported exceptions')
|
883 | 882 | def test_df_rolling_unsupported_values(self):
|
|
0 commit comments