class documentation

class TestNewBufferProtocol:

View In Hierarchy

Test PEP3118 buffers
Method ​_check​_roundtrip Undocumented
Method test​_ctypes​_integer​_via​_memoryview Undocumented
Method test​_ctypes​_struct​_via​_memoryview Undocumented
Method test​_error​_if​_stored​_buffer​_info​_is​_corrupted No summary
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​_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 No summary
Method test​_roundtrip Undocumented
Method test​_roundtrip​_half Undocumented
Method test​_roundtrip​_scalar Undocumented
Method test​_roundtrip​_single​_types Undocumented
def _check_roundtrip(self, obj):

Undocumented

def test_ctypes_integer_via_memoryview(self):

Undocumented

def test_ctypes_struct_via_memoryview(self):

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):
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):

Undocumented

def test_error_pointer_type(self):

Undocumented

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

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):

Undocumented

def test_export_discontiguous(self):

Undocumented

def test_export_endian(self):

Undocumented

def test_export_flags(self):

Undocumented

def test_export_record(self):

Undocumented

def test_export_simple_1d(self):

Undocumented

def test_export_simple_nd(self):

Undocumented

def test_export_subarray(self):

Undocumented

def test_invalid_buffer_format(self):

Undocumented

def test_max_dims(self):

Undocumented

def test_out_of_order_fields(self):

Undocumented

def test_padded_struct_array(self):

Undocumented

def test_padding(self):

Undocumented

def test_reference_leak(self):

Undocumented

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

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))):
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):

Undocumented

def test_roundtrip_half(self):

Undocumented

def test_roundtrip_scalar(self):

Undocumented

def test_roundtrip_single_types(self):

Undocumented