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

Method test_raw_ndarray

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

Source from the content-addressed store, hash-verified

108 self.check_raw(obj, obj)
109
110 def test_raw_ndarray(self):
111 # 1-D, contiguous
112 ndarray = import_helper.import_module("_testbuffer").ndarray
113 arr = ndarray(list(range(3)), shape=(3,), format='<h')
114 equiv = b"\x00\x00\x01\x00\x02\x00"
115 self.check_raw(arr, equiv)
116 # 2-D, C-contiguous
117 arr = ndarray(list(range(6)), shape=(2, 3), format='<h')
118 equiv = b"\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00"
119 self.check_raw(arr, equiv)
120 # 2-D, F-contiguous
121 arr = ndarray(list(range(6)), shape=(2, 3), strides=(2, 4),
122 format='<h')
123 # Note this is different from arr.tobytes()
124 equiv = b"\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00"
125 self.check_raw(arr, equiv)
126 # 0-D
127 arr = ndarray(456, shape=(), format='<i')
128 equiv = b'\xc8\x01\x00\x00'
129 self.check_raw(arr, equiv)
130
131 def check_raw_non_contiguous(self, obj):
132 pb = PickleBuffer(obj)

Callers

nothing calls this directly

Calls 3

check_rawMethod · 0.95
listClass · 0.85
import_moduleMethod · 0.45

Tested by

no test coverage detected