def test_broadcast_with_leading(self): a = np.arange(3, dtype='>i4').reshape([3, 1]) result = BroadcastArray._broadcast_numpy_array(a, {1: 4}, (1,)) expected = np.array([[[0, 0, 0, 0], [1, 1, 1, 1], [2, 2, 2, 2]]]) self.assertEqual(result.strides, (0, 4, 0)) assert_array_equal(result, expected)
def test_simple_broadcast(self): a = np.arange(3, dtype='>i4').reshape([3, 1]) result = BroadcastArray._broadcast_numpy_array(a, {1: 4}) expected = np.array([[0, 0, 0, 0], [1, 1, 1, 1], [2, 2, 2, 2]]) assert_array_equal(result, expected) self.assertEqual(result.strides, (4, 0))