def test_against_numpy(self):
""" Test iall against numpy.all """
stream = [np.zeros((8, 16, 2)) for _ in range(11)]
stream[3][3,0,1] = 1 # so that np.all(axis = None) evaluates to False
stack = np.stack(stream, axis = -1)
with self.subTest('axis = None'):
from_numpy = np.all(stack, axis = None)
from_stream = last(iall(stream, axis = None))
self.assertEqual(from_numpy, from_stream)
for axis in range(stack.ndim):
with self.subTest('axis = {}'.format(axis)):
from_numpy = np.all(stack, axis = axis)
from_stream = last(iall(stream, axis = axis))
self.assertTrue(np.allclose(from_numpy, from_stream))
评论列表
文章目录