Advertisement
Dmitrey15

Untitled

Jan 24th, 2012
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.09 KB | None | 0 0
  1. diff -r 09532c746387 pypy/module/test_lib_pypy/numpypy/core/test_numeric.py
  2. --- /dev/null   Thu Jan 01 00:00:00 1970 +0000
  3. +++ b/pypy/module/test_lib_pypy/numpypy/core/test_numeric.py    Tue Jan 24 17:27:06 2012 +0200
  4. @@ -0,0 +1,41 @@
  5. +from pypy.module.micronumpy.test.test_base import BaseNumpyAppTest
  6. +
  7. +class AppTestNumeric(BaseNumpyAppTest):
  8. +    def test_zeros_like(self):
  9. +        import numpypy as np
  10. +        for a in [
  11. +                  np.array(1), np.array([1, 2, 3]), np.array([[2.0, 4.0],[3,6]]), np.ones((3, 4, 5)), np.int16(1),
  12. +                  np.float32(1), np.zeros((3, 4, 5, 6)), np.array([1, 2], 'int16'), np.array([1, 2], 'float32')
  13. +                  ]:
  14. +                    b = np.zeros_like(a)
  15. +                    assert b.shape == a.shape and a.dtype == b.dtype
  16. +                    
  17. +        for a in [1, 1.0]:
  18. +            b = np.zeros_like(a)
  19. +            assert b.shape == ()  and b.size == 1
  20. +    
  21. +    def test_ones_like(self):
  22. +        import numpypy as np
  23. +        for a in [
  24. +                  np.array(1), np.array([1, 2, 3]), np.array([[2.0, 4.0],[3,6]]), np.ones((3, 4, 5)), np.int16(1),
  25. +                  np.float32(1), np.zeros((3, 4, 5, 6)), np.array([1, 2], 'int16'), np.array([1, 2], 'float32')
  26. +                  ]:
  27. +                    b = np.ones_like(a)
  28. +                    assert b.shape == a.shape and a.dtype == b.dtype
  29. +                    
  30. +        for a in [1, 1.0]:
  31. +            b = np.ones_like(a)
  32. +            assert b.shape == ()  and b.size == 1
  33. +    
  34. +    def test_empty_like(self):
  35. +        import numpypy as np
  36. +        for a in [
  37. +                  np.array(1), np.array([1, 2, 3]), np.array([[2.0, 4.0],[3,6]]), np.ones((3, 4, 5)), np.int16(1),
  38. +                  np.float32(1), np.zeros((3, 4, 5, 6)), np.array([1, 2], 'int16'), np.array([1, 2], 'float32')
  39. +                  ]:
  40. +                    b = np.empty_like(a)
  41. +                    assert b.shape == a.shape and a.dtype == b.dtype
  42. +                    
  43. +        for a in [1, 1.0]:
  44. +            b = np.empty_like(a)
  45. +            assert b.shape == ()  and b.size == 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement