(self)
| 8742 | "type %s and %s failed" % (dt1, dt2)) |
| 8743 | |
| 8744 | def test_to_bool_scalar(self): |
| 8745 | assert_equal(bool(np.array([False])), False) |
| 8746 | assert_equal(bool(np.array([True])), True) |
| 8747 | assert_equal(bool(np.array([[42]])), True) |
| 8748 | assert_raises(ValueError, bool, np.array([1, 2])) |
| 8749 | |
| 8750 | class NotConvertible: |
| 8751 | def __bool__(self): |
| 8752 | raise NotImplementedError |
| 8753 | |
| 8754 | assert_raises(NotImplementedError, bool, np.array(NotConvertible())) |
| 8755 | assert_raises(NotImplementedError, bool, np.array([NotConvertible()])) |
| 8756 | if IS_PYSTON: |
| 8757 | pytest.skip("Pyston disables recursion checking") |
| 8758 | |
| 8759 | self_containing = np.array([None]) |
| 8760 | self_containing[0] = self_containing |
| 8761 | |
| 8762 | Error = RecursionError |
| 8763 | |
| 8764 | assert_raises(Error, bool, self_containing) # previously stack overflow |
| 8765 | self_containing[0] = None # resolve circular reference |
| 8766 | |
| 8767 | def test_to_int_scalar(self): |
| 8768 | # gh-9972 means that these aren't always the same |
nothing calls this directly
no test coverage detected