OXIESEC PANEL
- Current Dir:
/
/
usr
/
local
/
lib
/
python3.6
/
dist-packages
/
numpy
/
core
/
tests
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
10/28/2024 05:59:26 AM
rwxr-xr-x
📄
__init__.py
0 bytes
10/28/2024 05:59:24 AM
rw-r--r--
📁
__pycache__
-
10/28/2024 05:59:26 AM
rwxr-xr-x
📄
_locales.py
2.14 KB
10/28/2024 05:59:24 AM
rw-r--r--
📁
data
-
10/28/2024 05:59:26 AM
rwxr-xr-x
📄
test__exceptions.py
1.96 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_abc.py
2.27 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_api.py
20.32 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_arrayprint.py
33.68 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_conversion_utils.py
4.86 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_cpu_features.py
6.63 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_datetime.py
105.66 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_defchararray.py
23.81 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_deprecations.py
23.62 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_dtype.py
48.14 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_einsum.py
44.14 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_errstate.py
2.02 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_extint128.py
5.51 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_function_base.py
12.84 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_getlimits.py
4.2 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_half.py
22.56 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_indexerrors.py
5.01 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_indexing.py
48.11 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_item_selection.py
3.5 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_longdouble.py
12.74 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_machar.py
1.04 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_mem_overlap.py
28.18 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_memmap.py
7.29 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_multiarray.py
312.3 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_nditer.py
109.67 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_numeric.py
121.21 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_numerictypes.py
20.36 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_overrides.py
14.09 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_print.py
6.58 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_protocols.py
1.14 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_records.py
19.23 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_regression.py
86.76 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_scalar_ctors.py
2.52 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_scalar_methods.py
3.97 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_scalarbuffer.py
3.97 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_scalarinherit.py
2.08 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_scalarmath.py
27.9 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_scalarprint.py
14.8 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_shape_base.py
24.1 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_ufunc.py
82.01 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_umath.py
118.6 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_umath_accuracy.py
2.97 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_umath_complex.py
22.6 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_unicode.py
12.26 KB
10/28/2024 05:59:24 AM
rw-r--r--
Editing: test_item_selection.py
Close
import sys import numpy as np from numpy.testing import ( assert_, assert_raises, assert_array_equal, HAS_REFCOUNT ) class TestTake: def test_simple(self): a = [[1, 2], [3, 4]] a_str = [[b'1', b'2'], [b'3', b'4']] modes = ['raise', 'wrap', 'clip'] indices = [-1, 4] index_arrays = [np.empty(0, dtype=np.intp), np.empty(tuple(), dtype=np.intp), np.empty((1, 1), dtype=np.intp)] real_indices = {'raise': {-1: 1, 4: IndexError}, 'wrap': {-1: 1, 4: 0}, 'clip': {-1: 0, 4: 1}} # Currently all types but object, use the same function generation. # So it should not be necessary to test all. However test also a non # refcounted struct on top of object, which has a size that hits the # default (non-specialized) path. types = int, object, np.dtype([('', 'i2', 3)]) for t in types: # ta works, even if the array may be odd if buffer interface is used ta = np.array(a if np.issubdtype(t, np.number) else a_str, dtype=t) tresult = list(ta.T.copy()) for index_array in index_arrays: if index_array.size != 0: tresult[0].shape = (2,) + index_array.shape tresult[1].shape = (2,) + index_array.shape for mode in modes: for index in indices: real_index = real_indices[mode][index] if real_index is IndexError and index_array.size != 0: index_array.put(0, index) assert_raises(IndexError, ta.take, index_array, mode=mode, axis=1) elif index_array.size != 0: index_array.put(0, index) res = ta.take(index_array, mode=mode, axis=1) assert_array_equal(res, tresult[real_index]) else: res = ta.take(index_array, mode=mode, axis=1) assert_(res.shape == (2,) + index_array.shape) def test_refcounting(self): objects = [object() for i in range(10)] for mode in ('raise', 'clip', 'wrap'): a = np.array(objects) b = np.array([2, 2, 4, 5, 3, 5]) a.take(b, out=a[:6], mode=mode) del a if HAS_REFCOUNT: assert_(all(sys.getrefcount(o) == 3 for o in objects)) # not contiguous, example: a = np.array(objects * 2)[::2] a.take(b, out=a[:6], mode=mode) del a if HAS_REFCOUNT: assert_(all(sys.getrefcount(o) == 3 for o in objects)) def test_unicode_mode(self): d = np.arange(10) k = b'\xc3\xa4'.decode("UTF8") assert_raises(ValueError, d.take, 5, mode=k) def test_empty_partition(self): # In reference to github issue #6530 a_original = np.array([0, 2, 4, 6, 8, 10]) a = a_original.copy() # An empty partition should be a successful no-op a.partition(np.array([], dtype=np.int16)) assert_array_equal(a, a_original) def test_empty_argpartition(self): # In reference to github issue #6530 a = np.array([0, 2, 4, 6, 8, 10]) a = a.argpartition(np.array([], dtype=np.int16)) b = np.array([0, 1, 2, 3, 4, 5]) assert_array_equal(a, b)