test_indexing

Module Contents

cdll
class TestIndexing

Bases:TestCase

test_none_index(self)
test_empty_tuple_index(self)
test_same_kind_index_casting(self)
test_empty_fancy_index(self)
test_ellipsis_index(self)
test_single_int_index(self)
test_single_bool_index(self)
test_boolean_indexing_onedim(self)
test_boolean_assignment_value_mismatch(self)
test_boolean_indexing_twodim(self)
test_reverse_strides_and_subspace_bufferinit(self)
test_reversed_strides_result_allocation(self)
test_uncontiguous_subspace_assignment(self)
test_too_many_fancy_indices_special_case(self)
test_scalar_array_bool(self)
test_everything_returns_views(self)
test_broaderrors_indexing(self)
test_trivial_fancy_out_of_bounds(self)
test_nonbaseclass_values(self)
test_subclass_writeable(self)
test_memory_order(self)
test_scalar_return_type(self)
test_small_regressions(self)
test_unaligned(self)
test_tuple_subclass(self)
test_broken_sequence_not_nd_index(self)
class TestFieldIndexing

Bases:TestCase

test_scalar_return_type(self)
class TestBroadcastedAssignments

Bases:TestCase

assign(self, a, ind, val)
test_prepending_ones(self)
test_prepend_not_one(self)
test_simple_broadcasting_errors(self)
test_index_is_larger(self)
test_broadcast_subspace(self)
class TestSubclasses

Bases:TestCase

test_basic(self)
test_matrix_fancy(self)
test_finalize_gets_full_info(self)
class TestFancyIndexingEquivalence

Bases:TestCase

test_object_assign(self)
test_cast_equivalence(self)
class TestMultiIndexingAutomated

Bases:TestCase

These test 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.
setUp(self)
_get_multi_index(self, arr, indices)

Mimic multi dimensional indexing.

arr : ndarray
Array to be indexed.

indices : tuple of index objects

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[indicies]) should be True (with some exceptions for scalars and possibly 0-d arrays).

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

_check_multi_index(self, arr, index)

Check a multi index item getting and simple setting.

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

Check a single index item getting and simple setting.

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).
_compare_index_result(self, arr, index, mimic_get, no_copy)

Compare mimicked result to indexing result.

test_boolean(self)
test_multidim(self)
test_1d(self)
class TestCApiAccess

Bases:TestCase

test_getitem(self)
test_setitem(self)