class documentation

class TestMultiIndexingAutomated:

View In Hierarchy

These tests use code to mimic the C-Code indexing for selection.

NOTE:

  • This still lacks tests for complex item setting.
  • If you change behavior of indexing, you might want to modify these tests to try more combinations.
  • Behavior was written to match numpy version 1.8. (though a first version matched 1.7.)
  • Only tuple indices are supported by the mimicking code. (and tested as of writing this)
  • Error types should match most of the time as long as there is only one error. For multiple errors, what gets raised will usually not be the same one. They are not tested.

Update 2016-11-30: It is probably not worth maintaining this test indefinitely and it can be dropped if maintenance becomes a burden.

Method ​_check​_multi​_index Check a multi index item getting and simple setting.
Method ​_check​_single​_index Check a single index item getting and simple setting.
Method ​_compare​_index​_result Compare mimicked result to indexing result.
Method ​_get​_multi​_index Mimic multi dimensional indexing.
Method setup Undocumented
Method test​_1d Undocumented
Method test​_boolean Undocumented
Method test​_multidim Undocumented
Instance Variable a Undocumented
Instance Variable b Undocumented
Instance Variable complex​_indices Undocumented
Instance Variable fill​_indices Undocumented
Instance Variable simple​_indices Undocumented
def _check_multi_index(self, arr, index):

Check a multi index item getting and simple setting.

Parameters

arr : ndarray
Array to be indexed, must be a reshaped arange.
index : tuple of indexing objects
Index being tested.
def _check_single_index(self, arr, index):

Check a single index item getting and simple setting.

Parameters

arr : ndarray
Array to be indexed, must be an arange.
index : indexing object
Index being tested. Must be a single index and not a tuple of indexing objects (see also _check_multi_index).
def _compare_index_result(self, arr, index, mimic_get, no_copy):
Compare mimicked result to indexing result.
def _get_multi_index(self, arr, indices):

Mimic multi dimensional indexing.

Parameters

arr : ndarray
Array to be indexed.

indices : tuple of index objects

Returns

out : ndarray
An array equivalent to the indexing operation (but always a copy). arr[indices] should be identical.
no_copy : bool
Whether the indexing operation requires a copy. If this is True, np.may_share_memory(arr, arr[indices]) should be True (with some exceptions for scalars and possibly 0-d arrays).

Notes

While the function may mostly match the errors of normal indexing this is generally not the case.

def setup(self):

Undocumented

def test_1d(self):

Undocumented

def test_boolean(self):

Undocumented

def test_multidim(self):

Undocumented

a =

Undocumented

b =

Undocumented

complex_indices =

Undocumented

fill_indices =

Undocumented

simple_indices =

Undocumented