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

Function _ca

Lib/test/test_buffer.py:299–311  ·  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

297 return strides
298
299def _ca(items, s):
300 """Convert flat item list to the nested list representation of a
301 multidimensional C array with shape 's'."""
302 if atomp(items):
303 return items
304 if len(s) == 0:
305 return items[0]
306 lst = [0] * s[0]
307 stride = len(items) // s[0] if s[0] else 0
308 for i in range(s[0]):
309 start = i*stride
310 lst[i] = _ca(items[start:start+stride], s[1:])
311 return lst
312
313def _fa(items, s):
314 """Convert flat item list to the nested list representation of a

Callers 1

carrayFunction · 0.85

Calls 1

atompFunction · 0.85

Tested by

no test coverage detected