class documentation

class TestMultiIndexingAutomated: (source)

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 setup_method 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
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.
def setup_method(self): (source)

Undocumented

def test_1d(self): (source)

Undocumented

def test_boolean(self): (source)

Undocumented

def test_multidim(self): (source)

Undocumented

Undocumented

Undocumented

complex_indices = (source)

Undocumented

fill_indices = (source)

Undocumented

simple_indices = (source)

Undocumented

def _check_multi_index(self, arr, index): (source)

Check a multi index item getting and simple setting.

Parameters
arr:ndarrayArray to be indexed, must be a reshaped arange.
index:tuple of indexing objectsIndex being tested.
def _check_single_index(self, arr, index): (source)

Check a single index item getting and simple setting.

Parameters
arr:ndarrayArray to be indexed, must be an arange.
index:indexing objectIndex 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): (source)

Compare mimicked result to indexing result.

def _get_multi_index(self, arr, indices): (source)

Mimic multi dimensional indexing.

Notes

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

Parameters
arr:ndarrayArray 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).