Convert flat item list to the nested list representation of a multidimensional C array with shape 's'.
(items, s)
| 285 | return strides |
| 286 | |
| 287 | def _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 | |
| 301 | def _fa(items, s): |
| 302 | """Convert flat item list to the nested list representation of a |