|
15 | 15 | from .helper import (
|
16 | 16 | get_all_dtypes,
|
17 | 17 | get_float_complex_dtypes,
|
| 18 | + get_float_dtypes, |
18 | 19 | has_support_aspect64,
|
19 | 20 | is_cpu_device,
|
20 | 21 | is_win_platform,
|
@@ -597,119 +598,125 @@ def test_gradient_y1_dx(self, array, dx):
|
597 | 598 |
|
598 | 599 |
|
599 | 600 | class TestCeil:
|
600 |
| - def test_ceil(self): |
| 601 | + @pytest.mark.parametrize("dtype", get_float_dtypes()) |
| 602 | + def test_ceil(self, dtype): |
601 | 603 | array_data = numpy.arange(10)
|
602 |
| - out = numpy.empty(10, dtype=numpy.float64) |
| 604 | + out = numpy.empty(10, dtype) |
603 | 605 |
|
604 | 606 | # DPNP
|
605 |
| - dp_array = dpnp.array(array_data, dtype=dpnp.float64) |
606 |
| - dp_out = dpnp.array(out, dtype=dpnp.float64) |
| 607 | + dp_array = dpnp.array(array_data, dtype=dtype) |
| 608 | + dp_out = dpnp.array(out, dtype=dtype) |
607 | 609 | result = dpnp.ceil(dp_array, out=dp_out)
|
608 | 610 |
|
609 | 611 | # original
|
610 |
| - np_array = numpy.array(array_data, dtype=numpy.float64) |
| 612 | + np_array = numpy.array(array_data, dtype=dtype) |
611 | 613 | expected = numpy.ceil(np_array, out=out)
|
612 | 614 |
|
613 | 615 | assert_array_equal(expected, result)
|
614 | 616 |
|
615 | 617 | @pytest.mark.parametrize(
|
616 |
| - "dtype", |
617 |
| - [numpy.float32, numpy.int64, numpy.int32], |
618 |
| - ids=["numpy.float32", "numpy.int64", "numpy.int32"], |
| 618 | + "dtype", get_all_dtypes(no_bool=True, no_complex=True, no_none=True) |
619 | 619 | )
|
620 | 620 | def test_invalid_dtype(self, dtype):
|
621 |
| - dp_array = dpnp.arange(10, dtype=dpnp.float64) |
| 621 | + dpnp_dtype = dpnp.float64 if has_support_aspect64() else dpnp.float32 |
| 622 | + pytest.skip("similar data types") if dpnp_dtype == dtype else None |
| 623 | + dp_array = dpnp.arange(10, dtype=dpnp_dtype) |
622 | 624 | dp_out = dpnp.empty(10, dtype=dtype)
|
623 | 625 |
|
624 |
| - with pytest.raises(ValueError): |
| 626 | + with pytest.raises(TypeError): |
625 | 627 | dpnp.ceil(dp_array, out=dp_out)
|
626 | 628 |
|
| 629 | + @pytest.mark.parametrize("dtype", get_float_dtypes()) |
627 | 630 | @pytest.mark.parametrize(
|
628 | 631 | "shape", [(0,), (15,), (2, 2)], ids=["(0,)", "(15, )", "(2,2)"]
|
629 | 632 | )
|
630 |
| - def test_invalid_shape(self, shape): |
631 |
| - dp_array = dpnp.arange(10, dtype=dpnp.float64) |
632 |
| - dp_out = dpnp.empty(shape, dtype=dpnp.float64) |
| 633 | + def test_invalid_shape(self, shape, dtype): |
| 634 | + dp_array = dpnp.arange(10, dtype=dtype) |
| 635 | + dp_out = dpnp.empty(shape, dtype=dtype) |
633 | 636 |
|
634 |
| - with pytest.raises(ValueError): |
| 637 | + with pytest.raises(TypeError): |
635 | 638 | dpnp.ceil(dp_array, out=dp_out)
|
636 | 639 |
|
637 | 640 |
|
638 | 641 | class TestFloor:
|
639 |
| - def test_floor(self): |
| 642 | + @pytest.mark.parametrize("dtype", get_float_dtypes()) |
| 643 | + def test_floor(self, dtype): |
640 | 644 | array_data = numpy.arange(10)
|
641 |
| - out = numpy.empty(10, dtype=numpy.float64) |
| 645 | + out = numpy.empty(10, dtype=dtype) |
642 | 646 |
|
643 | 647 | # DPNP
|
644 |
| - dp_array = dpnp.array(array_data, dtype=dpnp.float64) |
645 |
| - dp_out = dpnp.array(out, dtype=dpnp.float64) |
| 648 | + dp_array = dpnp.array(array_data, dtype=dtype) |
| 649 | + dp_out = dpnp.array(out, dtype=dtype) |
646 | 650 | result = dpnp.floor(dp_array, out=dp_out)
|
647 | 651 |
|
648 | 652 | # original
|
649 |
| - np_array = numpy.array(array_data, dtype=numpy.float64) |
| 653 | + np_array = numpy.array(array_data, dtype=dtype) |
650 | 654 | expected = numpy.floor(np_array, out=out)
|
651 | 655 |
|
652 | 656 | assert_array_equal(expected, result)
|
653 | 657 |
|
654 | 658 | @pytest.mark.parametrize(
|
655 |
| - "dtype", |
656 |
| - [numpy.float32, numpy.int64, numpy.int32], |
657 |
| - ids=["numpy.float32", "numpy.int64", "numpy.int32"], |
| 659 | + "dtype", get_all_dtypes(no_bool=True, no_complex=True, no_none=True) |
658 | 660 | )
|
659 | 661 | def test_invalid_dtype(self, dtype):
|
660 |
| - dp_array = dpnp.arange(10, dtype=dpnp.float64) |
| 662 | + dpnp_dtype = dpnp.float64 if has_support_aspect64() else dpnp.float32 |
| 663 | + pytest.skip("similar data types") if dpnp_dtype == dtype else None |
| 664 | + dp_array = dpnp.arange(10, dtype=dpnp_dtype) |
661 | 665 | dp_out = dpnp.empty(10, dtype=dtype)
|
662 | 666 |
|
663 |
| - with pytest.raises(ValueError): |
| 667 | + with pytest.raises(TypeError): |
664 | 668 | dpnp.floor(dp_array, out=dp_out)
|
665 | 669 |
|
| 670 | + @pytest.mark.parametrize("dtype", get_float_dtypes()) |
666 | 671 | @pytest.mark.parametrize(
|
667 | 672 | "shape", [(0,), (15,), (2, 2)], ids=["(0,)", "(15, )", "(2,2)"]
|
668 | 673 | )
|
669 |
| - def test_invalid_shape(self, shape): |
670 |
| - dp_array = dpnp.arange(10, dtype=dpnp.float64) |
671 |
| - dp_out = dpnp.empty(shape, dtype=dpnp.float64) |
| 674 | + def test_invalid_shape(self, shape, dtype): |
| 675 | + dp_array = dpnp.arange(10, dtype=dtype) |
| 676 | + dp_out = dpnp.empty(shape, dtype=dtype) |
672 | 677 |
|
673 |
| - with pytest.raises(ValueError): |
| 678 | + with pytest.raises(TypeError): |
674 | 679 | dpnp.floor(dp_array, out=dp_out)
|
675 | 680 |
|
676 | 681 |
|
677 | 682 | class TestTrunc:
|
678 |
| - def test_trunc(self): |
| 683 | + @pytest.mark.parametrize("dtype", get_float_dtypes()) |
| 684 | + def test_trunc(self, dtype): |
679 | 685 | array_data = numpy.arange(10)
|
680 |
| - out = numpy.empty(10, dtype=numpy.float64) |
| 686 | + out = numpy.empty(10, dtype=dtype) |
681 | 687 |
|
682 | 688 | # DPNP
|
683 |
| - dp_array = dpnp.array(array_data, dtype=dpnp.float64) |
684 |
| - dp_out = dpnp.array(out, dtype=dpnp.float64) |
| 689 | + dp_array = dpnp.array(array_data, dtype=dtype) |
| 690 | + dp_out = dpnp.array(out, dtype=dtype) |
685 | 691 | result = dpnp.trunc(dp_array, out=dp_out)
|
686 | 692 |
|
687 | 693 | # original
|
688 |
| - np_array = numpy.array(array_data, dtype=numpy.float64) |
| 694 | + np_array = numpy.array(array_data, dtype=dtype) |
689 | 695 | expected = numpy.trunc(np_array, out=out)
|
690 | 696 |
|
691 | 697 | assert_array_equal(expected, result)
|
692 | 698 |
|
693 | 699 | @pytest.mark.parametrize(
|
694 |
| - "dtype", |
695 |
| - [numpy.float32, numpy.int64, numpy.int32], |
696 |
| - ids=["numpy.float32", "numpy.int64", "numpy.int32"], |
| 700 | + "dtype", get_all_dtypes(no_bool=True, no_complex=True, no_none=True) |
697 | 701 | )
|
698 | 702 | def test_invalid_dtype(self, dtype):
|
699 |
| - dp_array = dpnp.arange(10, dtype=dpnp.float64) |
| 703 | + dpnp_dtype = dpnp.float64 if has_support_aspect64() else dpnp.float32 |
| 704 | + pytest.skip("similar data types") if dpnp_dtype == dtype else None |
| 705 | + dp_array = dpnp.arange(10, dtype=dpnp_dtype) |
700 | 706 | dp_out = dpnp.empty(10, dtype=dtype)
|
701 | 707 |
|
702 |
| - with pytest.raises(ValueError): |
| 708 | + with pytest.raises(TypeError): |
703 | 709 | dpnp.trunc(dp_array, out=dp_out)
|
704 | 710 |
|
| 711 | + @pytest.mark.parametrize("dtype", get_float_dtypes()) |
705 | 712 | @pytest.mark.parametrize(
|
706 | 713 | "shape", [(0,), (15,), (2, 2)], ids=["(0,)", "(15, )", "(2,2)"]
|
707 | 714 | )
|
708 |
| - def test_invalid_shape(self, shape): |
709 |
| - dp_array = dpnp.arange(10, dtype=dpnp.float64) |
710 |
| - dp_out = dpnp.empty(shape, dtype=dpnp.float64) |
| 715 | + def test_invalid_shape(self, shape, dtype): |
| 716 | + dp_array = dpnp.arange(10, dtype=dtype) |
| 717 | + dp_out = dpnp.empty(shape, dtype=dtype) |
711 | 718 |
|
712 |
| - with pytest.raises(ValueError): |
| 719 | + with pytest.raises(TypeError): |
713 | 720 | dpnp.trunc(dp_array, out=dp_out)
|
714 | 721 |
|
715 | 722 |
|
|
0 commit comments