diff options
author | Allan Haldane <allan.haldane@gmail.com> | 2015-10-25 23:41:11 -0400 |
---|---|---|
committer | Allan Haldane <allan.haldane@gmail.com> | 2015-10-26 21:17:59 -0400 |
commit | 086d42d8b315cacf04ccaf4a805dc2fc7c137fee (patch) | |
tree | 9a66fd73677cb8db8016e42d096860bfc00e8b2a | |
parent | bf28b4432183126c21f0fa80852c335e9c1ed7c1 (diff) | |
download | numpy-086d42d8b315cacf04ccaf4a805dc2fc7c137fee.tar.gz |
TST: Remove tests of view safety checks (see next commit)
Remove unit tests for the view safety chekcs, which are to be reverted
in the next commit.
-rw-r--r-- | numpy/core/tests/test_multiarray.py | 83 | ||||
-rw-r--r-- | numpy/lib/tests/test_recfunctions.py | 10 |
2 files changed, 0 insertions, 93 deletions
diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py index 85b0e5519..116348667 100644 --- a/numpy/core/tests/test_multiarray.py +++ b/numpy/core/tests/test_multiarray.py @@ -5829,89 +5829,6 @@ class TestHashing(TestCase): x = np.array([]) self.assertFalse(isinstance(x, collections.Hashable)) -from numpy.core._internal import _view_is_safe - -class TestObjViewSafetyFuncs(TestCase): - def test_view_safety(self): - psize = np.dtype('p').itemsize - - # creates dtype but with extra character code - for missing 'p' fields - def mtype(s): - n, offset, fields = 0, 0, [] - for c in s.split(','): # subarrays won't work - if c != '-': - fields.append(('f{0}'.format(n), c, offset)) - n += 1 - offset += np.dtype(c).itemsize if c != '-' else psize - - names, formats, offsets = zip(*fields) - return np.dtype({'names': names, 'formats': formats, - 'offsets': offsets, 'itemsize': offset}) - - # test nonequal itemsizes with objects: - # these should succeed: - _view_is_safe(np.dtype('O,p,O,p'), np.dtype('O,p,O,p,O,p')) - _view_is_safe(np.dtype('O,O'), np.dtype('O,O,O')) - # these should fail: - assert_raises(TypeError, _view_is_safe, np.dtype('O,O,p'), np.dtype('O,O')) - assert_raises(TypeError, _view_is_safe, np.dtype('O,O,p'), np.dtype('O,p')) - assert_raises(TypeError, _view_is_safe, np.dtype('O,O,p'), np.dtype('p,O')) - - # test nonequal itemsizes with missing fields: - # these should succeed: - _view_is_safe(mtype('-,p,-,p'), mtype('-,p,-,p,-,p')) - _view_is_safe(np.dtype('p,p'), np.dtype('p,p,p')) - # these should fail: - assert_raises(TypeError, _view_is_safe, mtype('p,p,-'), mtype('p,p')) - assert_raises(TypeError, _view_is_safe, mtype('p,p,-'), mtype('p,-')) - assert_raises(TypeError, _view_is_safe, mtype('p,p,-'), mtype('-,p')) - - # scans through positions at which we can view a type - def scanView(d1, otype): - goodpos = [] - for shift in range(d1.itemsize - np.dtype(otype).itemsize+1): - d2 = np.dtype({'names': ['f0'], 'formats': [otype], - 'offsets': [shift], 'itemsize': d1.itemsize}) - try: - _view_is_safe(d1, d2) - except TypeError: - pass - else: - goodpos.append(shift) - return goodpos - - # test partial overlap with object field - assert_equal(scanView(np.dtype('p,O,p,p,O,O'), 'p'), - [0] + list(range(2*psize, 3*psize+1))) - assert_equal(scanView(np.dtype('p,O,p,p,O,O'), 'O'), - [psize, 4*psize, 5*psize]) - - # test partial overlap with missing field - assert_equal(scanView(mtype('p,-,p,p,-,-'), 'p'), - [0] + list(range(2*psize, 3*psize+1))) - - # test nested structures with objects: - nestedO = np.dtype([('f0', 'p'), ('f1', 'p,O,p')]) - assert_equal(scanView(nestedO, 'p'), list(range(psize+1)) + [3*psize]) - assert_equal(scanView(nestedO, 'O'), [2*psize]) - - # test nested structures with missing fields: - nestedM = np.dtype([('f0', 'p'), ('f1', mtype('p,-,p'))]) - assert_equal(scanView(nestedM, 'p'), list(range(psize+1)) + [3*psize]) - - # test subarrays with objects - subarrayO = np.dtype('p,(2,3)O,p') - assert_equal(scanView(subarrayO, 'p'), [0, 7*psize]) - assert_equal(scanView(subarrayO, 'O'), - list(range(psize, 6*psize+1, psize))) - - #test dtype with overlapping fields - overlapped = np.dtype({'names': ['f0', 'f1', 'f2', 'f3'], - 'formats': ['p', 'p', 'p', 'p'], - 'offsets': [0, 1, 3*psize-1, 3*psize], - 'itemsize': 4*psize}) - assert_equal(scanView(overlapped, 'p'), [0, 1, 3*psize-1, 3*psize]) - class TestArrayPriority(TestCase): # This will go away when __array_priority__ is settled, meanwhile diff --git a/numpy/lib/tests/test_recfunctions.py b/numpy/lib/tests/test_recfunctions.py index 09cc29dc1..699a04716 100644 --- a/numpy/lib/tests/test_recfunctions.py +++ b/numpy/lib/tests/test_recfunctions.py @@ -720,15 +720,5 @@ class TestAppendFieldsObj(TestCase): dtype=[('A', object), ('B', float), ('C', int)]) assert_equal(test, control) - def test_append_with_objects(self): - "Test append_fields when the appended data contains objects" - obj = self.data['obj'] - x = np.array([(10, 1.), (20, 2.)], dtype=[('A', int), ('B', float)]) - y = np.array([obj, obj], dtype=object) - test = append_fields(x, 'C', data=y, dtypes=object, usemask=False) - control = np.array([(10, 1.0, obj), (20, 2.0, obj)], - dtype=[('A', int), ('B', float), ('C', object)]) - assert_equal(test, control) - if __name__ == '__main__': run_module_suite() |