MCPcopy Create free account
hub / github.com/numpy/numpy / test_strided_loop_alignments

Method test_strided_loop_alignments

numpy/core/tests/test_multiarray.py:9829–9860  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

9827 self.check(shape, np.dtype(dtype), order, align)
9828
9829 def test_strided_loop_alignments(self):
9830 # particularly test that complex64 and float128 use right alignment
9831 # code-paths, since these are particularly problematic. It is useful to
9832 # turn on USE_DEBUG for this test, so lowlevel-loop asserts are run.
9833 for align in [1, 2, 4, 8, 12, 16, None]:
9834 xf64 = _aligned_zeros(3, np.float64)
9835
9836 xc64 = _aligned_zeros(3, np.complex64, align=align)
9837 xf128 = _aligned_zeros(3, np.longdouble, align=align)
9838
9839 # test casting, both to and from misaligned
9840 with suppress_warnings() as sup:
9841 sup.filter(np.ComplexWarning, "Casting complex values")
9842 xc64.astype('f8')
9843 xf64.astype(np.complex64)
9844 test = xc64 + xf64
9845
9846 xf128.astype('f8')
9847 xf64.astype(np.longdouble)
9848 test = xf128 + xf64
9849
9850 test = xf128 + xc64
9851
9852 # test copy, both to and from misaligned
9853 # contig copy
9854 xf64[:] = xf64.copy()
9855 xc64[:] = xc64.copy()
9856 xf128[:] = xf128.copy()
9857 # strided copy
9858 xf64[::2] = xf64[::2].copy()
9859 xc64[::2] = xc64[::2].copy()
9860 xf128[::2] = xf128[::2].copy()
9861
9862def test_getfield():
9863 a = np.arange(32, dtype='uint16')

Callers

nothing calls this directly

Calls 5

suppress_warningsClass · 0.90
_aligned_zerosFunction · 0.85
filterMethod · 0.80
astypeMethod · 0.80
copyMethod · 0.45

Tested by

no test coverage detected