(self)
| 2010 | uf.accumulate(np.zeros((0, 0)), axis=0) |
| 2011 | |
| 2012 | def test_safe_casting(self): |
| 2013 | # In old versions of numpy, in-place operations used the 'unsafe' |
| 2014 | # casting rules. In versions >= 1.10, 'same_kind' is the |
| 2015 | # default and an exception is raised instead of a warning. |
| 2016 | # when 'same_kind' is not satisfied. |
| 2017 | a = np.array([1, 2, 3], dtype=int) |
| 2018 | # Non-in-place addition is fine |
| 2019 | assert_array_equal(assert_no_warnings(np.add, a, 1.1), |
| 2020 | [2.1, 3.1, 4.1]) |
| 2021 | assert_raises(TypeError, np.add, a, 1.1, out=a) |
| 2022 | |
| 2023 | def add_inplace(a, b): |
| 2024 | a += b |
| 2025 | |
| 2026 | assert_raises(TypeError, add_inplace, a, 1.1) |
| 2027 | # Make sure that explicitly overriding the exception is allowed: |
| 2028 | assert_no_warnings(np.add, a, 1.1, out=a, casting="unsafe") |
| 2029 | assert_array_equal(a, [2, 3, 4]) |
| 2030 | |
| 2031 | def test_ufunc_custom_out(self): |
| 2032 | # Test ufunc with built in input types and custom output type |
nothing calls this directly
no test coverage detected