MCPcopy Index your code
hub / github.com/python/cpython / test_ndarray_2d

Method test_ndarray_2d

Lib/test/test_picklebuffer.py:76–95  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

74 self.assertIsNone(wpb())
75
76 def test_ndarray_2d(self):
77 # C-contiguous
78 ndarray = import_helper.import_module("_testbuffer").ndarray
79 arr = ndarray(list(range(12)), shape=(4, 3), format='<i')
80 self.assertTrue(arr.c_contiguous)
81 self.assertFalse(arr.f_contiguous)
82 pb = PickleBuffer(arr)
83 self.check_memoryview(pb, arr)
84 # Non-contiguous
85 arr = arr[::2]
86 self.assertFalse(arr.c_contiguous)
87 self.assertFalse(arr.f_contiguous)
88 pb = PickleBuffer(arr)
89 self.check_memoryview(pb, arr)
90 # F-contiguous
91 arr = ndarray(list(range(12)), shape=(3, 4), strides=(4, 12), format='<i')
92 self.assertTrue(arr.f_contiguous)
93 self.assertFalse(arr.c_contiguous)
94 pb = PickleBuffer(arr)
95 self.check_memoryview(pb, arr)
96
97 # Tests for PickleBuffer.raw()
98

Callers

nothing calls this directly

Calls 5

check_memoryviewMethod · 0.95
listClass · 0.85
assertTrueMethod · 0.80
assertFalseMethod · 0.80
import_moduleMethod · 0.45

Tested by

no test coverage detected