(self, function, args, kwargs, numpy_ref)
| 649 | @pytest.mark.parametrize('function, args, kwargs', _array_tests) |
| 650 | @pytest.mark.parametrize('numpy_ref', [True, False]) |
| 651 | def test_array_like(self, function, args, kwargs, numpy_ref): |
| 652 | MyArray = self._create_MyArray() |
| 653 | self.add_method('array', MyArray) |
| 654 | self.add_method(function, MyArray) |
| 655 | np_func = getattr(np, function) |
| 656 | my_func = getattr(MyArray, function) |
| 657 | |
| 658 | if numpy_ref is True: |
| 659 | ref = np.array(1) |
| 660 | else: |
| 661 | ref = MyArray.array() |
| 662 | |
| 663 | like_args = tuple(a() if callable(a) else a for a in args) |
| 664 | array_like = np_func(*like_args, **kwargs, like=ref) |
| 665 | |
| 666 | if numpy_ref is True: |
| 667 | assert type(array_like) is np.ndarray |
| 668 | |
| 669 | np_args = tuple(a() if callable(a) else a for a in args) |
| 670 | np_arr = np_func(*np_args, **kwargs) |
| 671 | |
| 672 | # Special-case np.empty to ensure values match |
| 673 | if function == "empty": |
| 674 | np_arr.fill(1) |
| 675 | array_like.fill(1) |
| 676 | |
| 677 | assert_equal(array_like, np_arr) |
| 678 | else: |
| 679 | assert type(array_like) is MyArray |
| 680 | assert array_like.function is my_func |
| 681 | |
| 682 | @pytest.mark.parametrize('function, args, kwargs', _array_tests) |
| 683 | @pytest.mark.parametrize('ref', [1, [1], "MyNoArrayFunctionArray"]) |
nothing calls this directly
no test coverage detected