| 1 |
import py |
| 2 |
import sys |
| 3 |
|
| 4 |
from pypy.module.micronumpy.test.test_base import BaseNumpyAppTest |
| 5 |
|
| 6 |
|
| 7 |
class AppTestDeprecations(BaseNumpyAppTest): |
| 8 |
spaceconfig = dict(usemodules=["micronumpy", "struct", "binascii"]) |
| 9 |
|
| 10 |
def test_getitem(self): |
| 11 |
import numpy as np |
| 12 |
import warnings, sys |
| 13 |
warnings.simplefilter('error', np.VisibleDeprecationWarning) |
| 14 |
try: |
| 15 |
arr = np.ones((5, 4, 3)) |
| 16 |
index = np.array([True]) |
| 17 |
raises(np.VisibleDeprecationWarning, arr.__getitem__, index) |
| 18 |
|
| 19 |
index = np.array([False] * 6) |
| 20 |
raises(np.VisibleDeprecationWarning, arr.__getitem__, index) |
| 21 |
|
| 22 |
index = np.zeros((4, 4), dtype=bool) |
| 23 |
if '__pypy__' in sys.builtin_module_names: |
| 24 |
|
| 25 |
|
| 26 |
raises(IndexError, arr.__getitem__, index) |
| 27 |
raises(IndexError, arr.__getitem__, (slice(None), index)) |
| 28 |
else: |
| 29 |
raises(np.VisibleDeprecationWarning, arr.__getitem__, index) |
| 30 |
raises(np.VisibleDeprecationWarning, arr.__getitem__, (slice(None), index)) |
| 31 |
finally: |
| 32 |
warnings.simplefilter('default', np.VisibleDeprecationWarning) |
| 33 |
|