class documentation

class TestNewBufferProtocol: (source)

View In Hierarchy

Test PEP3118 buffers

Method test_ctypes_integer_via_memoryview Undocumented
Method test_ctypes_struct_via_memoryview Undocumented
Method test_error_if_stored_buffer_info_is_corrupted If a user extends a NumPy array before 1.20 and then runs it on NumPy 1.20+. A C-subclassed array might in theory modify the new buffer-info field. This checks that an error is raised if this happens (for buffer export), an error is written on delete...
Method test_error_message_unsupported Undocumented
Method test_error_pointer_type Undocumented
Method test_error_too_many_dims Undocumented
Method test_export_and_pickle_user_dtype Undocumented
Method test_export_discontiguous Undocumented
Method test_export_endian Undocumented
Method test_export_flags Undocumented
Method test_export_record Undocumented
Method test_export_simple_1d Undocumented
Method test_export_simple_nd Undocumented
Method test_export_subarray Undocumented
Method test_invalid_buffer_format Undocumented
Method test_max_dims Undocumented
Method test_no_suboffsets Undocumented
Method test_out_of_order_fields Undocumented
Method test_padded_struct_array Undocumented
Method test_padding Undocumented
Method test_reference_leak Undocumented
Method test_relaxed_strides Undocumented
Method test_relaxed_strides_buffer_info_leak Test that alternating export of C- and F-order buffers from an array which is both C- and F-order when relaxed strides is active works. This test defines array in the signature to ensure leaking more references every time the test is run (catching the leak with pytest-leaks).
Method test_roundtrip Undocumented
Method test_roundtrip_half Undocumented
Method test_roundtrip_scalar Undocumented
Method test_roundtrip_single_types Undocumented
Method _check_roundtrip Undocumented
def test_ctypes_integer_via_memoryview(self): (source)

Undocumented

def test_ctypes_struct_via_memoryview(self): (source)

Undocumented

@pytest.mark.parametrize('obj', [np.ones(3), np.ones(1, dtype='i,i')[]])
def test_error_if_stored_buffer_info_is_corrupted(self, obj): (source)

If a user extends a NumPy array before 1.20 and then runs it on NumPy 1.20+. A C-subclassed array might in theory modify the new buffer-info field. This checks that an error is raised if this happens (for buffer export), an error is written on delete. This is a sanity check to help users transition to safe code, it may be deleted at any point.

def test_error_message_unsupported(self): (source)

Undocumented

def test_error_pointer_type(self): (source)

Undocumented

@pytest.mark.slow
def test_error_too_many_dims(self): (source)

Undocumented

@pytest.mark.parametrize(['obj', 'error'], [pytest.param(np.array([1, 2], dtype=rational), ValueError, id='array'), pytest.param(rational(1, 2), TypeError, id='scalar')])
def test_export_and_pickle_user_dtype(self, obj, error): (source)

Undocumented

def test_export_discontiguous(self): (source)

Undocumented

def test_export_endian(self): (source)

Undocumented

def test_export_flags(self): (source)

Undocumented

def test_export_record(self): (source)

Undocumented

def test_export_simple_1d(self): (source)

Undocumented

def test_export_simple_nd(self): (source)

Undocumented

def test_export_subarray(self): (source)

Undocumented

def test_invalid_buffer_format(self): (source)

Undocumented

def test_max_dims(self): (source)

Undocumented

def test_no_suboffsets(self): (source)

Undocumented

def test_out_of_order_fields(self): (source)

Undocumented

def test_padded_struct_array(self): (source)

Undocumented

def test_padding(self): (source)

Undocumented

def test_reference_leak(self): (source)

Undocumented

@pytest.mark.valgrind_error(reason='leaks buffer info cache temporarily.')
def test_relaxed_strides(self, c=np.ones((1, 10, 10), dtype='i8')): (source)

Undocumented

@pytest.mark.valgrind_error(reason='leaks buffer info cache temporarily.')
@pytest.mark.skipif(not np.ones((10, 1), order='C').flags.f_contiguous, reason='Test is unnecessary (but fails) without relaxed strides.')
def test_relaxed_strides_buffer_info_leak(self, arr=np.ones((1, 10))): (source)

Test that alternating export of C- and F-order buffers from an array which is both C- and F-order when relaxed strides is active works. This test defines array in the signature to ensure leaking more references every time the test is run (catching the leak with pytest-leaks).

def test_roundtrip(self): (source)

Undocumented

def test_roundtrip_half(self): (source)

Undocumented

def test_roundtrip_scalar(self): (source)

Undocumented

def test_roundtrip_single_types(self): (source)

Undocumented

def _check_roundtrip(self, obj): (source)

Undocumented