Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from pypy.module.micronumpy.test.test_base import BaseNumpyAppTest
- class AppTestNumeric(BaseNumpyAppTest):
- def test_zeros_like(self):
- import numpypy as np
- for a in [
- np.array(1), np.array([1, 2, 3]), np.array([[2.0, 4.0],[3,6]]), np.ones((3, 4, 5)), np.int16(1),
- np.float32(1), np.zeros((3, 4, 5, 6)), np.array([1, 2], 'int16'), np.array([1, 2], 'float32')
- ]:
- b = np.zeros_like(a)
- assert b.shape == a.shape and a.dtype == b.dtype
- for a in [1, 1.0]:
- b = np.zeros_like(a)
- assert b.shape == () and b.size == 1
- def test_ones_like(self):
- import numpypy as np
- for a in [
- np.array(1), np.array([1, 2, 3]), np.array([[2.0, 4.0],[3,6]]), np.ones((3, 4, 5)), np.int16(1),
- np.float32(1), np.zeros((3, 4, 5, 6)), np.array([1, 2], 'int16'), np.array([1, 2], 'float32')
- ]:
- b = np.ones_like(a)
- assert b.shape == a.shape and a.dtype == b.dtype
- for a in [1, 1.0]:
- b = np.ones_like(a)
- assert b.shape == () and b.size == 1
- def test_empty_like(self):
- import numpypy as np
- for a in [
- np.array(1), np.array([1, 2, 3]), np.array([[2.0, 4.0],[3,6]]), np.ones((3, 4, 5)), np.int16(1),
- np.float32(1), np.zeros((3, 4, 5, 6)), np.array([1, 2], 'int16'), np.array([1, 2], 'float32')
- ]:
- b = np.empty_like(a)
- assert b.shape == a.shape and a.dtype == b.dtype
- for a in [1, 1.0]:
- b = np.empty_like(a)
- assert b.shape == () and b.size == 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement