(self)
| 1833 | uf.accumulate(np.zeros((0, 0)), axis=0) |
| 1834 | |
| 1835 | def test_safe_casting(self): |
| 1836 | # In old versions of numpy, in-place operations used the 'unsafe' |
| 1837 | # casting rules. In versions >= 1.10, 'same_kind' is the |
| 1838 | # default and an exception is raised instead of a warning. |
| 1839 | # when 'same_kind' is not satisfied. |
| 1840 | a = np.array([1, 2, 3], dtype=int) |
| 1841 | # Non-in-place addition is fine |
| 1842 | assert_array_equal(assert_no_warnings(np.add, a, 1.1), |
| 1843 | [2.1, 3.1, 4.1]) |
| 1844 | assert_raises(TypeError, np.add, a, 1.1, out=a) |
| 1845 | |
| 1846 | def add_inplace(a, b): |
| 1847 | a += b |
| 1848 | |
| 1849 | assert_raises(TypeError, add_inplace, a, 1.1) |
| 1850 | # Make sure that explicitly overriding the exception is allowed: |
| 1851 | assert_no_warnings(np.add, a, 1.1, out=a, casting="unsafe") |
| 1852 | assert_array_equal(a, [2, 3, 4]) |
| 1853 | |
| 1854 | def test_ufunc_custom_out(self): |
| 1855 | # Test ufunc with built in input types and custom output type |
nothing calls this directly
no test coverage detected