MCPcopy Create free account
hub / github.com/apache/arrow / get_contiguous_span

Function get_contiguous_span

python/pyarrow/util.py:161–194  ·  view source on GitHub ↗

Return a contiguous span of N-D array data. Parameters ---------- shape : tuple strides : tuple itemsize : int Specify array shape data Returns ------- start, end : int The span end points.

(shape, strides, itemsize)

Source from the content-addressed store, hash-verified

159
160
161def get_contiguous_span(shape, strides, itemsize):
162 """
163 Return a contiguous span of N-D array data.
164
165 Parameters
166 ----------
167 shape : tuple
168 strides : tuple
169 itemsize : int
170 Specify array shape data
171
172 Returns
173 -------
174 start, end : int
175 The span end points.
176 """
177 if not strides:
178 start = 0
179 end = itemsize * product(shape)
180 else:
181 start = 0
182 end = itemsize
183 for i, dim in enumerate(shape):
184 if dim == 0:
185 start = end = 0
186 break
187 stride = strides[i]
188 if stride > 0:
189 end += stride * (dim - 1)
190 elif stride < 0:
191 start += stride * (dim - 1)
192 if end - start != itemsize * product(shape):
193 raise ValueError('array data is non-contiguous')
194 return start, end
195
196
197def find_free_port():

Callers

nothing calls this directly

Calls 1

productFunction · 0.85

Tested by

no test coverage detected