MCPcopy Index your code
hub / github.com/RustPython/RustPython / _ca

Function _ca

Lib/test/test_buffer.py:287–299  ·  view source on GitHub ↗

Convert flat item list to the nested list representation of a multidimensional C array with shape 's'.

(items, s)

Source from the content-addressed store, hash-verified

285 return strides
286
287def _ca(items, s):
288 """Convert flat item list to the nested list representation of a
289 multidimensional C array with shape 's'."""
290 if atomp(items):
291 return items
292 if len(s) == 0:
293 return items[0]
294 lst = [0] * s[0]
295 stride = len(items) // s[0] if s[0] else 0
296 for i in range(s[0]):
297 start = i*stride
298 lst[i] = _ca(items[start:start+stride], s[1:])
299 return lst
300
301def _fa(items, s):
302 """Convert flat item list to the nested list representation of a

Callers 1

carrayFunction · 0.85

Calls 2

atompFunction · 0.85
lenFunction · 0.85

Tested by

no test coverage detected