(self, function, args, kwargs, numpy_ref)
| 606 | @pytest.mark.parametrize('function, args, kwargs', _array_tests) |
| 607 | @pytest.mark.parametrize('numpy_ref', [True, False]) |
| 608 | def test_array_like(self, function, args, kwargs, numpy_ref): |
| 609 | self.add_method('array', self.MyArray) |
| 610 | self.add_method(function, self.MyArray) |
| 611 | np_func = getattr(np, function) |
| 612 | my_func = getattr(self.MyArray, function) |
| 613 | |
| 614 | if numpy_ref is True: |
| 615 | ref = np.array(1) |
| 616 | else: |
| 617 | ref = self.MyArray.array() |
| 618 | |
| 619 | like_args = tuple(a() if callable(a) else a for a in args) |
| 620 | array_like = np_func(*like_args, **kwargs, like=ref) |
| 621 | |
| 622 | if numpy_ref is True: |
| 623 | assert type(array_like) is np.ndarray |
| 624 | |
| 625 | np_args = tuple(a() if callable(a) else a for a in args) |
| 626 | np_arr = np_func(*np_args, **kwargs) |
| 627 | |
| 628 | # Special-case np.empty to ensure values match |
| 629 | if function == "empty": |
| 630 | np_arr.fill(1) |
| 631 | array_like.fill(1) |
| 632 | |
| 633 | assert_equal(array_like, np_arr) |
| 634 | else: |
| 635 | assert type(array_like) is self.MyArray |
| 636 | assert array_like.function is my_func |
| 637 | |
| 638 | @pytest.mark.parametrize('function, args, kwargs', _array_tests) |
| 639 | @pytest.mark.parametrize('ref', [1, [1], "MyNoArrayFunctionArray"]) |
nothing calls this directly
no test coverage detected