(self, typecode, ufunc)
| 1998 | "typecode", np.typecodes['AllInteger'] + np.typecodes['Float']) |
| 1999 | @pytest.mark.parametrize("ufunc", indexed_ufuncs) |
| 2000 | def test_ufunc_at_inner_loops(self, typecode, ufunc): |
| 2001 | if ufunc is np.divide and typecode in np.typecodes['AllInteger']: |
| 2002 | # Avoid divide-by-zero and inf for integer divide |
| 2003 | a = np.ones(100, dtype=typecode) |
| 2004 | indx = np.random.randint(100, size=30, dtype=np.intp) |
| 2005 | vals = np.arange(1, 31, dtype=typecode) |
| 2006 | else: |
| 2007 | a = np.ones(1000, dtype=typecode) |
| 2008 | indx = np.random.randint(1000, size=3000, dtype=np.intp) |
| 2009 | vals = np.arange(3000, dtype=typecode) |
| 2010 | atag = a.copy() |
| 2011 | # Do the calculation twice and compare the answers |
| 2012 | with warnings.catch_warnings(record=True) as w_at: |
| 2013 | warnings.simplefilter('always') |
| 2014 | ufunc.at(a, indx, vals) |
| 2015 | with warnings.catch_warnings(record=True) as w_loop: |
| 2016 | warnings.simplefilter('always') |
| 2017 | for i, v in zip(indx, vals): |
| 2018 | # Make sure all the work happens inside the ufunc |
| 2019 | # in order to duplicate error/warning handling |
| 2020 | ufunc(atag[i], v, out=atag[i:i+1], casting="unsafe") |
| 2021 | assert_equal(atag, a) |
| 2022 | # If w_loop warned, make sure w_at warned as well |
| 2023 | if len(w_loop) > 0: |
| 2024 | # |
| 2025 | assert len(w_at) > 0 |
| 2026 | assert w_at[0].category == w_loop[0].category |
| 2027 | assert str(w_at[0].message)[:10] == str(w_loop[0].message)[:10] |
| 2028 | |
| 2029 | @pytest.mark.parametrize("typecode", np.typecodes['Complex']) |
| 2030 | @pytest.mark.parametrize("ufunc", [np.add, np.subtract, np.multiply]) |
nothing calls this directly
no test coverage detected