Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -r 09532c746387 pypy/module/test_lib_pypy/numpypy/core/test_numeric.py
- --- /dev/null Thu Jan 01 00:00:00 1970 +0000
- +++ b/pypy/module/test_lib_pypy/numpypy/core/test_numeric.py Tue Jan 24 17:27:06 2012 +0200
- @@ -0,0 +1,41 @@
- +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