Reikriam

src/cpu-kernels/operations.cpp

May 29th, 2020
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 108.21 KB | None | 0 0
  1. awkward_listarray_num
  2. ----------------------------------------------------
  3.  
  4. for T in int:
  5. for C in int:
  6.  
  7. def awkward_listarray_num(
  8. tonum: List[T],
  9. fromstarts: List[C],
  10. startsoffset: int,
  11. fromstops: List[C],
  12. stopsoffset: int,
  13. length: int,
  14. ):
  15. for i in range(length):
  16. start = fromstarts[startsoffset + i]
  17. stop = fromstops[stopsoffset + i]
  18. tonum[i] = int(stop - start)
  19. return
  20.  
  21.  
  22. awkward_listarray32_num_64
  23. ----------------------------------------------------
  24.  
  25. def awkward_listarray32_num_64(
  26. tonum: List[int],
  27. fromstarts: List[int],
  28. startsoffset: int,
  29. fromstops: List[int],
  30. stopsoffset: int,
  31. length: int,
  32. ):
  33. return awkward_listarray_num(
  34. tonum, fromstarts, startsoffset, fromstops, stopsoffset, length
  35. )
  36.  
  37.  
  38. awkward_listarrayU32_num_64
  39. ----------------------------------------------------
  40.  
  41. def awkward_listarrayU32_num_64(
  42. tonum: List[int],
  43. fromstarts: List[int],
  44. startsoffset: int,
  45. fromstops: List[int],
  46. stopsoffset: int,
  47. length: int,
  48. ):
  49. return awkward_listarray_num(
  50. tonum, fromstarts, startsoffset, fromstops, stopsoffset, length
  51. )
  52.  
  53.  
  54. awkward_listarray64_num_64
  55. ----------------------------------------------------
  56.  
  57. def awkward_listarray64_num_64(
  58. tonum: List[int],
  59. fromstarts: List[int],
  60. startsoffset: int,
  61. fromstops: List[int],
  62. stopsoffset: int,
  63. length: int,
  64. ):
  65. return awkward_listarray_num(
  66. tonum, fromstarts, startsoffset, fromstops, stopsoffset, length
  67. )
  68.  
  69.  
  70. awkward_regulararray_num
  71. ----------------------------------------------------
  72.  
  73. for T in int:
  74.  
  75. def awkward_regulararray_num(tonum: List[T], size: int, length: int):
  76. for i in range(length):
  77. tonum[i] = size
  78. return
  79.  
  80.  
  81. awkward_regulararray_num_64
  82. ----------------------------------------------------
  83.  
  84. def awkward_regulararray_num_64(tonum: List[int], size: int, length: int):
  85. return awkward_regulararray_num(tonum, size, length)
  86.  
  87.  
  88. awkward_listoffsetarray_flatten_offsets
  89. ----------------------------------------------------
  90.  
  91. for T in int:
  92. for C in int:
  93.  
  94. def awkward_listoffsetarray_flatten_offsets(
  95. tooffsets: List[T],
  96. outeroffsets: List[C],
  97. outeroffsetsoffset: int,
  98. outeroffsetslen: int,
  99. inneroffsets: List[T],
  100. inneroffsetsoffset: int,
  101. inneroffsetslen: int,
  102. ):
  103. for i in range(outeroffsetslen):
  104. tooffsets[i] = inneroffsets[
  105. inneroffsetsoffset + outeroffsets[outeroffsetsoffset + i]
  106. ]
  107. return
  108.  
  109.  
  110. awkward_listoffsetarray32_flatten_offsets_64
  111. ----------------------------------------------------
  112.  
  113. def awkward_listoffsetarray32_flatten_offsets_64(
  114. tooffsets: List[int],
  115. outeroffsets: List[int],
  116. outeroffsetsoffset: int,
  117. outeroffsetslen: int,
  118. inneroffsets: List[int],
  119. inneroffsetsoffset: int,
  120. inneroffsetslen: int,
  121. ):
  122. return awkward_listoffsetarray_flatten_offsets(
  123. tooffsets,
  124. outeroffsets,
  125. outeroffsetsoffset,
  126. outeroffsetslen,
  127. inneroffsets,
  128. inneroffsetsoffset,
  129. inneroffsetslen,
  130. )
  131.  
  132.  
  133. awkward_listoffsetarrayU32_flatten_offsets_64
  134. ----------------------------------------------------
  135.  
  136. def awkward_listoffsetarrayU32_flatten_offsets_64(
  137. tooffsets: List[int],
  138. outeroffsets: List[int],
  139. outeroffsetsoffset: int,
  140. outeroffsetslen: int,
  141. inneroffsets: List[int],
  142. inneroffsetsoffset: int,
  143. inneroffsetslen: int,
  144. ):
  145. return awkward_listoffsetarray_flatten_offsets(
  146. tooffsets,
  147. outeroffsets,
  148. outeroffsetsoffset,
  149. outeroffsetslen,
  150. inneroffsets,
  151. inneroffsetsoffset,
  152. inneroffsetslen,
  153. )
  154.  
  155.  
  156. awkward_listoffsetarray64_flatten_offsets_64
  157. ----------------------------------------------------
  158.  
  159. def awkward_listoffsetarray64_flatten_offsets_64(
  160. tooffsets: List[int],
  161. outeroffsets: List[int],
  162. outeroffsetsoffset: int,
  163. outeroffsetslen: int,
  164. inneroffsets: List[int],
  165. inneroffsetsoffset: int,
  166. inneroffsetslen: int,
  167. ):
  168. return awkward_listoffsetarray_flatten_offsets(
  169. tooffsets,
  170. outeroffsets,
  171. outeroffsetsoffset,
  172. outeroffsetslen,
  173. inneroffsets,
  174. inneroffsetsoffset,
  175. inneroffsetslen,
  176. )
  177.  
  178.  
  179. awkward_indexedarray_flatten_none2empty
  180. ----------------------------------------------------
  181.  
  182. for T in int:
  183. for C in int:
  184.  
  185. def awkward_indexedarray_flatten_none2empty(
  186. outoffsets: List[T],
  187. outindex: List[C],
  188. outindexoffset: int,
  189. outindexlength: int,
  190. offsets: List[T],
  191. offsetsoffset: int,
  192. offsetslength: int,
  193. ):
  194. outoffsets[0] = offsets[offsetsoffset + 0]
  195. k = 1
  196. for i in range(outindexlength):
  197. idx = outindex[outindexoffset + i]
  198. if idx < 0:
  199. outoffsets[k] = outoffsets[k - 1]
  200. k = k + 1
  201. else:
  202. if ((offsetsoffset + idx) + 1) >= offsetslength:
  203. raise ValueError("flattening offset out of range")
  204. else:
  205. count = (
  206. offsets[(offsetsoffset + idx) + 1]
  207. - offsets[offsetsoffset + idx]
  208. )
  209. outoffsets[k] = outoffsets[k - 1] + count
  210. k = k + 1
  211. return
  212.  
  213.  
  214. awkward_indexedarray32_flatten_none2empty_64
  215. ----------------------------------------------------
  216.  
  217. def awkward_indexedarray32_flatten_none2empty_64(
  218. outoffsets: List[int],
  219. outindex: List[int],
  220. outindexoffset: int,
  221. outindexlength: int,
  222. offsets: List[int],
  223. offsetsoffset: int,
  224. offsetslength: int,
  225. ):
  226. return awkward_indexedarray_flatten_none2empty(
  227. outoffsets,
  228. outindex,
  229. outindexoffset,
  230. outindexlength,
  231. offsets,
  232. offsetsoffset,
  233. offsetslength,
  234. )
  235.  
  236.  
  237. awkward_indexedarrayU32_flatten_none2empty_64
  238. ----------------------------------------------------
  239.  
  240. def awkward_indexedarrayU32_flatten_none2empty_64(
  241. outoffsets: List[int],
  242. outindex: List[int],
  243. outindexoffset: int,
  244. outindexlength: int,
  245. offsets: List[int],
  246. offsetsoffset: int,
  247. offsetslength: int,
  248. ):
  249. return awkward_indexedarray_flatten_none2empty(
  250. outoffsets,
  251. outindex,
  252. outindexoffset,
  253. outindexlength,
  254. offsets,
  255. offsetsoffset,
  256. offsetslength,
  257. )
  258.  
  259.  
  260. awkward_indexedarray64_flatten_none2empty_64
  261. ----------------------------------------------------
  262.  
  263. def awkward_indexedarray64_flatten_none2empty_64(
  264. outoffsets: List[int],
  265. outindex: List[int],
  266. outindexoffset: int,
  267. outindexlength: int,
  268. offsets: List[int],
  269. offsetsoffset: int,
  270. offsetslength: int,
  271. ):
  272. return awkward_indexedarray_flatten_none2empty(
  273. outoffsets,
  274. outindex,
  275. outindexoffset,
  276. outindexlength,
  277. offsets,
  278. offsetsoffset,
  279. offsetslength,
  280. )
  281.  
  282.  
  283. awkward_unionarray_flatten_length
  284. ----------------------------------------------------
  285.  
  286. for FROMTAGS in int:
  287. for FROMINDEX in int:
  288. for T in int:
  289.  
  290. def awkward_unionarray_flatten_length(
  291. total_length: List[int],
  292. fromtags: List[FROMTAGS],
  293. fromtagsoffset: int,
  294. fromindex: List[FROMINDEX],
  295. fromindexoffset: int,
  296. length: int,
  297. offsetsraws: List[List[int]],
  298. offsetsoffsets: List[int],
  299. ):
  300. total_length = 0
  301. for i in range(length):
  302. tag = fromtags[fromtagsoffset + i]
  303. idx = fromindex[fromindexoffset + i]
  304. start = offsetsraws[tag][offsetsoffsets[tag] + idx]
  305. stop = offsetsraws[tag][(offsetsoffsets[tag] + idx) + 1]
  306. total_length = total_length + (stop - start)
  307. return
  308.  
  309.  
  310. awkward_unionarray32_flatten_length_64
  311. ----------------------------------------------------
  312.  
  313. def awkward_unionarray32_flatten_length_64(
  314. total_length: List[int],
  315. fromtags: List[int],
  316. fromtagsoffset: int,
  317. fromindex: List[int],
  318. fromindexoffset: int,
  319. length: int,
  320. offsetsraws: List[List[int]],
  321. offsetsoffsets: List[int],
  322. ):
  323. return awkward_unionarray_flatten_length(
  324. total_length,
  325. fromtags,
  326. fromtagsoffset,
  327. fromindex,
  328. fromindexoffset,
  329. length,
  330. offsetsraws,
  331. offsetsoffsets,
  332. )
  333.  
  334.  
  335. awkward_unionarrayU32_flatten_length_64
  336. ----------------------------------------------------
  337.  
  338. def awkward_unionarrayU32_flatten_length_64(
  339. total_length: List[int],
  340. fromtags: List[int],
  341. fromtagsoffset: int,
  342. fromindex: List[int],
  343. fromindexoffset: int,
  344. length: int,
  345. offsetsraws: List[List[int]],
  346. offsetsoffsets: List[int],
  347. ):
  348. return awkward_unionarray_flatten_length(
  349. total_length,
  350. fromtags,
  351. fromtagsoffset,
  352. fromindex,
  353. fromindexoffset,
  354. length,
  355. offsetsraws,
  356. offsetsoffsets,
  357. )
  358.  
  359.  
  360. awkward_unionarray64_flatten_length_64
  361. ----------------------------------------------------
  362.  
  363. def awkward_unionarray64_flatten_length_64(
  364. total_length: List[int],
  365. fromtags: List[int],
  366. fromtagsoffset: int,
  367. fromindex: List[int],
  368. fromindexoffset: int,
  369. length: int,
  370. offsetsraws: List[List[int]],
  371. offsetsoffsets: List[int],
  372. ):
  373. return awkward_unionarray_flatten_length(
  374. total_length,
  375. fromtags,
  376. fromtagsoffset,
  377. fromindex,
  378. fromindexoffset,
  379. length,
  380. offsetsraws,
  381. offsetsoffsets,
  382. )
  383.  
  384.  
  385. awkward_unionarray_flatten_combine
  386. ----------------------------------------------------
  387.  
  388. for FROMTAGS in int:
  389. for FROMINDEX in int:
  390. for TOTAGS in int:
  391. for TOINDEX in int:
  392. for T in int:
  393.  
  394. def awkward_unionarray_flatten_combine(
  395. totags: List[TOTAGS],
  396. toindex: List[TOINDEX],
  397. tooffsets: List[T],
  398. fromtags: List[FROMTAGS],
  399. fromtagsoffset: int,
  400. fromindex: List[FROMINDEX],
  401. fromindexoffset: int,
  402. length: int,
  403. offsetsraws: List[List[int]],
  404. offsetsoffsets: List[int],
  405. ):
  406. tooffsets[0] = 0
  407. k = 0
  408. for i in range(length):
  409. tag = fromtags[fromtagsoffset + i]
  410. idx = fromindex[fromindexoffset + i]
  411. start = offsetsraws[tag][offsetsoffsets[tag] + idx]
  412. stop = offsetsraws[tag][(offsetsoffsets[tag] + idx) + 1]
  413. tooffsets[i + 1] = tooffsets[i] + (stop - start)
  414. j = start
  415. while j < stop:
  416. totags[k] = tag
  417. toindex[k] = j
  418. k = k + 1
  419. j = j + 1
  420. return
  421.  
  422.  
  423. awkward_unionarray32_flatten_combine_64
  424. ----------------------------------------------------
  425.  
  426. def awkward_unionarray32_flatten_combine_64(
  427. totags: List[int],
  428. toindex: List[int],
  429. tooffsets: List[int],
  430. fromtags: List[int],
  431. fromtagsoffset: int,
  432. fromindex: List[int],
  433. fromindexoffset: int,
  434. length: int,
  435. offsetsraws: List[List[int]],
  436. offsetsoffsets: List[int],
  437. ):
  438. return awkward_unionarray_flatten_combine(
  439. totags,
  440. toindex,
  441. tooffsets,
  442. fromtags,
  443. fromtagsoffset,
  444. fromindex,
  445. fromindexoffset,
  446. length,
  447. offsetsraws,
  448. offsetsoffsets,
  449. )
  450.  
  451.  
  452. awkward_unionarrayU32_flatten_combine_64
  453. ----------------------------------------------------
  454.  
  455. def awkward_unionarrayU32_flatten_combine_64(
  456. totags: List[int],
  457. toindex: List[int],
  458. tooffsets: List[int],
  459. fromtags: List[int],
  460. fromtagsoffset: int,
  461. fromindex: List[int],
  462. fromindexoffset: int,
  463. length: int,
  464. offsetsraws: List[List[int]],
  465. offsetsoffsets: List[int],
  466. ):
  467. return awkward_unionarray_flatten_combine(
  468. totags,
  469. toindex,
  470. tooffsets,
  471. fromtags,
  472. fromtagsoffset,
  473. fromindex,
  474. fromindexoffset,
  475. length,
  476. offsetsraws,
  477. offsetsoffsets,
  478. )
  479.  
  480.  
  481. awkward_unionarray64_flatten_combine_64
  482. ----------------------------------------------------
  483.  
  484. def awkward_unionarray64_flatten_combine_64(
  485. totags: List[int],
  486. toindex: List[int],
  487. tooffsets: List[int],
  488. fromtags: List[int],
  489. fromtagsoffset: int,
  490. fromindex: List[int],
  491. fromindexoffset: int,
  492. length: int,
  493. offsetsraws: List[List[int]],
  494. offsetsoffsets: List[int],
  495. ):
  496. return awkward_unionarray_flatten_combine(
  497. totags,
  498. toindex,
  499. tooffsets,
  500. fromtags,
  501. fromtagsoffset,
  502. fromindex,
  503. fromindexoffset,
  504. length,
  505. offsetsraws,
  506. offsetsoffsets,
  507. )
  508.  
  509.  
  510. awkward_indexedarray_flatten_nextcarry
  511. ----------------------------------------------------
  512.  
  513. for C in int:
  514. for T in int:
  515.  
  516. def awkward_indexedarray_flatten_nextcarry(
  517. tocarry: List[T],
  518. fromindex: List[C],
  519. indexoffset: int,
  520. lenindex: int,
  521. lencontent: int,
  522. ):
  523. k = 0
  524. for i in range(lenindex):
  525. j = fromindex[indexoffset + i]
  526. if j >= lencontent:
  527. raise ValueError("index out of range")
  528. else:
  529. if j >= 0:
  530. tocarry[k] = j
  531. k = k + 1
  532. return
  533.  
  534.  
  535. awkward_indexedarray32_flatten_nextcarry_64
  536. ----------------------------------------------------
  537.  
  538. def awkward_indexedarray32_flatten_nextcarry_64(
  539. tocarry: List[int],
  540. fromindex: List[int],
  541. indexoffset: int,
  542. lenindex: int,
  543. lencontent: int,
  544. ):
  545. return awkward_indexedarray_flatten_nextcarry(
  546. tocarry, fromindex, indexoffset, lenindex, lencontent
  547. )
  548.  
  549.  
  550. awkward_indexedarrayU32_flatten_nextcarry_64
  551. ----------------------------------------------------
  552.  
  553. def awkward_indexedarrayU32_flatten_nextcarry_64(
  554. tocarry: List[int],
  555. fromindex: List[int],
  556. indexoffset: int,
  557. lenindex: int,
  558. lencontent: int,
  559. ):
  560. return awkward_indexedarray_flatten_nextcarry(
  561. tocarry, fromindex, indexoffset, lenindex, lencontent
  562. )
  563.  
  564.  
  565. awkward_indexedarray64_flatten_nextcarry_64
  566. ----------------------------------------------------
  567.  
  568. def awkward_indexedarray64_flatten_nextcarry_64(
  569. tocarry: List[int],
  570. fromindex: List[int],
  571. indexoffset: int,
  572. lenindex: int,
  573. lencontent: int,
  574. ):
  575. return awkward_indexedarray_flatten_nextcarry(
  576. tocarry, fromindex, indexoffset, lenindex, lencontent
  577. )
  578.  
  579.  
  580. awkward_indexedarray_overlay_mask
  581. ----------------------------------------------------
  582.  
  583. for C in int:
  584. for M in int:
  585. for TO in int:
  586.  
  587. def awkward_indexedarray_overlay_mask(
  588. toindex: List[TO],
  589. mask: List[M],
  590. maskoffset: int,
  591. fromindex: List[C],
  592. indexoffset: int,
  593. length: int,
  594. ):
  595. for i in range(length):
  596. m = mask[maskoffset + i]
  597. toindex[i] = -1 if m else fromindex[indexoffset + i]
  598. return
  599.  
  600.  
  601. awkward_indexedarray32_overlay_mask8_to64
  602. ----------------------------------------------------
  603.  
  604. def awkward_indexedarray32_overlay_mask8_to64(
  605. toindex: List[int],
  606. mask: List[int],
  607. maskoffset: int,
  608. fromindex: List[int],
  609. indexoffset: int,
  610. length: int,
  611. ):
  612. return awkward_indexedarray_overlay_mask(
  613. toindex, mask, maskoffset, fromindex, indexoffset, length
  614. )
  615.  
  616.  
  617. awkward_indexedarrayU32_overlay_mask8_to64
  618. ----------------------------------------------------
  619.  
  620. def awkward_indexedarrayU32_overlay_mask8_to64(
  621. toindex: List[int],
  622. mask: List[int],
  623. maskoffset: int,
  624. fromindex: List[int],
  625. indexoffset: int,
  626. length: int,
  627. ):
  628. return awkward_indexedarray_overlay_mask(
  629. toindex, mask, maskoffset, fromindex, indexoffset, length
  630. )
  631.  
  632.  
  633. awkward_indexedarray64_overlay_mask8_to64
  634. ----------------------------------------------------
  635.  
  636. def awkward_indexedarray64_overlay_mask8_to64(
  637. toindex: List[int],
  638. mask: List[int],
  639. maskoffset: int,
  640. fromindex: List[int],
  641. indexoffset: int,
  642. length: int,
  643. ):
  644. return awkward_indexedarray_overlay_mask(
  645. toindex, mask, maskoffset, fromindex, indexoffset, length
  646. )
  647.  
  648.  
  649. awkward_indexedarray_mask
  650. ----------------------------------------------------
  651.  
  652. for C in int:
  653. for M in int:
  654.  
  655. def awkward_indexedarray_mask(
  656. tomask: List[M], fromindex: List[C], indexoffset: int, length: int
  657. ):
  658. for i in range(length):
  659. tomask[i] = fromindex[indexoffset + i] < 0
  660. return
  661.  
  662.  
  663. awkward_indexedarray32_mask8
  664. ----------------------------------------------------
  665.  
  666. def awkward_indexedarray32_mask8(
  667. tomask: List[int], fromindex: List[int], indexoffset: int, length: int
  668. ):
  669. return awkward_indexedarray_mask(tomask, fromindex, indexoffset, length)
  670.  
  671.  
  672. awkward_indexedarrayU32_mask8
  673. ----------------------------------------------------
  674.  
  675. def awkward_indexedarrayU32_mask8(
  676. tomask: List[int], fromindex: List[int], indexoffset: int, length: int
  677. ):
  678. return awkward_indexedarray_mask(tomask, fromindex, indexoffset, length)
  679.  
  680.  
  681. awkward_indexedarray64_mask8
  682. ----------------------------------------------------
  683.  
  684. def awkward_indexedarray64_mask8(
  685. tomask: List[int], fromindex: List[int], indexoffset: int, length: int
  686. ):
  687. return awkward_indexedarray_mask(tomask, fromindex, indexoffset, length)
  688.  
  689.  
  690. awkward_bytemaskedarray_mask
  691. ----------------------------------------------------
  692.  
  693. def awkward_bytemaskedarray_mask(
  694. tomask: List[M], frommask: List[M], maskoffset: int, length: int, validwhen: bool
  695. ):
  696. for i in range(length):
  697. tomask[i] = (frommask[maskoffset + i] != 0) != validwhen
  698. return
  699.  
  700.  
  701. awkward_bytemaskedarray_mask8
  702. ----------------------------------------------------
  703.  
  704. def awkward_bytemaskedarray_mask8(
  705. tomask: List[int],
  706. frommask: List[int],
  707. maskoffset: int,
  708. length: int,
  709. validwhen: bool,
  710. ):
  711. return awkward_bytemaskedarray_mask(tomask, frommask, maskoffset, length, validwhen)
  712.  
  713.  
  714. awkward_zero_mask
  715. ----------------------------------------------------
  716.  
  717. def awkward_zero_mask(tomask: List[M], length: int):
  718. for i in range(length):
  719. tomask[i] = 0
  720. return
  721.  
  722.  
  723. awkward_zero_mask8
  724. ----------------------------------------------------
  725.  
  726. def awkward_zero_mask8(tomask: List[int], length: int):
  727. return awkward_zero_mask(tomask, length)
  728.  
  729.  
  730. awkward_indexedarray_simplify
  731. ----------------------------------------------------
  732.  
  733. for OUT in int:
  734. for IN in int:
  735. for TO in int:
  736.  
  737. def awkward_indexedarray_simplify(
  738. toindex: List[TO],
  739. outerindex: List[OUT],
  740. outeroffset: int,
  741. outerlength: int,
  742. innerindex: List[IN],
  743. inneroffset: int,
  744. innerlength: int,
  745. ):
  746. for i in range(outerlength):
  747. j = outerindex[outeroffset + i]
  748. if j < 0:
  749. toindex[i] = -1
  750. else:
  751. if j >= innerlength:
  752. raise ValueError("index out of range")
  753. else:
  754. toindex[i] = innerindex[inneroffset + j]
  755. return
  756.  
  757.  
  758. awkward_indexedarray32_simplify32_to64
  759. ----------------------------------------------------
  760.  
  761. def awkward_indexedarray32_simplify32_to64(
  762. toindex: List[int],
  763. outerindex: List[int],
  764. outeroffset: int,
  765. outerlength: int,
  766. innerindex: List[int],
  767. inneroffset: int,
  768. innerlength: int,
  769. ):
  770. return awkward_indexedarray_simplify(
  771. toindex,
  772. outerindex,
  773. outeroffset,
  774. outerlength,
  775. innerindex,
  776. inneroffset,
  777. innerlength,
  778. )
  779.  
  780.  
  781. awkward_indexedarray32_simplifyU32_to64
  782. ----------------------------------------------------
  783.  
  784. def awkward_indexedarray32_simplifyU32_to64(
  785. toindex: List[int],
  786. outerindex: List[int],
  787. outeroffset: int,
  788. outerlength: int,
  789. innerindex: List[int],
  790. inneroffset: int,
  791. innerlength: int,
  792. ):
  793. return awkward_indexedarray_simplify(
  794. toindex,
  795. outerindex,
  796. outeroffset,
  797. outerlength,
  798. innerindex,
  799. inneroffset,
  800. innerlength,
  801. )
  802.  
  803.  
  804. awkward_indexedarray32_simplify64_to64
  805. ----------------------------------------------------
  806.  
  807. def awkward_indexedarray32_simplify64_to64(
  808. toindex: List[int],
  809. outerindex: List[int],
  810. outeroffset: int,
  811. outerlength: int,
  812. innerindex: List[int],
  813. inneroffset: int,
  814. innerlength: int,
  815. ):
  816. return awkward_indexedarray_simplify(
  817. toindex,
  818. outerindex,
  819. outeroffset,
  820. outerlength,
  821. innerindex,
  822. inneroffset,
  823. innerlength,
  824. )
  825.  
  826.  
  827. awkward_indexedarrayU32_simplify32_to64
  828. ----------------------------------------------------
  829.  
  830. def awkward_indexedarrayU32_simplify32_to64(
  831. toindex: List[int],
  832. outerindex: List[int],
  833. outeroffset: int,
  834. outerlength: int,
  835. innerindex: List[int],
  836. inneroffset: int,
  837. innerlength: int,
  838. ):
  839. return awkward_indexedarray_simplify(
  840. toindex,
  841. outerindex,
  842. outeroffset,
  843. outerlength,
  844. innerindex,
  845. inneroffset,
  846. innerlength,
  847. )
  848.  
  849.  
  850. awkward_indexedarrayU32_simplifyU32_to64
  851. ----------------------------------------------------
  852.  
  853. def awkward_indexedarrayU32_simplifyU32_to64(
  854. toindex: List[int],
  855. outerindex: List[int],
  856. outeroffset: int,
  857. outerlength: int,
  858. innerindex: List[int],
  859. inneroffset: int,
  860. innerlength: int,
  861. ):
  862. return awkward_indexedarray_simplify(
  863. toindex,
  864. outerindex,
  865. outeroffset,
  866. outerlength,
  867. innerindex,
  868. inneroffset,
  869. innerlength,
  870. )
  871.  
  872.  
  873. awkward_indexedarrayU32_simplify64_to64
  874. ----------------------------------------------------
  875.  
  876. def awkward_indexedarrayU32_simplify64_to64(
  877. toindex: List[int],
  878. outerindex: List[int],
  879. outeroffset: int,
  880. outerlength: int,
  881. innerindex: List[int],
  882. inneroffset: int,
  883. innerlength: int,
  884. ):
  885. return awkward_indexedarray_simplify(
  886. toindex,
  887. outerindex,
  888. outeroffset,
  889. outerlength,
  890. innerindex,
  891. inneroffset,
  892. innerlength,
  893. )
  894.  
  895.  
  896. awkward_indexedarray64_simplify32_to64
  897. ----------------------------------------------------
  898.  
  899. def awkward_indexedarray64_simplify32_to64(
  900. toindex: List[int],
  901. outerindex: List[int],
  902. outeroffset: int,
  903. outerlength: int,
  904. innerindex: List[int],
  905. inneroffset: int,
  906. innerlength: int,
  907. ):
  908. return awkward_indexedarray_simplify(
  909. toindex,
  910. outerindex,
  911. outeroffset,
  912. outerlength,
  913. innerindex,
  914. inneroffset,
  915. innerlength,
  916. )
  917.  
  918.  
  919. awkward_indexedarray64_simplifyU32_to64
  920. ----------------------------------------------------
  921.  
  922. def awkward_indexedarray64_simplifyU32_to64(
  923. toindex: List[int],
  924. outerindex: List[int],
  925. outeroffset: int,
  926. outerlength: int,
  927. innerindex: List[int],
  928. inneroffset: int,
  929. innerlength: int,
  930. ):
  931. return awkward_indexedarray_simplify(
  932. toindex,
  933. outerindex,
  934. outeroffset,
  935. outerlength,
  936. innerindex,
  937. inneroffset,
  938. innerlength,
  939. )
  940.  
  941.  
  942. awkward_indexedarray64_simplify64_to64
  943. ----------------------------------------------------
  944.  
  945. def awkward_indexedarray64_simplify64_to64(
  946. toindex: List[int],
  947. outerindex: List[int],
  948. outeroffset: int,
  949. outerlength: int,
  950. innerindex: List[int],
  951. inneroffset: int,
  952. innerlength: int,
  953. ):
  954. return awkward_indexedarray_simplify(
  955. toindex,
  956. outerindex,
  957. outeroffset,
  958. outerlength,
  959. innerindex,
  960. inneroffset,
  961. innerlength,
  962. )
  963.  
  964.  
  965. awkward_regulararray_compact_offsets
  966. ----------------------------------------------------
  967.  
  968. for T in int:
  969.  
  970. def awkward_regulararray_compact_offsets(
  971. tooffsets: List[T], length: int, size: int
  972. ):
  973. tooffsets[0] = 0
  974. for i in range(length):
  975. tooffsets[i + 1] = (i + 1) * size
  976. return
  977.  
  978.  
  979. awkward_regulararray_compact_offsets64
  980. ----------------------------------------------------
  981.  
  982. def awkward_regulararray_compact_offsets64(
  983. tooffsets: List[int], length: int, size: int
  984. ):
  985. return awkward_regulararray_compact_offsets(tooffsets, length, size)
  986.  
  987.  
  988. awkward_listarray_compact_offsets
  989. ----------------------------------------------------
  990.  
  991. for C in int:
  992. for T in int:
  993.  
  994. def awkward_listarray_compact_offsets(
  995. tooffsets: List[T],
  996. fromstarts: List[C],
  997. fromstops: List[C],
  998. startsoffset: int,
  999. stopsoffset: int,
  1000. length: int,
  1001. ):
  1002. tooffsets[0] = 0
  1003. for i in range(length):
  1004. start = fromstarts[startsoffset + i]
  1005. stop = fromstops[stopsoffset + i]
  1006. if stop < start:
  1007. raise ValueError("stops[i] < starts[i]")
  1008. tooffsets[i + 1] = tooffsets[i] + (stop - start)
  1009. return
  1010.  
  1011.  
  1012. awkward_listarray32_compact_offsets64
  1013. ----------------------------------------------------
  1014.  
  1015. def awkward_listarray32_compact_offsets64(
  1016. tooffsets: List[int],
  1017. fromstarts: List[int],
  1018. fromstops: List[int],
  1019. startsoffset: int,
  1020. stopsoffset: int,
  1021. length: int,
  1022. ):
  1023. return awkward_listarray_compact_offsets(
  1024. tooffsets, fromstarts, fromstops, startsoffset, stopsoffset, length
  1025. )
  1026.  
  1027.  
  1028. awkward_listarrayU32_compact_offsets64
  1029. ----------------------------------------------------
  1030.  
  1031. def awkward_listarrayU32_compact_offsets64(
  1032. tooffsets: List[int],
  1033. fromstarts: List[int],
  1034. fromstops: List[int],
  1035. startsoffset: int,
  1036. stopsoffset: int,
  1037. length: int,
  1038. ):
  1039. return awkward_listarray_compact_offsets(
  1040. tooffsets, fromstarts, fromstops, startsoffset, stopsoffset, length
  1041. )
  1042.  
  1043.  
  1044. awkward_listarray64_compact_offsets64
  1045. ----------------------------------------------------
  1046.  
  1047. def awkward_listarray64_compact_offsets64(
  1048. tooffsets: List[int],
  1049. fromstarts: List[int],
  1050. fromstops: List[int],
  1051. startsoffset: int,
  1052. stopsoffset: int,
  1053. length: int,
  1054. ):
  1055. return awkward_listarray_compact_offsets(
  1056. tooffsets, fromstarts, fromstops, startsoffset, stopsoffset, length
  1057. )
  1058.  
  1059.  
  1060. awkward_listoffsetarray_compact_offsets
  1061. ----------------------------------------------------
  1062.  
  1063. for C in int:
  1064. for T in int:
  1065.  
  1066. def awkward_listoffsetarray_compact_offsets(
  1067. tooffsets: List[T], fromoffsets: List[C], offsetsoffset: int, length: int
  1068. ):
  1069. diff = int(fromoffsets[offsetsoffset + 0])
  1070. tooffsets[0] = 0
  1071. for i in range(length):
  1072. tooffsets[i + 1] = fromoffsets[(offsetsoffset + i) + 1] - diff
  1073. return
  1074.  
  1075.  
  1076. awkward_listoffsetarray32_compact_offsets64
  1077. ----------------------------------------------------
  1078.  
  1079. def awkward_listoffsetarray32_compact_offsets64(
  1080. tooffsets: List[int], fromoffsets: List[int], offsetsoffset: int, length: int
  1081. ):
  1082. return awkward_listoffsetarray_compact_offsets(
  1083. tooffsets, fromoffsets, offsetsoffset, length
  1084. )
  1085.  
  1086.  
  1087. awkward_listoffsetarrayU32_compact_offsets64
  1088. ----------------------------------------------------
  1089.  
  1090. def awkward_listoffsetarrayU32_compact_offsets64(
  1091. tooffsets: List[int], fromoffsets: List[int], offsetsoffset: int, length: int
  1092. ):
  1093. return awkward_listoffsetarray_compact_offsets(
  1094. tooffsets, fromoffsets, offsetsoffset, length
  1095. )
  1096.  
  1097.  
  1098. awkward_listoffsetarray64_compact_offsets64
  1099. ----------------------------------------------------
  1100.  
  1101. def awkward_listoffsetarray64_compact_offsets64(
  1102. tooffsets: List[int], fromoffsets: List[int], offsetsoffset: int, length: int
  1103. ):
  1104. return awkward_listoffsetarray_compact_offsets(
  1105. tooffsets, fromoffsets, offsetsoffset, length
  1106. )
  1107.  
  1108.  
  1109. awkward_listarray_broadcast_tooffsets
  1110. ----------------------------------------------------
  1111.  
  1112. for C in int:
  1113. for T in int:
  1114.  
  1115. def awkward_listarray_broadcast_tooffsets(
  1116. tocarry: List[T],
  1117. fromoffsets: List[T],
  1118. offsetsoffset: int,
  1119. offsetslength: int,
  1120. fromstarts: List[C],
  1121. startsoffset: int,
  1122. fromstops: List[C],
  1123. stopsoffset: int,
  1124. lencontent: int,
  1125. ):
  1126. k = 0
  1127. for i in range(offsetslength - 1):
  1128. start = int(fromstarts[startsoffset + i])
  1129. stop = int(fromstops[stopsoffset + i])
  1130. if (start != stop) and (stop > lencontent):
  1131. raise ValueError("stops[i] > len(content)")
  1132. count = int(
  1133. fromoffsets[(offsetsoffset + i) + 1]
  1134. - fromoffsets[offsetsoffset + i]
  1135. )
  1136. if count < 0:
  1137. raise ValueError(
  1138. "broadcast's offsets must be monotonically increasing"
  1139. )
  1140. if (stop - start) != count:
  1141. raise ValueError("cannot broadcast nested list")
  1142. j = start
  1143. while j < stop:
  1144. tocarry[k] = int(j)
  1145. k = k + 1
  1146. j = j + 1
  1147. return
  1148.  
  1149.  
  1150. awkward_listarray32_broadcast_tooffsets64
  1151. ----------------------------------------------------
  1152.  
  1153. def awkward_listarray32_broadcast_tooffsets64(
  1154. tocarry: List[int],
  1155. fromoffsets: List[int],
  1156. offsetsoffset: int,
  1157. offsetslength: int,
  1158. fromstarts: List[int],
  1159. startsoffset: int,
  1160. fromstops: List[int],
  1161. stopsoffset: int,
  1162. lencontent: int,
  1163. ):
  1164. return awkward_listarray_broadcast_tooffsets(
  1165. tocarry,
  1166. fromoffsets,
  1167. offsetsoffset,
  1168. offsetslength,
  1169. fromstarts,
  1170. startsoffset,
  1171. fromstops,
  1172. stopsoffset,
  1173. lencontent,
  1174. )
  1175.  
  1176.  
  1177. awkward_listarrayU32_broadcast_tooffsets64
  1178. ----------------------------------------------------
  1179.  
  1180. def awkward_listarrayU32_broadcast_tooffsets64(
  1181. tocarry: List[int],
  1182. fromoffsets: List[int],
  1183. offsetsoffset: int,
  1184. offsetslength: int,
  1185. fromstarts: List[int],
  1186. startsoffset: int,
  1187. fromstops: List[int],
  1188. stopsoffset: int,
  1189. lencontent: int,
  1190. ):
  1191. return awkward_listarray_broadcast_tooffsets(
  1192. tocarry,
  1193. fromoffsets,
  1194. offsetsoffset,
  1195. offsetslength,
  1196. fromstarts,
  1197. startsoffset,
  1198. fromstops,
  1199. stopsoffset,
  1200. lencontent,
  1201. )
  1202.  
  1203.  
  1204. awkward_listarray64_broadcast_tooffsets64
  1205. ----------------------------------------------------
  1206.  
  1207. def awkward_listarray64_broadcast_tooffsets64(
  1208. tocarry: List[int],
  1209. fromoffsets: List[int],
  1210. offsetsoffset: int,
  1211. offsetslength: int,
  1212. fromstarts: List[int],
  1213. startsoffset: int,
  1214. fromstops: List[int],
  1215. stopsoffset: int,
  1216. lencontent: int,
  1217. ):
  1218. return awkward_listarray_broadcast_tooffsets(
  1219. tocarry,
  1220. fromoffsets,
  1221. offsetsoffset,
  1222. offsetslength,
  1223. fromstarts,
  1224. startsoffset,
  1225. fromstops,
  1226. stopsoffset,
  1227. lencontent,
  1228. )
  1229.  
  1230.  
  1231. awkward_regulararray_broadcast_tooffsets
  1232. ----------------------------------------------------
  1233.  
  1234. for T in int:
  1235.  
  1236. def awkward_regulararray_broadcast_tooffsets(
  1237. fromoffsets: List[T], offsetsoffset: int, offsetslength: int, size: int
  1238. ):
  1239. for i in range(offsetslength - 1):
  1240. count = int(
  1241. fromoffsets[(offsetsoffset + i) + 1] - fromoffsets[offsetsoffset + i]
  1242. )
  1243. if count < 0:
  1244. raise ValueError("broadcast's offsets must be monotonically increasing")
  1245. if size != count:
  1246. raise ValueError("cannot broadcast nested list")
  1247. return
  1248.  
  1249.  
  1250. awkward_regulararray_broadcast_tooffsets64
  1251. ----------------------------------------------------
  1252.  
  1253. def awkward_regulararray_broadcast_tooffsets64(
  1254. fromoffsets: List[int], offsetsoffset: int, offsetslength: int, size: int
  1255. ):
  1256. return awkward_regulararray_broadcast_tooffsets(
  1257. fromoffsets, offsetsoffset, offsetslength, size
  1258. )
  1259.  
  1260.  
  1261. awkward_regulararray_broadcast_tooffsets_size1
  1262. ----------------------------------------------------
  1263.  
  1264. for T in int:
  1265.  
  1266. def awkward_regulararray_broadcast_tooffsets_size1(
  1267. tocarry: List[T], fromoffsets: List[T], offsetsoffset: int, offsetslength: int
  1268. ):
  1269. k = 0
  1270. for i in range(offsetslength - 1):
  1271. count = int(
  1272. fromoffsets[(offsetsoffset + i) + 1] - fromoffsets[offsetsoffset + i]
  1273. )
  1274. if count < 0:
  1275. raise ValueError("broadcast's offsets must be monotonically increasing")
  1276. for j in range(count):
  1277. tocarry[k] = int(i)
  1278. k = k + 1
  1279. return
  1280.  
  1281.  
  1282. awkward_regulararray_broadcast_tooffsets64_size1
  1283. ----------------------------------------------------
  1284.  
  1285. def awkward_regulararray_broadcast_tooffsets64_size1(
  1286. tocarry: List[int], fromoffsets: List[int], offsetsoffset: int, offsetslength: int
  1287. ):
  1288. return awkward_regulararray_broadcast_tooffsets_size1(
  1289. tocarry, fromoffsets, offsetsoffset, offsetslength
  1290. )
  1291.  
  1292.  
  1293. awkward_listoffsetarray_toRegularArray
  1294. ----------------------------------------------------
  1295.  
  1296. for C in int:
  1297.  
  1298. def awkward_listoffsetarray_toRegularArray(
  1299. size: List[int], fromoffsets: List[C], offsetsoffset: int, offsetslength: int
  1300. ):
  1301. size = -1
  1302. for i in range(offsetslength - 1):
  1303. count = int(
  1304. fromoffsets[(offsetsoffset + i) + 1] - fromoffsets[offsetsoffset + i]
  1305. )
  1306. if count < 0:
  1307. raise ValueError("offsets must be monotonically increasing")
  1308. if size == -1:
  1309. size = count
  1310. else:
  1311. if size != count:
  1312. raise ValueError(
  1313. "cannot convert to RegularArray because subarray lengths are not regular"
  1314. )
  1315. if size == -1:
  1316. size = 0
  1317. return
  1318.  
  1319.  
  1320. awkward_listoffsetarray32_toRegularArray
  1321. ----------------------------------------------------
  1322.  
  1323. def awkward_listoffsetarray32_toRegularArray(
  1324. size: List[int], fromoffsets: List[int], offsetsoffset: int, offsetslength: int
  1325. ):
  1326. return awkward_listoffsetarray_toRegularArray(
  1327. size, fromoffsets, offsetsoffset, offsetslength
  1328. )
  1329.  
  1330.  
  1331. awkward_listoffsetarrayU32_toRegularArray
  1332. ----------------------------------------------------
  1333.  
  1334. def awkward_listoffsetarrayU32_toRegularArray(
  1335. size: List[int], fromoffsets: List[int], offsetsoffset: int, offsetslength: int
  1336. ):
  1337. return awkward_listoffsetarray_toRegularArray(
  1338. size, fromoffsets, offsetsoffset, offsetslength
  1339. )
  1340.  
  1341.  
  1342. awkward_listoffsetarray64_toRegularArray
  1343. ----------------------------------------------------
  1344.  
  1345. def awkward_listoffsetarray64_toRegularArray(
  1346. size: List[int], fromoffsets: List[int], offsetsoffset: int, offsetslength: int
  1347. ):
  1348. return awkward_listoffsetarray_toRegularArray(
  1349. size, fromoffsets, offsetsoffset, offsetslength
  1350. )
  1351.  
  1352.  
  1353. awkward_numpyarray_fill
  1354. ----------------------------------------------------
  1355.  
  1356. for FROM in (float, int):
  1357. for TO in (float, int):
  1358.  
  1359. def awkward_numpyarray_fill(
  1360. toptr: List[TO],
  1361. tooffset: int,
  1362. fromptr: List[FROM],
  1363. fromoffset: int,
  1364. length: int,
  1365. ):
  1366. for i in range(length):
  1367. toptr[tooffset + i] = int(fromptr[fromoffset + i])
  1368. return
  1369.  
  1370.  
  1371. awkward_numpyarray_fill_frombool
  1372. ----------------------------------------------------
  1373.  
  1374. for TO in (float, int, bool):
  1375.  
  1376. def awkward_numpyarray_fill_frombool(
  1377. toptr: List[TO],
  1378. tooffset: int,
  1379. fromptr: List[bool],
  1380. fromoffset: int,
  1381. length: int,
  1382. ):
  1383. for i in range(length):
  1384. toptr[tooffset + i] = int(fromptr[fromoffset + i] != 0)
  1385. return
  1386.  
  1387.  
  1388. awkward_numpyarray_fill_todouble_fromdouble
  1389. ----------------------------------------------------
  1390.  
  1391. def awkward_numpyarray_fill_todouble_fromdouble(
  1392. toptr: List[double],
  1393. tooffset: int,
  1394. fromptr: List[double],
  1395. fromoffset: int,
  1396. length: int,
  1397. ):
  1398. return awkward_numpyarray_fill(toptr, tooffset, fromptr, fromoffset, length)
  1399.  
  1400.  
  1401. awkward_numpyarray_fill_todouble_fromfloat
  1402. ----------------------------------------------------
  1403.  
  1404. def awkward_numpyarray_fill_todouble_fromfloat(
  1405. toptr: List[double],
  1406. tooffset: int,
  1407. fromptr: List[float],
  1408. fromoffset: int,
  1409. length: int,
  1410. ):
  1411. return awkward_numpyarray_fill(toptr, tooffset, fromptr, fromoffset, length)
  1412.  
  1413.  
  1414. awkward_numpyarray_fill_todouble_from64
  1415. ----------------------------------------------------
  1416.  
  1417. def awkward_numpyarray_fill_todouble_from64(
  1418. toptr: List[double], tooffset: int, fromptr: List[int], fromoffset: int, length: int
  1419. ):
  1420. return awkward_numpyarray_fill(toptr, tooffset, fromptr, fromoffset, length)
  1421.  
  1422.  
  1423. awkward_numpyarray_fill_todouble_fromU64
  1424. ----------------------------------------------------
  1425.  
  1426. def awkward_numpyarray_fill_todouble_fromU64(
  1427. toptr: List[double], tooffset: int, fromptr: List[int], fromoffset: int, length: int
  1428. ):
  1429. return awkward_numpyarray_fill(toptr, tooffset, fromptr, fromoffset, length)
  1430.  
  1431.  
  1432. awkward_numpyarray_fill_todouble_from32
  1433. ----------------------------------------------------
  1434.  
  1435. def awkward_numpyarray_fill_todouble_from32(
  1436. toptr: List[double], tooffset: int, fromptr: List[int], fromoffset: int, length: int
  1437. ):
  1438. return awkward_numpyarray_fill(toptr, tooffset, fromptr, fromoffset, length)
  1439.  
  1440.  
  1441. awkward_numpyarray_fill_todouble_fromU32
  1442. ----------------------------------------------------
  1443.  
  1444. def awkward_numpyarray_fill_todouble_fromU32(
  1445. toptr: List[double], tooffset: int, fromptr: List[int], fromoffset: int, length: int
  1446. ):
  1447. return awkward_numpyarray_fill(toptr, tooffset, fromptr, fromoffset, length)
  1448.  
  1449.  
  1450. awkward_numpyarray_fill_todouble_from16
  1451. ----------------------------------------------------
  1452.  
  1453. def awkward_numpyarray_fill_todouble_from16(
  1454. toptr: List[double], tooffset: int, fromptr: List[int], fromoffset: int, length: int
  1455. ):
  1456. return awkward_numpyarray_fill(toptr, tooffset, fromptr, fromoffset, length)
  1457.  
  1458.  
  1459. awkward_numpyarray_fill_todouble_fromU16
  1460. ----------------------------------------------------
  1461.  
  1462. def awkward_numpyarray_fill_todouble_fromU16(
  1463. toptr: List[double], tooffset: int, fromptr: List[int], fromoffset: int, length: int
  1464. ):
  1465. return awkward_numpyarray_fill(toptr, tooffset, fromptr, fromoffset, length)
  1466.  
  1467.  
  1468. awkward_numpyarray_fill_todouble_from8
  1469. ----------------------------------------------------
  1470.  
  1471. def awkward_numpyarray_fill_todouble_from8(
  1472. toptr: List[double], tooffset: int, fromptr: List[int], fromoffset: int, length: int
  1473. ):
  1474. return awkward_numpyarray_fill(toptr, tooffset, fromptr, fromoffset, length)
  1475.  
  1476.  
  1477. awkward_numpyarray_fill_todouble_fromU8
  1478. ----------------------------------------------------
  1479.  
  1480. def awkward_numpyarray_fill_todouble_fromU8(
  1481. toptr: List[double], tooffset: int, fromptr: List[int], fromoffset: int, length: int
  1482. ):
  1483. return awkward_numpyarray_fill(toptr, tooffset, fromptr, fromoffset, length)
  1484.  
  1485.  
  1486. awkward_numpyarray_fill_todouble_frombool
  1487. ----------------------------------------------------
  1488.  
  1489. def awkward_numpyarray_fill_todouble_frombool(
  1490. toptr: List[double],
  1491. tooffset: int,
  1492. fromptr: List[bool],
  1493. fromoffset: int,
  1494. length: int,
  1495. ):
  1496. return awkward_numpyarray_fill_fromint(toptr, tooffset, fromptr, fromoffset, length)
  1497.  
  1498.  
  1499. awkward_numpyarray_fill_toU64_fromU64
  1500. ----------------------------------------------------
  1501.  
  1502. def awkward_numpyarray_fill_toU64_fromU64(
  1503. toptr: List[int], tooffset: int, fromptr: List[int], fromoffset: int, length: int
  1504. ):
  1505. return awkward_numpyarray_fill(toptr, tooffset, fromptr, fromoffset, length)
  1506.  
  1507.  
  1508. awkward_numpyarray_fill_to64_from64
  1509. ----------------------------------------------------
  1510.  
  1511. def awkward_numpyarray_fill_to64_from64(
  1512. toptr: List[int], tooffset: int, fromptr: List[int], fromoffset: int, length: int
  1513. ):
  1514. return awkward_numpyarray_fill(toptr, tooffset, fromptr, fromoffset, length)
  1515.  
  1516.  
  1517. awkward_numpyarray_fill_to64_fromU64
  1518. ----------------------------------------------------
  1519.  
  1520. def awkward_numpyarray_fill_to64_fromU64(
  1521. toptr: List[int], tooffset: int, fromptr: List[int], fromoffset: int, length: int
  1522. ):
  1523. for i in range(length):
  1524. if fromptr[fromoffset + i] > kMaxInt64:
  1525. raise ValueError("uint64 value too large for int64 output")
  1526. toptr[tooffset + i] = fromptr[fromoffset + i]
  1527. return
  1528.  
  1529.  
  1530. awkward_numpyarray_fill_to64_from32
  1531. ----------------------------------------------------
  1532.  
  1533. def awkward_numpyarray_fill_to64_from32(
  1534. toptr: List[int], tooffset: int, fromptr: List[int], fromoffset: int, length: int
  1535. ):
  1536. return awkward_numpyarray_fill(toptr, tooffset, fromptr, fromoffset, length)
  1537.  
  1538.  
  1539. awkward_numpyarray_fill_to64_fromU32
  1540. ----------------------------------------------------
  1541.  
  1542. def awkward_numpyarray_fill_to64_fromU32(
  1543. toptr: List[int], tooffset: int, fromptr: List[int], fromoffset: int, length: int
  1544. ):
  1545. return awkward_numpyarray_fill(toptr, tooffset, fromptr, fromoffset, length)
  1546.  
  1547.  
  1548. awkward_numpyarray_fill_to64_from16
  1549. ----------------------------------------------------
  1550.  
  1551. def awkward_numpyarray_fill_to64_from16(
  1552. toptr: List[int], tooffset: int, fromptr: List[int], fromoffset: int, length: int
  1553. ):
  1554. return awkward_numpyarray_fill(toptr, tooffset, fromptr, fromoffset, length)
  1555.  
  1556.  
  1557. awkward_numpyarray_fill_to64_fromU16
  1558. ----------------------------------------------------
  1559.  
  1560. def awkward_numpyarray_fill_to64_fromU16(
  1561. toptr: List[int], tooffset: int, fromptr: List[int], fromoffset: int, length: int
  1562. ):
  1563. return awkward_numpyarray_fill(toptr, tooffset, fromptr, fromoffset, length)
  1564.  
  1565.  
  1566. awkward_numpyarray_fill_to64_from8
  1567. ----------------------------------------------------
  1568.  
  1569. def awkward_numpyarray_fill_to64_from8(
  1570. toptr: List[int], tooffset: int, fromptr: List[int], fromoffset: int, length: int
  1571. ):
  1572. return awkward_numpyarray_fill(toptr, tooffset, fromptr, fromoffset, length)
  1573.  
  1574.  
  1575. awkward_numpyarray_fill_to64_fromU8
  1576. ----------------------------------------------------
  1577.  
  1578. def awkward_numpyarray_fill_to64_fromU8(
  1579. toptr: List[int], tooffset: int, fromptr: List[int], fromoffset: int, length: int
  1580. ):
  1581. return awkward_numpyarray_fill(toptr, tooffset, fromptr, fromoffset, length)
  1582.  
  1583.  
  1584. awkward_numpyarray_fill_to64_frombool
  1585. ----------------------------------------------------
  1586.  
  1587. def awkward_numpyarray_fill_to64_frombool(
  1588. toptr: List[int], tooffset: int, fromptr: List[bool], fromoffset: int, length: int
  1589. ):
  1590. return awkward_numpyarray_fill_fromint(toptr, tooffset, fromptr, fromoffset, length)
  1591.  
  1592.  
  1593. awkward_numpyarray_fill_tobool_frombool
  1594. ----------------------------------------------------
  1595.  
  1596. def awkward_numpyarray_fill_tobool_frombool(
  1597. toptr: List[bool], tooffset: int, fromptr: List[bool], fromoffset: int, length: int
  1598. ):
  1599. return awkward_numpyarray_fill_fromint(toptr, tooffset, fromptr, fromoffset, length)
  1600.  
  1601.  
  1602. awkward_numpyarray_fill_tobyte_frombyte
  1603. ----------------------------------------------------
  1604.  
  1605. def awkward_numpyarray_fill_tobyte_frombyte(
  1606. toptr: List[int], tooffset: int, fromptr: List[int], fromoffset: int, length: int
  1607. ):
  1608. return awkward_numpyarray_fill(toptr, tooffset, fromptr, fromoffset, length)
  1609.  
  1610.  
  1611. awkward_listarray_fill
  1612. ----------------------------------------------------
  1613.  
  1614. for FROM in int:
  1615. for TO in int:
  1616.  
  1617. def awkward_listarray_fill(
  1618. tostarts: List[TO],
  1619. tostartsoffset: int,
  1620. tostops: List[TO],
  1621. tostopsoffset: int,
  1622. fromstarts: List[FROM],
  1623. fromstartsoffset: int,
  1624. fromstops: List[FROM],
  1625. fromstopsoffset: int,
  1626. length: int,
  1627. base: int,
  1628. ):
  1629. for i in range(length):
  1630. tostarts[tostartsoffset + i] = int(
  1631. fromstarts[fromstartsoffset + i] + base
  1632. )
  1633. tostops[tostopsoffset + i] = int(fromstops[fromstopsoffset + i] + base)
  1634. return
  1635.  
  1636.  
  1637. awkward_listarray_fill_to64_from32
  1638. ----------------------------------------------------
  1639.  
  1640. def awkward_listarray_fill_to64_from32(
  1641. tostarts: List[int],
  1642. tostartsoffset: int,
  1643. tostops: List[int],
  1644. tostopsoffset: int,
  1645. fromstarts: List[int],
  1646. fromstartsoffset: int,
  1647. fromstops: List[int],
  1648. fromstopsoffset: int,
  1649. length: int,
  1650. base: int,
  1651. ):
  1652. return awkward_listarray_fill(
  1653. tostarts,
  1654. tostartsoffset,
  1655. tostops,
  1656. tostopsoffset,
  1657. fromstarts,
  1658. fromstartsoffset,
  1659. fromstops,
  1660. fromstopsoffset,
  1661. length,
  1662. base,
  1663. )
  1664.  
  1665.  
  1666. awkward_listarray_fill_to64_fromU32
  1667. ----------------------------------------------------
  1668.  
  1669. def awkward_listarray_fill_to64_fromU32(
  1670. tostarts: List[int],
  1671. tostartsoffset: int,
  1672. tostops: List[int],
  1673. tostopsoffset: int,
  1674. fromstarts: List[int],
  1675. fromstartsoffset: int,
  1676. fromstops: List[int],
  1677. fromstopsoffset: int,
  1678. length: int,
  1679. base: int,
  1680. ):
  1681. return awkward_listarray_fill(
  1682. tostarts,
  1683. tostartsoffset,
  1684. tostops,
  1685. tostopsoffset,
  1686. fromstarts,
  1687. fromstartsoffset,
  1688. fromstops,
  1689. fromstopsoffset,
  1690. length,
  1691. base,
  1692. )
  1693.  
  1694.  
  1695. awkward_listarray_fill_to64_from64
  1696. ----------------------------------------------------
  1697.  
  1698. def awkward_listarray_fill_to64_from64(
  1699. tostarts: List[int],
  1700. tostartsoffset: int,
  1701. tostops: List[int],
  1702. tostopsoffset: int,
  1703. fromstarts: List[int],
  1704. fromstartsoffset: int,
  1705. fromstops: List[int],
  1706. fromstopsoffset: int,
  1707. length: int,
  1708. base: int,
  1709. ):
  1710. return awkward_listarray_fill(
  1711. tostarts,
  1712. tostartsoffset,
  1713. tostops,
  1714. tostopsoffset,
  1715. fromstarts,
  1716. fromstartsoffset,
  1717. fromstops,
  1718. fromstopsoffset,
  1719. length,
  1720. base,
  1721. )
  1722.  
  1723.  
  1724. awkward_indexedarray_fill
  1725. ----------------------------------------------------
  1726.  
  1727. for FROM in int:
  1728. for TO in int:
  1729.  
  1730. def awkward_indexedarray_fill(
  1731. toindex: List[TO],
  1732. toindexoffset: int,
  1733. fromindex: List[FROM],
  1734. fromindexoffset: int,
  1735. length: int,
  1736. base: int,
  1737. ):
  1738. for i in range(length):
  1739. fromval = fromindex[fromindexoffset + i]
  1740. toindex[toindexoffset + i] = -1 if fromval < 0 else int(fromval + base)
  1741. return
  1742.  
  1743.  
  1744. awkward_indexedarray_fill_to64_from32
  1745. ----------------------------------------------------
  1746.  
  1747. def awkward_indexedarray_fill_to64_from32(
  1748. toindex: List[int],
  1749. toindexoffset: int,
  1750. fromindex: List[int],
  1751. fromindexoffset: int,
  1752. length: int,
  1753. base: int,
  1754. ):
  1755. return awkward_indexedarray_fill(
  1756. toindex, toindexoffset, fromindex, fromindexoffset, length, base
  1757. )
  1758.  
  1759.  
  1760. awkward_indexedarray_fill_to64_fromU32
  1761. ----------------------------------------------------
  1762.  
  1763. def awkward_indexedarray_fill_to64_fromU32(
  1764. toindex: List[int],
  1765. toindexoffset: int,
  1766. fromindex: List[int],
  1767. fromindexoffset: int,
  1768. length: int,
  1769. base: int,
  1770. ):
  1771. return awkward_indexedarray_fill(
  1772. toindex, toindexoffset, fromindex, fromindexoffset, length, base
  1773. )
  1774.  
  1775.  
  1776. awkward_indexedarray_fill_to64_from64
  1777. ----------------------------------------------------
  1778.  
  1779. def awkward_indexedarray_fill_to64_from64(
  1780. toindex: List[int],
  1781. toindexoffset: int,
  1782. fromindex: List[int],
  1783. fromindexoffset: int,
  1784. length: int,
  1785. base: int,
  1786. ):
  1787. return awkward_indexedarray_fill(
  1788. toindex, toindexoffset, fromindex, fromindexoffset, length, base
  1789. )
  1790.  
  1791.  
  1792. awkward_indexedarray_fill_count
  1793. ----------------------------------------------------
  1794.  
  1795. def awkward_indexedarray_fill_count(
  1796. toindex: List[TO], toindexoffset: int, length: int, base: int
  1797. ):
  1798. for i in range(length):
  1799. toindex[toindexoffset + i] = i + base
  1800. return
  1801.  
  1802.  
  1803. awkward_indexedarray_fill_to64_count
  1804. ----------------------------------------------------
  1805.  
  1806. def awkward_indexedarray_fill_to64_count(
  1807. toindex: List[int], toindexoffset: int, length: int, base: int
  1808. ):
  1809. return awkward_indexedarray_fill_count(toindex, toindexoffset, length, base)
  1810.  
  1811.  
  1812. awkward_unionarray_filltags
  1813. ----------------------------------------------------
  1814.  
  1815. for FROM in int:
  1816. for TO in int:
  1817.  
  1818. def awkward_unionarray_filltags(
  1819. totags: List[TO],
  1820. totagsoffset: int,
  1821. fromtags: List[FROM],
  1822. fromtagsoffset: int,
  1823. length: int,
  1824. base: int,
  1825. ):
  1826. for i in range(length):
  1827. totags[totagsoffset + i] = int(fromtags[fromtagsoffset + i] + base)
  1828. return
  1829.  
  1830.  
  1831. awkward_unionarray_filltags_to8_from8
  1832. ----------------------------------------------------
  1833.  
  1834. def awkward_unionarray_filltags_to8_from8(
  1835. totags: List[int],
  1836. totagsoffset: int,
  1837. fromtags: List[int],
  1838. fromtagsoffset: int,
  1839. length: int,
  1840. base: int,
  1841. ):
  1842. return awkward_unionarray_filltags(
  1843. totags, totagsoffset, fromtags, fromtagsoffset, length, base
  1844. )
  1845.  
  1846.  
  1847. awkward_unionarray_fillindex
  1848. ----------------------------------------------------
  1849.  
  1850. for FROM in int:
  1851. for TO in int:
  1852.  
  1853. def awkward_unionarray_fillindex(
  1854. toindex: List[TO],
  1855. toindexoffset: int,
  1856. fromindex: List[FROM],
  1857. fromindexoffset: int,
  1858. length: int,
  1859. ):
  1860. for i in range(length):
  1861. toindex[toindexoffset + i] = int(fromindex[fromindexoffset + i])
  1862. return
  1863.  
  1864.  
  1865. awkward_unionarray_fillindex_to64_from32
  1866. ----------------------------------------------------
  1867.  
  1868. def awkward_unionarray_fillindex_to64_from32(
  1869. toindex: List[int],
  1870. toindexoffset: int,
  1871. fromindex: List[int],
  1872. fromindexoffset: int,
  1873. length: int,
  1874. ):
  1875. return awkward_unionarray_fillindex(
  1876. toindex, toindexoffset, fromindex, fromindexoffset, length
  1877. )
  1878.  
  1879.  
  1880. awkward_unionarray_fillindex_to64_fromU32
  1881. ----------------------------------------------------
  1882.  
  1883. def awkward_unionarray_fillindex_to64_fromU32(
  1884. toindex: List[int],
  1885. toindexoffset: int,
  1886. fromindex: List[int],
  1887. fromindexoffset: int,
  1888. length: int,
  1889. ):
  1890. return awkward_unionarray_fillindex(
  1891. toindex, toindexoffset, fromindex, fromindexoffset, length
  1892. )
  1893.  
  1894.  
  1895. awkward_unionarray_fillindex_to64_from64
  1896. ----------------------------------------------------
  1897.  
  1898. def awkward_unionarray_fillindex_to64_from64(
  1899. toindex: List[int],
  1900. toindexoffset: int,
  1901. fromindex: List[int],
  1902. fromindexoffset: int,
  1903. length: int,
  1904. ):
  1905. return awkward_unionarray_fillindex(
  1906. toindex, toindexoffset, fromindex, fromindexoffset, length
  1907. )
  1908.  
  1909.  
  1910. awkward_unionarray_filltags_const
  1911. ----------------------------------------------------
  1912.  
  1913. for TO in int:
  1914.  
  1915. def awkward_unionarray_filltags_const(
  1916. totags: List[TO], totagsoffset: int, length: int, base: int
  1917. ):
  1918. for i in range(length):
  1919. totags[totagsoffset + i] = int(base)
  1920. return
  1921.  
  1922.  
  1923. awkward_unionarray_filltags_to8_const
  1924. ----------------------------------------------------
  1925.  
  1926. def awkward_unionarray_filltags_to8_const(
  1927. totags: List[int], totagsoffset: int, length: int, base: int
  1928. ):
  1929. return awkward_unionarray_filltags_const(totags, totagsoffset, length, base)
  1930.  
  1931.  
  1932. awkward_unionarray_fillindex_count
  1933. ----------------------------------------------------
  1934.  
  1935. for TO in int:
  1936.  
  1937. def awkward_unionarray_fillindex_count(
  1938. toindex: List[TO], toindexoffset: int, length: int
  1939. ):
  1940. for i in range(length):
  1941. toindex[toindexoffset + i] = int(i)
  1942. return
  1943.  
  1944.  
  1945. awkward_unionarray_fillindex_to64_count
  1946. ----------------------------------------------------
  1947.  
  1948. def awkward_unionarray_fillindex_to64_count(
  1949. toindex: List[int], toindexoffset: int, length: int
  1950. ):
  1951. return awkward_unionarray_fillindex_count(toindex, toindexoffset, length)
  1952.  
  1953.  
  1954. awkward_unionarray_simplify
  1955. ----------------------------------------------------
  1956.  
  1957. for OUTERTAGS in int:
  1958. for OUTERINDEX in int:
  1959. for INNERTAGS in int:
  1960. for INNERINDEX in int:
  1961. for TOTAGS in int:
  1962. for TOINDEX in int:
  1963.  
  1964. def awkward_unionarray_simplify(
  1965. totags: List[TOTAGS],
  1966. toindex: List[TOINDEX],
  1967. outertags: List[OUTERTAGS],
  1968. outertagsoffset: int,
  1969. outerindex: List[OUTERINDEX],
  1970. outerindexoffset: int,
  1971. innertags: List[INNERTAGS],
  1972. innertagsoffset: int,
  1973. innerindex: List[INNERINDEX],
  1974. innerindexoffset: int,
  1975. towhich: int,
  1976. innerwhich: int,
  1977. outerwhich: int,
  1978. length: int,
  1979. base: int,
  1980. ):
  1981. for i in range(length):
  1982. if outertags[outertagsoffset + i] == outerwhich:
  1983. j = outerindex[outerindexoffset + i]
  1984. if innertags[innertagsoffset + j] == innerwhich:
  1985. totags[i] = int(towhich)
  1986. toindex[i] = int(
  1987. innerindex[innerindexoffset + j] + base
  1988. )
  1989. return
  1990.  
  1991.  
  1992. awkward_unionarray8_32_simplify8_32_to8_64
  1993. ----------------------------------------------------
  1994.  
  1995. def awkward_unionarray8_32_simplify8_32_to8_64(
  1996. totags: List[int],
  1997. toindex: List[int],
  1998. outertags: List[int],
  1999. outertagsoffset: int,
  2000. outerindex: List[int],
  2001. outerindexoffset: int,
  2002. innertags: List[int],
  2003. innertagsoffset: int,
  2004. innerindex: List[int],
  2005. innerindexoffset: int,
  2006. towhich: int,
  2007. innerwhich: int,
  2008. outerwhich: int,
  2009. length: int,
  2010. base: int,
  2011. ):
  2012. return awkward_unionarray_simplify(
  2013. totags,
  2014. toindex,
  2015. outertags,
  2016. outertagsoffset,
  2017. outerindex,
  2018. outerindexoffset,
  2019. innertags,
  2020. innertagsoffset,
  2021. innerindex,
  2022. innerindexoffset,
  2023. towhich,
  2024. innerwhich,
  2025. outerwhich,
  2026. length,
  2027. base,
  2028. )
  2029.  
  2030.  
  2031. awkward_unionarray8_32_simplify8_U32_to8_64
  2032. ----------------------------------------------------
  2033.  
  2034. def awkward_unionarray8_32_simplify8_U32_to8_64(
  2035. totags: List[int],
  2036. toindex: List[int],
  2037. outertags: List[int],
  2038. outertagsoffset: int,
  2039. outerindex: List[int],
  2040. outerindexoffset: int,
  2041. innertags: List[int],
  2042. innertagsoffset: int,
  2043. innerindex: List[int],
  2044. innerindexoffset: int,
  2045. towhich: int,
  2046. innerwhich: int,
  2047. outerwhich: int,
  2048. length: int,
  2049. base: int,
  2050. ):
  2051. return awkward_unionarray_simplify(
  2052. totags,
  2053. toindex,
  2054. outertags,
  2055. outertagsoffset,
  2056. outerindex,
  2057. outerindexoffset,
  2058. innertags,
  2059. innertagsoffset,
  2060. innerindex,
  2061. innerindexoffset,
  2062. towhich,
  2063. innerwhich,
  2064. outerwhich,
  2065. length,
  2066. base,
  2067. )
  2068.  
  2069.  
  2070. awkward_unionarray8_32_simplify8_64_to8_64
  2071. ----------------------------------------------------
  2072.  
  2073. def awkward_unionarray8_32_simplify8_64_to8_64(
  2074. totags: List[int],
  2075. toindex: List[int],
  2076. outertags: List[int],
  2077. outertagsoffset: int,
  2078. outerindex: List[int],
  2079. outerindexoffset: int,
  2080. innertags: List[int],
  2081. innertagsoffset: int,
  2082. innerindex: List[int],
  2083. innerindexoffset: int,
  2084. towhich: int,
  2085. innerwhich: int,
  2086. outerwhich: int,
  2087. length: int,
  2088. base: int,
  2089. ):
  2090. return awkward_unionarray_simplify(
  2091. totags,
  2092. toindex,
  2093. outertags,
  2094. outertagsoffset,
  2095. outerindex,
  2096. outerindexoffset,
  2097. innertags,
  2098. innertagsoffset,
  2099. innerindex,
  2100. innerindexoffset,
  2101. towhich,
  2102. innerwhich,
  2103. outerwhich,
  2104. length,
  2105. base,
  2106. )
  2107.  
  2108.  
  2109. awkward_unionarray8_U32_simplify8_32_to8_64
  2110. ----------------------------------------------------
  2111.  
  2112. def awkward_unionarray8_U32_simplify8_32_to8_64(
  2113. totags: List[int],
  2114. toindex: List[int],
  2115. outertags: List[int],
  2116. outertagsoffset: int,
  2117. outerindex: List[int],
  2118. outerindexoffset: int,
  2119. innertags: List[int],
  2120. innertagsoffset: int,
  2121. innerindex: List[int],
  2122. innerindexoffset: int,
  2123. towhich: int,
  2124. innerwhich: int,
  2125. outerwhich: int,
  2126. length: int,
  2127. base: int,
  2128. ):
  2129. return awkward_unionarray_simplify(
  2130. totags,
  2131. toindex,
  2132. outertags,
  2133. outertagsoffset,
  2134. outerindex,
  2135. outerindexoffset,
  2136. innertags,
  2137. innertagsoffset,
  2138. innerindex,
  2139. innerindexoffset,
  2140. towhich,
  2141. innerwhich,
  2142. outerwhich,
  2143. length,
  2144. base,
  2145. )
  2146.  
  2147.  
  2148. awkward_unionarray8_U32_simplify8_U32_to8_64
  2149. ----------------------------------------------------
  2150.  
  2151. def awkward_unionarray8_U32_simplify8_U32_to8_64(
  2152. totags: List[int],
  2153. toindex: List[int],
  2154. outertags: List[int],
  2155. outertagsoffset: int,
  2156. outerindex: List[int],
  2157. outerindexoffset: int,
  2158. innertags: List[int],
  2159. innertagsoffset: int,
  2160. innerindex: List[int],
  2161. innerindexoffset: int,
  2162. towhich: int,
  2163. innerwhich: int,
  2164. outerwhich: int,
  2165. length: int,
  2166. base: int,
  2167. ):
  2168. return awkward_unionarray_simplify(
  2169. totags,
  2170. toindex,
  2171. outertags,
  2172. outertagsoffset,
  2173. outerindex,
  2174. outerindexoffset,
  2175. innertags,
  2176. innertagsoffset,
  2177. innerindex,
  2178. innerindexoffset,
  2179. towhich,
  2180. innerwhich,
  2181. outerwhich,
  2182. length,
  2183. base,
  2184. )
  2185.  
  2186.  
  2187. awkward_unionarray8_U32_simplify8_64_to8_64
  2188. ----------------------------------------------------
  2189.  
  2190. def awkward_unionarray8_U32_simplify8_64_to8_64(
  2191. totags: List[int],
  2192. toindex: List[int],
  2193. outertags: List[int],
  2194. outertagsoffset: int,
  2195. outerindex: List[int],
  2196. outerindexoffset: int,
  2197. innertags: List[int],
  2198. innertagsoffset: int,
  2199. innerindex: List[int],
  2200. innerindexoffset: int,
  2201. towhich: int,
  2202. innerwhich: int,
  2203. outerwhich: int,
  2204. length: int,
  2205. base: int,
  2206. ):
  2207. return awkward_unionarray_simplify(
  2208. totags,
  2209. toindex,
  2210. outertags,
  2211. outertagsoffset,
  2212. outerindex,
  2213. outerindexoffset,
  2214. innertags,
  2215. innertagsoffset,
  2216. innerindex,
  2217. innerindexoffset,
  2218. towhich,
  2219. innerwhich,
  2220. outerwhich,
  2221. length,
  2222. base,
  2223. )
  2224.  
  2225.  
  2226. awkward_unionarray8_64_simplify8_32_to8_64
  2227. ----------------------------------------------------
  2228.  
  2229. def awkward_unionarray8_64_simplify8_32_to8_64(
  2230. totags: List[int],
  2231. toindex: List[int],
  2232. outertags: List[int],
  2233. outertagsoffset: int,
  2234. outerindex: List[int],
  2235. outerindexoffset: int,
  2236. innertags: List[int],
  2237. innertagsoffset: int,
  2238. innerindex: List[int],
  2239. innerindexoffset: int,
  2240. towhich: int,
  2241. innerwhich: int,
  2242. outerwhich: int,
  2243. length: int,
  2244. base: int,
  2245. ):
  2246. return awkward_unionarray_simplify(
  2247. totags,
  2248. toindex,
  2249. outertags,
  2250. outertagsoffset,
  2251. outerindex,
  2252. outerindexoffset,
  2253. innertags,
  2254. innertagsoffset,
  2255. innerindex,
  2256. innerindexoffset,
  2257. towhich,
  2258. innerwhich,
  2259. outerwhich,
  2260. length,
  2261. base,
  2262. )
  2263.  
  2264.  
  2265. awkward_unionarray8_64_simplify8_U32_to8_64
  2266. ----------------------------------------------------
  2267.  
  2268. def awkward_unionarray8_64_simplify8_U32_to8_64(
  2269. totags: List[int],
  2270. toindex: List[int],
  2271. outertags: List[int],
  2272. outertagsoffset: int,
  2273. outerindex: List[int],
  2274. outerindexoffset: int,
  2275. innertags: List[int],
  2276. innertagsoffset: int,
  2277. innerindex: List[int],
  2278. innerindexoffset: int,
  2279. towhich: int,
  2280. innerwhich: int,
  2281. outerwhich: int,
  2282. length: int,
  2283. base: int,
  2284. ):
  2285. return awkward_unionarray_simplify(
  2286. totags,
  2287. toindex,
  2288. outertags,
  2289. outertagsoffset,
  2290. outerindex,
  2291. outerindexoffset,
  2292. innertags,
  2293. innertagsoffset,
  2294. innerindex,
  2295. innerindexoffset,
  2296. towhich,
  2297. innerwhich,
  2298. outerwhich,
  2299. length,
  2300. base,
  2301. )
  2302.  
  2303.  
  2304. awkward_unionarray8_64_simplify8_64_to8_64
  2305. ----------------------------------------------------
  2306.  
  2307. def awkward_unionarray8_64_simplify8_64_to8_64(
  2308. totags: List[int],
  2309. toindex: List[int],
  2310. outertags: List[int],
  2311. outertagsoffset: int,
  2312. outerindex: List[int],
  2313. outerindexoffset: int,
  2314. innertags: List[int],
  2315. innertagsoffset: int,
  2316. innerindex: List[int],
  2317. innerindexoffset: int,
  2318. towhich: int,
  2319. innerwhich: int,
  2320. outerwhich: int,
  2321. length: int,
  2322. base: int,
  2323. ):
  2324. return awkward_unionarray_simplify(
  2325. totags,
  2326. toindex,
  2327. outertags,
  2328. outertagsoffset,
  2329. outerindex,
  2330. outerindexoffset,
  2331. innertags,
  2332. innertagsoffset,
  2333. innerindex,
  2334. innerindexoffset,
  2335. towhich,
  2336. innerwhich,
  2337. outerwhich,
  2338. length,
  2339. base,
  2340. )
  2341.  
  2342.  
  2343. awkward_unionarray_simplify_one
  2344. ----------------------------------------------------
  2345.  
  2346. for FROMTAGS in int:
  2347. for FROMINDEX in int:
  2348. for TOTAGS in int:
  2349. for TOINDEX in int:
  2350.  
  2351. def awkward_unionarray_simplify_one(
  2352. totags: List[TOTAGS],
  2353. toindex: List[TOINDEX],
  2354. fromtags: List[FROMTAGS],
  2355. fromtagsoffset: int,
  2356. fromindex: List[FROMINDEX],
  2357. fromindexoffset: int,
  2358. towhich: int,
  2359. fromwhich: int,
  2360. length: int,
  2361. base: int,
  2362. ):
  2363. for i in range(length):
  2364. if fromtags[fromtagsoffset + i] == fromwhich:
  2365. totags[i] = int(towhich)
  2366. toindex[i] = int(fromindex[fromindexoffset + i] + base)
  2367. return
  2368.  
  2369.  
  2370. awkward_unionarray8_32_simplify_one_to8_64
  2371. ----------------------------------------------------
  2372.  
  2373. def awkward_unionarray8_32_simplify_one_to8_64(
  2374. totags: List[int],
  2375. toindex: List[int],
  2376. fromtags: List[int],
  2377. fromtagsoffset: int,
  2378. fromindex: List[int],
  2379. fromindexoffset: int,
  2380. towhich: int,
  2381. fromwhich: int,
  2382. length: int,
  2383. base: int,
  2384. ):
  2385. return awkward_unionarray_simplify_one(
  2386. totags,
  2387. toindex,
  2388. fromtags,
  2389. fromtagsoffset,
  2390. fromindex,
  2391. fromindexoffset,
  2392. towhich,
  2393. fromwhich,
  2394. length,
  2395. base,
  2396. )
  2397.  
  2398.  
  2399. awkward_unionarray8_U32_simplify_one_to8_64
  2400. ----------------------------------------------------
  2401.  
  2402. def awkward_unionarray8_U32_simplify_one_to8_64(
  2403. totags: List[int],
  2404. toindex: List[int],
  2405. fromtags: List[int],
  2406. fromtagsoffset: int,
  2407. fromindex: List[int],
  2408. fromindexoffset: int,
  2409. towhich: int,
  2410. fromwhich: int,
  2411. length: int,
  2412. base: int,
  2413. ):
  2414. return awkward_unionarray_simplify_one(
  2415. totags,
  2416. toindex,
  2417. fromtags,
  2418. fromtagsoffset,
  2419. fromindex,
  2420. fromindexoffset,
  2421. towhich,
  2422. fromwhich,
  2423. length,
  2424. base,
  2425. )
  2426.  
  2427.  
  2428. awkward_unionarray8_64_simplify_one_to8_64
  2429. ----------------------------------------------------
  2430.  
  2431. def awkward_unionarray8_64_simplify_one_to8_64(
  2432. totags: List[int],
  2433. toindex: List[int],
  2434. fromtags: List[int],
  2435. fromtagsoffset: int,
  2436. fromindex: List[int],
  2437. fromindexoffset: int,
  2438. towhich: int,
  2439. fromwhich: int,
  2440. length: int,
  2441. base: int,
  2442. ):
  2443. return awkward_unionarray_simplify_one(
  2444. totags,
  2445. toindex,
  2446. fromtags,
  2447. fromtagsoffset,
  2448. fromindex,
  2449. fromindexoffset,
  2450. towhich,
  2451. fromwhich,
  2452. length,
  2453. base,
  2454. )
  2455.  
  2456.  
  2457. awkward_listarray_validity
  2458. ----------------------------------------------------
  2459.  
  2460. for C in int:
  2461.  
  2462. def awkward_listarray_validity(
  2463. starts: List[C],
  2464. startsoffset: int,
  2465. stops: List[C],
  2466. stopsoffset: int,
  2467. length: int,
  2468. lencontent: int,
  2469. ):
  2470. for i in range(length):
  2471. start = starts[startsoffset + i]
  2472. stop = stops[stopsoffset + i]
  2473. if start != stop:
  2474. if start > stop:
  2475. raise ValueError("start[i] > stop[i]")
  2476. if start < 0:
  2477. raise ValueError("start[i] < 0")
  2478. if stop > lencontent:
  2479. raise ValueError("stop[i] > len(content)")
  2480. return
  2481.  
  2482.  
  2483. awkward_listarray32_validity
  2484. ----------------------------------------------------
  2485.  
  2486. def awkward_listarray32_validity(
  2487. starts: List[int],
  2488. startsoffset: int,
  2489. stops: List[int],
  2490. stopsoffset: int,
  2491. length: int,
  2492. lencontent: int,
  2493. ):
  2494. return awkward_listarray_validity(
  2495. starts, startsoffset, stops, stopsoffset, length, lencontent
  2496. )
  2497.  
  2498.  
  2499. awkward_listarrayU32_validity
  2500. ----------------------------------------------------
  2501.  
  2502. def awkward_listarrayU32_validity(
  2503. starts: List[int],
  2504. startsoffset: int,
  2505. stops: List[int],
  2506. stopsoffset: int,
  2507. length: int,
  2508. lencontent: int,
  2509. ):
  2510. return awkward_listarray_validity(
  2511. starts, startsoffset, stops, stopsoffset, length, lencontent
  2512. )
  2513.  
  2514.  
  2515. awkward_listarray64_validity
  2516. ----------------------------------------------------
  2517.  
  2518. def awkward_listarray64_validity(
  2519. starts: List[int],
  2520. startsoffset: int,
  2521. stops: List[int],
  2522. stopsoffset: int,
  2523. length: int,
  2524. lencontent: int,
  2525. ):
  2526. return awkward_listarray_validity(
  2527. starts, startsoffset, stops, stopsoffset, length, lencontent
  2528. )
  2529.  
  2530.  
  2531. awkward_indexedarray_validity
  2532. ----------------------------------------------------
  2533.  
  2534. for C in int:
  2535. for ISOPTION in bool:
  2536.  
  2537. def awkward_indexedarray_validity(
  2538. index: List[C], indexoffset: int, length: int, lencontent: int
  2539. ):
  2540. for i in range(length):
  2541. idx = index[indexoffset + i]
  2542. if not ISOPTION:
  2543. if idx < 0:
  2544. raise ValueError("index[i] < 0")
  2545. if idx >= lencontent:
  2546. raise ValueError("index[i] >= len(content)")
  2547. return
  2548.  
  2549.  
  2550. awkward_indexedarray32_validity
  2551. ----------------------------------------------------
  2552.  
  2553. def awkward_indexedarray32_validity(
  2554. index: List[int], indexoffset: int, length: int, lencontent: int, isoption: bool
  2555. ):
  2556. if isoption:
  2557. return awkward_indexedarray_validity(index, indexoffset, length, lencontent)
  2558. else:
  2559. return awkward_indexedarray_validity(index, indexoffset, length, lencontent)
  2560.  
  2561.  
  2562. awkward_indexedarrayU32_validity
  2563. ----------------------------------------------------
  2564.  
  2565. def awkward_indexedarrayU32_validity(
  2566. index: List[int], indexoffset: int, length: int, lencontent: int, isoption: bool
  2567. ):
  2568. if isoption:
  2569. return awkward_indexedarray_validity(index, indexoffset, length, lencontent)
  2570. else:
  2571. return awkward_indexedarray_validity(index, indexoffset, length, lencontent)
  2572.  
  2573.  
  2574. awkward_indexedarray64_validity
  2575. ----------------------------------------------------
  2576.  
  2577. def awkward_indexedarray64_validity(
  2578. index: List[int], indexoffset: int, length: int, lencontent: int, isoption: bool
  2579. ):
  2580. if isoption:
  2581. return awkward_indexedarray_validity(index, indexoffset, length, lencontent)
  2582. else:
  2583. return awkward_indexedarray_validity(index, indexoffset, length, lencontent)
  2584.  
  2585.  
  2586. awkward_unionarray_validity
  2587. ----------------------------------------------------
  2588.  
  2589. for T in int:
  2590. for I in int:
  2591.  
  2592. def awkward_unionarray_validity(
  2593. tags: List[T],
  2594. tagsoffset: int,
  2595. index: List[I],
  2596. indexoffset: int,
  2597. length: int,
  2598. numcontents: int,
  2599. lencontents: List[int],
  2600. ):
  2601. for i in range(length):
  2602. tag = tags[tagsoffset + i]
  2603. idx = index[indexoffset + i]
  2604. if tag < 0:
  2605. raise ValueError("tags[i] < 0")
  2606. if idx < 0:
  2607. raise ValueError("index[i] < 0")
  2608. if tag >= numcontents:
  2609. raise ValueError("tags[i] >= len(contents)")
  2610. lencontent = lencontents[tag]
  2611. if idx >= lencontent:
  2612. raise ValueError("index[i] >= len(content[tags[i]])")
  2613. return
  2614.  
  2615.  
  2616. awkward_unionarray8_32_validity
  2617. ----------------------------------------------------
  2618.  
  2619. def awkward_unionarray8_32_validity(
  2620. tags: List[int],
  2621. tagsoffset: int,
  2622. index: List[int],
  2623. indexoffset: int,
  2624. length: int,
  2625. numcontents: int,
  2626. lencontents: List[int],
  2627. ):
  2628. return awkward_unionarray_validity(
  2629. tags, tagsoffset, index, indexoffset, length, numcontents, lencontents
  2630. )
  2631.  
  2632.  
  2633. awkward_unionarray8_U32_validity
  2634. ----------------------------------------------------
  2635.  
  2636. def awkward_unionarray8_U32_validity(
  2637. tags: List[int],
  2638. tagsoffset: int,
  2639. index: List[int],
  2640. indexoffset: int,
  2641. length: int,
  2642. numcontents: int,
  2643. lencontents: List[int],
  2644. ):
  2645. return awkward_unionarray_validity(
  2646. tags, tagsoffset, index, indexoffset, length, numcontents, lencontents
  2647. )
  2648.  
  2649.  
  2650. awkward_unionarray8_64_validity
  2651. ----------------------------------------------------
  2652.  
  2653. def awkward_unionarray8_64_validity(
  2654. tags: List[int],
  2655. tagsoffset: int,
  2656. index: List[int],
  2657. indexoffset: int,
  2658. length: int,
  2659. numcontents: int,
  2660. lencontents: List[int],
  2661. ):
  2662. return awkward_unionarray_validity(
  2663. tags, tagsoffset, index, indexoffset, length, numcontents, lencontents
  2664. )
  2665.  
  2666.  
  2667. awkward_UnionArray_fillna
  2668. ----------------------------------------------------
  2669.  
  2670. for T in int:
  2671. for C in int:
  2672.  
  2673. def awkward_UnionArray_fillna(
  2674. toindex: List[T], fromindex: List[C], offset: int, length: int
  2675. ):
  2676. for i in range(length):
  2677. toindex[i] = fromindex[offset + i] if fromindex[offset + i] >= 0 else 0
  2678. return
  2679.  
  2680.  
  2681. awkward_UnionArray_fillna_from32_to64
  2682. ----------------------------------------------------
  2683.  
  2684. def awkward_UnionArray_fillna_from32_to64(
  2685. toindex: List[int], fromindex: List[int], offset: int, length: int
  2686. ):
  2687. return awkward_UnionArray_fillna(toindex, fromindex, offset, length)
  2688.  
  2689.  
  2690. awkward_UnionArray_fillna_fromU32_to64
  2691. ----------------------------------------------------
  2692.  
  2693. def awkward_UnionArray_fillna_fromU32_to64(
  2694. toindex: List[int], fromindex: List[int], offset: int, length: int
  2695. ):
  2696. return awkward_UnionArray_fillna(toindex, fromindex, offset, length)
  2697.  
  2698.  
  2699. awkward_UnionArray_fillna_from64_to64
  2700. ----------------------------------------------------
  2701.  
  2702. def awkward_UnionArray_fillna_from64_to64(
  2703. toindex: List[int], fromindex: List[int], offset: int, length: int
  2704. ):
  2705. return awkward_UnionArray_fillna(toindex, fromindex, offset, length)
  2706.  
  2707.  
  2708. awkward_IndexedOptionArray_rpad_and_clip_mask_axis1
  2709. ----------------------------------------------------
  2710.  
  2711. for T in int:
  2712.  
  2713. def awkward_IndexedOptionArray_rpad_and_clip_mask_axis1(
  2714. toindex: List[T], frommask: List[int], length: int
  2715. ):
  2716. count = 0
  2717. for i in range(length):
  2718. if frommask[i]:
  2719. toindex[i] = -1
  2720. else:
  2721. toindex[i] = count = count + 1
  2722. return
  2723.  
  2724.  
  2725. awkward_IndexedOptionArray_rpad_and_clip_mask_axis1_64
  2726. ----------------------------------------------------
  2727.  
  2728. def awkward_IndexedOptionArray_rpad_and_clip_mask_axis1_64(
  2729. toindex: List[int], frommask: List[int], length: int
  2730. ):
  2731. return awkward_IndexedOptionArray_rpad_and_clip_mask_axis1(
  2732. toindex, frommask, length
  2733. )
  2734.  
  2735.  
  2736. awkward_index_rpad_and_clip_axis0
  2737. ----------------------------------------------------
  2738.  
  2739. for T in int:
  2740.  
  2741. def awkward_index_rpad_and_clip_axis0(toindex: List[T], target: int, length: int):
  2742. shorter = target if target < length else length
  2743. for i in range(shorter):
  2744. toindex[i] = i
  2745. i = shorter
  2746. while i < target:
  2747. toindex[i] = -1
  2748. i = i + 1
  2749. return
  2750.  
  2751.  
  2752. awkward_index_rpad_and_clip_axis0_64
  2753. ----------------------------------------------------
  2754.  
  2755. def awkward_index_rpad_and_clip_axis0_64(toindex: List[int], target: int, length: int):
  2756. return awkward_index_rpad_and_clip_axis0(toindex, target, length)
  2757.  
  2758.  
  2759. awkward_index_rpad_and_clip_axis1
  2760. ----------------------------------------------------
  2761.  
  2762. for T in int:
  2763.  
  2764. def awkward_index_rpad_and_clip_axis1(
  2765. tostarts: List[T], tostops: List[T], target: int, length: int
  2766. ):
  2767. offset = 0
  2768. for i in range(length):
  2769. tostarts[i] = offset
  2770. offset = offset + target
  2771. tostops[i] = offset
  2772. return
  2773.  
  2774.  
  2775. awkward_index_rpad_and_clip_axis1_64
  2776. ----------------------------------------------------
  2777.  
  2778. def awkward_index_rpad_and_clip_axis1_64(
  2779. tostarts: List[int], tostops: List[int], target: int, length: int
  2780. ):
  2781. return awkward_index_rpad_and_clip_axis1(tostarts, tostops, target, length)
  2782.  
  2783.  
  2784. awkward_RegularArray_rpad_and_clip_axis1
  2785. ----------------------------------------------------
  2786.  
  2787. for T in int:
  2788.  
  2789. def awkward_RegularArray_rpad_and_clip_axis1(
  2790. toindex: List[T], target: int, size: int, length: int
  2791. ):
  2792. shorter = target if target < size else size
  2793. for i in range(length):
  2794. for j in range(shorter):
  2795. toindex[(i * target) + j] = (i * size) + j
  2796. j = shorter
  2797. while j < target:
  2798. toindex[(i * target) + j] = -1
  2799. j = j + 1
  2800. return
  2801.  
  2802.  
  2803. awkward_RegularArray_rpad_and_clip_axis1_64
  2804. ----------------------------------------------------
  2805.  
  2806. def awkward_RegularArray_rpad_and_clip_axis1_64(
  2807. toindex: List[int], target: int, size: int, length: int
  2808. ):
  2809. return awkward_RegularArray_rpad_and_clip_axis1(toindex, target, size, length)
  2810.  
  2811.  
  2812. awkward_ListArray_min_range
  2813. ----------------------------------------------------
  2814.  
  2815. for C in int:
  2816.  
  2817. def awkward_ListArray_min_range(
  2818. tomin: List[int],
  2819. fromstarts: List[C],
  2820. fromstops: List[C],
  2821. lenstarts: int,
  2822. startsoffset: int,
  2823. stopsoffset: int,
  2824. ):
  2825. shorter = fromstops[stopsoffset + 0] - fromstarts[startsoffset + 0]
  2826. i = 1
  2827. while i < lenstarts:
  2828. range = fromstops[startsoffset + i] - fromstarts[stopsoffset + i]
  2829. shorter = shorter if shorter < range else range
  2830. i = i + 1
  2831. tomin = shorter
  2832. return
  2833.  
  2834.  
  2835. awkward_ListArray32_min_range
  2836. ----------------------------------------------------
  2837.  
  2838. def awkward_ListArray32_min_range(
  2839. tomin: List[int],
  2840. fromstarts: List[int],
  2841. fromstops: List[int],
  2842. lenstarts: int,
  2843. startsoffset: int,
  2844. stopsoffset: int,
  2845. ):
  2846. return awkward_ListArray_min_range(
  2847. tomin, fromstarts, fromstops, lenstarts, startsoffset, stopsoffset
  2848. )
  2849.  
  2850.  
  2851. awkward_ListArrayU32_min_range
  2852. ----------------------------------------------------
  2853.  
  2854. def awkward_ListArrayU32_min_range(
  2855. tomin: List[int],
  2856. fromstarts: List[int],
  2857. fromstops: List[int],
  2858. lenstarts: int,
  2859. startsoffset: int,
  2860. stopsoffset: int,
  2861. ):
  2862. return awkward_ListArray_min_range(
  2863. tomin, fromstarts, fromstops, lenstarts, startsoffset, stopsoffset
  2864. )
  2865.  
  2866.  
  2867. awkward_ListArray64_min_range
  2868. ----------------------------------------------------
  2869.  
  2870. def awkward_ListArray64_min_range(
  2871. tomin: List[int],
  2872. fromstarts: List[int],
  2873. fromstops: List[int],
  2874. lenstarts: int,
  2875. startsoffset: int,
  2876. stopsoffset: int,
  2877. ):
  2878. return awkward_ListArray_min_range(
  2879. tomin, fromstarts, fromstops, lenstarts, startsoffset, stopsoffset
  2880. )
  2881.  
  2882.  
  2883. awkward_ListArray_rpad_and_clip_length_axis1
  2884. ----------------------------------------------------
  2885.  
  2886. for C in int:
  2887.  
  2888. def awkward_ListArray_rpad_and_clip_length_axis1(
  2889. tolength: List[int],
  2890. fromstarts: List[C],
  2891. fromstops: List[C],
  2892. target: int,
  2893. lenstarts: int,
  2894. startsoffset: int,
  2895. stopsoffset: int,
  2896. ):
  2897. length = 0
  2898. for i in range(lenstarts):
  2899. range = fromstops[startsoffset + i] - fromstarts[stopsoffset + i]
  2900. length = target if target > range else range
  2901. tolength = length
  2902. return
  2903.  
  2904.  
  2905. awkward_ListArray32_rpad_and_clip_length_axis1
  2906. ----------------------------------------------------
  2907.  
  2908. def awkward_ListArray32_rpad_and_clip_length_axis1(
  2909. tomin: List[int],
  2910. fromstarts: List[int],
  2911. fromstops: List[int],
  2912. target: int,
  2913. lenstarts: int,
  2914. startsoffset: int,
  2915. stopsoffset: int,
  2916. ):
  2917. return awkward_ListArray_rpad_and_clip_length_axis1(
  2918. tomin, fromstarts, fromstops, target, lenstarts, startsoffset, stopsoffset
  2919. )
  2920.  
  2921.  
  2922. awkward_ListArrayU32_rpad_and_clip_length_axis1
  2923. ----------------------------------------------------
  2924.  
  2925. def awkward_ListArrayU32_rpad_and_clip_length_axis1(
  2926. tomin: List[int],
  2927. fromstarts: List[int],
  2928. fromstops: List[int],
  2929. target: int,
  2930. lenstarts: int,
  2931. startsoffset: int,
  2932. stopsoffset: int,
  2933. ):
  2934. return awkward_ListArray_rpad_and_clip_length_axis1(
  2935. tomin, fromstarts, fromstops, target, lenstarts, startsoffset, stopsoffset
  2936. )
  2937.  
  2938.  
  2939. awkward_ListArray64_rpad_and_clip_length_axis1
  2940. ----------------------------------------------------
  2941.  
  2942. def awkward_ListArray64_rpad_and_clip_length_axis1(
  2943. tomin: List[int],
  2944. fromstarts: List[int],
  2945. fromstops: List[int],
  2946. target: int,
  2947. lenstarts: int,
  2948. startsoffset: int,
  2949. stopsoffset: int,
  2950. ):
  2951. return awkward_ListArray_rpad_and_clip_length_axis1(
  2952. tomin, fromstarts, fromstops, target, lenstarts, startsoffset, stopsoffset
  2953. )
  2954.  
  2955.  
  2956. awkward_ListArray_rpad_axis1
  2957. ----------------------------------------------------
  2958.  
  2959. for T in int:
  2960. for C in int:
  2961.  
  2962. def awkward_ListArray_rpad_axis1(
  2963. toindex: List[T],
  2964. fromstarts: List[C],
  2965. fromstops: List[C],
  2966. tostarts: List[C],
  2967. tostops: List[C],
  2968. target: int,
  2969. length: int,
  2970. startsoffset: int,
  2971. stopsoffset: int,
  2972. ):
  2973. offset = 0
  2974. for i in range(length):
  2975. tostarts[i] = offset
  2976. range = fromstops[startsoffset + i] - fromstarts[stopsoffset + i]
  2977. for j in range(range):
  2978. toindex[offset + j] = fromstarts[startsoffset + i] + j
  2979. j = range
  2980. while j < target:
  2981. toindex[offset + j] = -1
  2982. j = j + 1
  2983. offset = tostarts[i] + target if target > range else tostarts[i] + range
  2984. tostops[i] = offset
  2985. return
  2986.  
  2987.  
  2988. awkward_ListArray32_rpad_axis1_64
  2989. ----------------------------------------------------
  2990.  
  2991. def awkward_ListArray32_rpad_axis1_64(
  2992. toindex: List[int],
  2993. fromstarts: List[int],
  2994. fromstops: List[int],
  2995. tostarts: List[int],
  2996. tostops: List[int],
  2997. target: int,
  2998. length: int,
  2999. startsoffset: int,
  3000. stopsoffset: int,
  3001. ):
  3002. return awkward_ListArray_rpad_axis1(
  3003. toindex,
  3004. fromstarts,
  3005. fromstops,
  3006. tostarts,
  3007. tostops,
  3008. target,
  3009. length,
  3010. startsoffset,
  3011. stopsoffset,
  3012. )
  3013.  
  3014.  
  3015. awkward_ListArrayU32_rpad_axis1_64
  3016. ----------------------------------------------------
  3017.  
  3018. def awkward_ListArrayU32_rpad_axis1_64(
  3019. toindex: List[int],
  3020. fromstarts: List[int],
  3021. fromstops: List[int],
  3022. tostarts: List[int],
  3023. tostops: List[int],
  3024. target: int,
  3025. length: int,
  3026. startsoffset: int,
  3027. stopsoffset: int,
  3028. ):
  3029. return awkward_ListArray_rpad_axis1(
  3030. toindex,
  3031. fromstarts,
  3032. fromstops,
  3033. tostarts,
  3034. tostops,
  3035. target,
  3036. length,
  3037. startsoffset,
  3038. stopsoffset,
  3039. )
  3040.  
  3041.  
  3042. awkward_ListArray64_rpad_axis1_64
  3043. ----------------------------------------------------
  3044.  
  3045. def awkward_ListArray64_rpad_axis1_64(
  3046. toindex: List[int],
  3047. fromstarts: List[int],
  3048. fromstops: List[int],
  3049. tostarts: List[int],
  3050. tostops: List[int],
  3051. target: int,
  3052. length: int,
  3053. startsoffset: int,
  3054. stopsoffset: int,
  3055. ):
  3056. return awkward_ListArray_rpad_axis1(
  3057. toindex,
  3058. fromstarts,
  3059. fromstops,
  3060. tostarts,
  3061. tostops,
  3062. target,
  3063. length,
  3064. startsoffset,
  3065. stopsoffset,
  3066. )
  3067.  
  3068.  
  3069. awkward_ListOffsetArray_rpad_and_clip_axis1
  3070. ----------------------------------------------------
  3071.  
  3072. for T in int:
  3073. for C in int:
  3074.  
  3075. def awkward_ListOffsetArray_rpad_and_clip_axis1(
  3076. toindex: List[T],
  3077. fromoffsets: List[C],
  3078. offsetsoffset: int,
  3079. length: int,
  3080. target: int,
  3081. ):
  3082. for i in range(length):
  3083. range = int(
  3084. fromoffsets[(offsetsoffset + i) + 1]
  3085. - fromoffsets[offsetsoffset + i]
  3086. )
  3087. shorter = target if target < range else range
  3088. for j in range(shorter):
  3089. toindex[(i * target) + j] = int(fromoffsets[offsetsoffset + i]) + j
  3090. j = shorter
  3091. while j < target:
  3092. toindex[(i * target) + j] = -1
  3093. j = j + 1
  3094. return
  3095.  
  3096.  
  3097. awkward_ListOffsetArray32_rpad_and_clip_axis1_64
  3098. ----------------------------------------------------
  3099.  
  3100. def awkward_ListOffsetArray32_rpad_and_clip_axis1_64(
  3101. toindex: List[int],
  3102. fromoffsets: List[int],
  3103. offsetsoffset: int,
  3104. length: int,
  3105. target: int,
  3106. ):
  3107. return awkward_ListOffsetArray_rpad_and_clip_axis1(
  3108. toindex, fromoffsets, offsetsoffset, length, target
  3109. )
  3110.  
  3111.  
  3112. awkward_ListOffsetArrayU32_rpad_and_clip_axis1_64
  3113. ----------------------------------------------------
  3114.  
  3115. def awkward_ListOffsetArrayU32_rpad_and_clip_axis1_64(
  3116. toindex: List[int],
  3117. fromoffsets: List[int],
  3118. offsetsoffset: int,
  3119. length: int,
  3120. target: int,
  3121. ):
  3122. return awkward_ListOffsetArray_rpad_and_clip_axis1(
  3123. toindex, fromoffsets, offsetsoffset, length, target
  3124. )
  3125.  
  3126.  
  3127. awkward_ListOffsetArray64_rpad_and_clip_axis1_64
  3128. ----------------------------------------------------
  3129.  
  3130. def awkward_ListOffsetArray64_rpad_and_clip_axis1_64(
  3131. toindex: List[int],
  3132. fromoffsets: List[int],
  3133. offsetsoffset: int,
  3134. length: int,
  3135. target: int,
  3136. ):
  3137. return awkward_ListOffsetArray_rpad_and_clip_axis1(
  3138. toindex, fromoffsets, offsetsoffset, length, target
  3139. )
  3140.  
  3141.  
  3142. awkward_ListOffsetArray_rpad_length_axis1
  3143. ----------------------------------------------------
  3144.  
  3145. for C in int:
  3146.  
  3147. def awkward_ListOffsetArray_rpad_length_axis1(
  3148. tooffsets: List[C],
  3149. fromoffsets: List[C],
  3150. offsetsoffset: int,
  3151. fromlength: int,
  3152. target: int,
  3153. tolength: List[int],
  3154. ):
  3155. length = 0
  3156. tooffsets[0] = 0
  3157. for i in range(fromlength):
  3158. range = (
  3159. fromoffsets[(offsetsoffset + i) + 1] - fromoffsets[offsetsoffset + i]
  3160. )
  3161. longer = range if target < range else target
  3162. length = length + longer
  3163. tooffsets[i + 1] = tooffsets[i] + longer
  3164. tolength = length
  3165. return
  3166.  
  3167.  
  3168. awkward_ListOffsetArray32_rpad_length_axis1
  3169. ----------------------------------------------------
  3170.  
  3171. def awkward_ListOffsetArray32_rpad_length_axis1(
  3172. tooffsets: List[int],
  3173. fromoffsets: List[int],
  3174. offsetsoffset: int,
  3175. fromlength: int,
  3176. target: int,
  3177. tolength: List[int],
  3178. ):
  3179. return awkward_ListOffsetArray_rpad_length_axis1(
  3180. tooffsets, fromoffsets, offsetsoffset, fromlength, target, tolength
  3181. )
  3182.  
  3183.  
  3184. awkward_ListOffsetArrayU32_rpad_length_axis1
  3185. ----------------------------------------------------
  3186.  
  3187. def awkward_ListOffsetArrayU32_rpad_length_axis1(
  3188. tooffsets: List[int],
  3189. fromoffsets: List[int],
  3190. offsetsoffset: int,
  3191. fromlength: int,
  3192. target: int,
  3193. tolength: List[int],
  3194. ):
  3195. return awkward_ListOffsetArray_rpad_length_axis1(
  3196. tooffsets, fromoffsets, offsetsoffset, fromlength, target, tolength
  3197. )
  3198.  
  3199.  
  3200. awkward_ListOffsetArray64_rpad_length_axis1
  3201. ----------------------------------------------------
  3202.  
  3203. def awkward_ListOffsetArray64_rpad_length_axis1(
  3204. tooffsets: List[int],
  3205. fromoffsets: List[int],
  3206. offsetsoffset: int,
  3207. fromlength: int,
  3208. target: int,
  3209. tolength: List[int],
  3210. ):
  3211. return awkward_ListOffsetArray_rpad_length_axis1(
  3212. tooffsets, fromoffsets, offsetsoffset, fromlength, target, tolength
  3213. )
  3214.  
  3215.  
  3216. awkward_ListOffsetArray_rpad_axis1
  3217. ----------------------------------------------------
  3218.  
  3219. for T in int:
  3220. for C in int:
  3221.  
  3222. def awkward_ListOffsetArray_rpad_axis1(
  3223. toindex: List[T],
  3224. fromoffsets: List[C],
  3225. offsetsoffset: int,
  3226. fromlength: int,
  3227. target: int,
  3228. ):
  3229. count = 0
  3230. for i in range(fromlength):
  3231. range = int(
  3232. fromoffsets[(offsetsoffset + i) + 1]
  3233. - fromoffsets[offsetsoffset + i]
  3234. )
  3235. for j in range(range):
  3236. count = count + 1
  3237. toindex[count] = int(fromoffsets[offsetsoffset + i]) + j
  3238. j = range
  3239. while j < target:
  3240. count = count + 1
  3241. toindex[count] = -1
  3242. j = j + 1
  3243. return
  3244.  
  3245.  
  3246. awkward_ListOffsetArray32_rpad_axis1_64
  3247. ----------------------------------------------------
  3248.  
  3249. def awkward_ListOffsetArray32_rpad_axis1_64(
  3250. toindex: List[int],
  3251. fromoffsets: List[int],
  3252. offsetsoffset: int,
  3253. fromlength: int,
  3254. target: int,
  3255. ):
  3256. return awkward_ListOffsetArray_rpad_axis1(
  3257. toindex, fromoffsets, offsetsoffset, fromlength, target
  3258. )
  3259.  
  3260.  
  3261. awkward_ListOffsetArrayU32_rpad_axis1_64
  3262. ----------------------------------------------------
  3263.  
  3264. def awkward_ListOffsetArrayU32_rpad_axis1_64(
  3265. toindex: List[int],
  3266. fromoffsets: List[int],
  3267. offsetsoffset: int,
  3268. fromlength: int,
  3269. target: int,
  3270. ):
  3271. return awkward_ListOffsetArray_rpad_axis1(
  3272. toindex, fromoffsets, offsetsoffset, fromlength, target
  3273. )
  3274.  
  3275.  
  3276. awkward_ListOffsetArray64_rpad_axis1_64
  3277. ----------------------------------------------------
  3278.  
  3279. def awkward_ListOffsetArray64_rpad_axis1_64(
  3280. toindex: List[int],
  3281. fromoffsets: List[int],
  3282. offsetsoffset: int,
  3283. fromlength: int,
  3284. target: int,
  3285. ):
  3286. return awkward_ListOffsetArray_rpad_axis1(
  3287. toindex, fromoffsets, offsetsoffset, fromlength, target
  3288. )
  3289.  
  3290.  
  3291. awkward_localindex
  3292. ----------------------------------------------------
  3293.  
  3294. for T in int:
  3295.  
  3296. def awkward_localindex(toindex: List[T], length: int):
  3297. for i in range(length):
  3298. toindex[i] = i
  3299. return
  3300.  
  3301.  
  3302. awkward_localindex_64
  3303. ----------------------------------------------------
  3304.  
  3305. def awkward_localindex_64(toindex: List[int], length: int):
  3306. return awkward_localindex(toindex, length)
  3307.  
  3308.  
  3309. awkward_listarray_localindex
  3310. ----------------------------------------------------
  3311.  
  3312. for C in int:
  3313. for T in int:
  3314.  
  3315. def awkward_listarray_localindex(
  3316. toindex: List[T], offsets: List[C], offsetsoffset: int, length: int
  3317. ):
  3318. for i in range(length):
  3319. start = int(offsets[offsetsoffset + i])
  3320. stop = int(offsets[(offsetsoffset + i) + 1])
  3321. j = start
  3322. while j < stop:
  3323. toindex[j] = j - start
  3324. j = j + 1
  3325. return
  3326.  
  3327.  
  3328. awkward_listarray32_localindex_64
  3329. ----------------------------------------------------
  3330.  
  3331. def awkward_listarray32_localindex_64(
  3332. toindex: List[int], offsets: List[int], offsetsoffset: int, length: int
  3333. ):
  3334. return awkward_listarray_localindex(toindex, offsets, offsetsoffset, length)
  3335.  
  3336.  
  3337. awkward_listarrayU32_localindex_64
  3338. ----------------------------------------------------
  3339.  
  3340. def awkward_listarrayU32_localindex_64(
  3341. toindex: List[int], offsets: List[int], offsetsoffset: int, length: int
  3342. ):
  3343. return awkward_listarray_localindex(toindex, offsets, offsetsoffset, length)
  3344.  
  3345.  
  3346. awkward_listarray64_localindex_64
  3347. ----------------------------------------------------
  3348.  
  3349. def awkward_listarray64_localindex_64(
  3350. toindex: List[int], offsets: List[int], offsetsoffset: int, length: int
  3351. ):
  3352. return awkward_listarray_localindex(toindex, offsets, offsetsoffset, length)
  3353.  
  3354.  
  3355. awkward_regulararray_localindex
  3356. ----------------------------------------------------
  3357.  
  3358. for T in int:
  3359.  
  3360. def awkward_regulararray_localindex(toindex: List[T], size: int, length: int):
  3361. for i in range(length):
  3362. for j in range(size):
  3363. toindex[(i * size) + j] = j
  3364. return
  3365.  
  3366.  
  3367. awkward_regulararray_localindex_64
  3368. ----------------------------------------------------
  3369.  
  3370. def awkward_regulararray_localindex_64(toindex: List[int], size: int, length: int):
  3371. return awkward_regulararray_localindex(toindex, size, length)
  3372.  
  3373.  
  3374. awkward_combinations
  3375. ----------------------------------------------------
  3376.  
  3377. for T in int:
  3378.  
  3379. def awkward_combinations(
  3380. toindex: List[T], n: int, replacement: bool, singlelen: int
  3381. ):
  3382. raise ValueError("FIXME: awkward_combinations")
  3383.  
  3384.  
  3385. awkward_combinations_64
  3386. ----------------------------------------------------
  3387.  
  3388. def awkward_combinations_64(
  3389. toindex: List[int], n: int, replacement: bool, singlelen: int
  3390. ):
  3391. return awkward_combinations(toindex, n, replacement, singlelen)
  3392.  
  3393.  
  3394. awkward_listarray_combinations_length
  3395. ----------------------------------------------------
  3396.  
  3397. for C in int:
  3398. for T in int:
  3399.  
  3400. def awkward_listarray_combinations_length(
  3401. totallen: List[int],
  3402. tooffsets: List[T],
  3403. n: int,
  3404. replacement: bool,
  3405. starts: List[C],
  3406. startsoffset: int,
  3407. stops: List[C],
  3408. stopsoffset: int,
  3409. length: int,
  3410. ):
  3411. totallen = 0
  3412. tooffsets[0] = 0
  3413. for i in range(length):
  3414. size = int(stops[stopsoffset + i] - starts[startsoffset + i])
  3415. if replacement:
  3416. size = n - 1
  3417. thisn = n
  3418.  
  3419. if thisn > size:
  3420. combinationslen = 0
  3421. else:
  3422. if thisn == size:
  3423. combinationslen = 1
  3424. else:
  3425. if (thisn * 2) > size:
  3426. thisn = size - thisn
  3427. combinationslen = size
  3428. j = 2
  3429. while j <= thisn:
  3430. combinationslen = (size - j) + 1
  3431. combinationslen = j
  3432. j = j + 1
  3433. totallen = totallen + combinationslen
  3434. tooffsets[i + 1] = tooffsets[i] + combinationslen
  3435. return
  3436.  
  3437.  
  3438. awkward_listarray32_combinations_length_64
  3439. ----------------------------------------------------
  3440.  
  3441. def awkward_listarray32_combinations_length_64(
  3442. totallen: List[int],
  3443. tooffsets: List[int],
  3444. n: int,
  3445. replacement: bool,
  3446. starts: List[int],
  3447. startsoffset: int,
  3448. stops: List[int],
  3449. stopsoffset: int,
  3450. length: int,
  3451. ):
  3452. return awkward_listarray_combinations_length(
  3453. totallen,
  3454. tooffsets,
  3455. n,
  3456. replacement,
  3457. starts,
  3458. startsoffset,
  3459. stops,
  3460. stopsoffset,
  3461. length,
  3462. )
  3463.  
  3464.  
  3465. awkward_listarrayU32_combinations_length_64
  3466. ----------------------------------------------------
  3467.  
  3468. def awkward_listarrayU32_combinations_length_64(
  3469. totallen: List[int],
  3470. tooffsets: List[int],
  3471. n: int,
  3472. replacement: bool,
  3473. starts: List[int],
  3474. startsoffset: int,
  3475. stops: List[int],
  3476. stopsoffset: int,
  3477. length: int,
  3478. ):
  3479. return awkward_listarray_combinations_length(
  3480. totallen,
  3481. tooffsets,
  3482. n,
  3483. replacement,
  3484. starts,
  3485. startsoffset,
  3486. stops,
  3487. stopsoffset,
  3488. length,
  3489. )
  3490.  
  3491.  
  3492. awkward_listarray64_combinations_length_64
  3493. ----------------------------------------------------
  3494.  
  3495. def awkward_listarray64_combinations_length_64(
  3496. totallen: List[int],
  3497. tooffsets: List[int],
  3498. n: int,
  3499. replacement: bool,
  3500. starts: List[int],
  3501. startsoffset: int,
  3502. stops: List[int],
  3503. stopsoffset: int,
  3504. length: int,
  3505. ):
  3506. return awkward_listarray_combinations_length(
  3507. totallen,
  3508. tooffsets,
  3509. n,
  3510. replacement,
  3511. starts,
  3512. startsoffset,
  3513. stops,
  3514. stopsoffset,
  3515. length,
  3516. )
  3517.  
  3518.  
  3519. awkward_listarray_combinations_step
  3520. ----------------------------------------------------
  3521.  
  3522. def awkward_listarray_combinations_step(
  3523. tocarry: List[List[int]],
  3524. toindex: List[int],
  3525. fromindex: List[int],
  3526. j: int,
  3527. stop: int,
  3528. n: int,
  3529. replacement: bool,
  3530. ):
  3531. while fromindex[j] < stop:
  3532. if replacement:
  3533. k = j + 1
  3534. while k < n:
  3535. fromindex[k] = fromindex[j]
  3536. k = k + 1
  3537. else:
  3538. k = j + 1
  3539. while k < n:
  3540. fromindex[k] = fromindex[j] + (k - j)
  3541. k = k + 1
  3542. if (j + 1) == n:
  3543. for k in range(n):
  3544. tocarry[k][toindex[k]] = fromindex[k]
  3545. toindex[k] = toindex[k] + 1
  3546. else:
  3547. awkward_listarray_combinations_step(
  3548. tocarry, toindex, fromindex, j + 1, stop, n, replacement
  3549. )
  3550. fromindex[j] = fromindex[j] + 1
  3551.  
  3552.  
  3553. awkward_listarray_combinations
  3554. ----------------------------------------------------
  3555.  
  3556. for C in int:
  3557. for T in int:
  3558.  
  3559. def awkward_listarray_combinations(
  3560. tocarry: List[List[int]],
  3561. n: int,
  3562. replacement: bool,
  3563. starts: List[C],
  3564. startsoffset: int,
  3565. stops: List[C],
  3566. stopsoffset: int,
  3567. length: int,
  3568. ):
  3569. toindex = []
  3570. fromindex = []
  3571. for j in range(n):
  3572. toindex[j] = 0
  3573. for i in range(length):
  3574. start = int(starts[startsoffset + i])
  3575. stop = int(stops[stopsoffset + i])
  3576. fromindex[0] = start
  3577. awkward_listarray_combinations_step(
  3578. tocarry, toindex, fromindex, 0, stop, n, replacement
  3579. )
  3580. return
  3581.  
  3582.  
  3583. awkward_listarray32_combinations_64
  3584. ----------------------------------------------------
  3585.  
  3586. def awkward_listarray32_combinations_64(
  3587. tocarry: List[List[int]],
  3588. n: int,
  3589. replacement: bool,
  3590. starts: List[int],
  3591. startsoffset: int,
  3592. stops: List[int],
  3593. stopsoffset: int,
  3594. length: int,
  3595. ):
  3596. return awkward_listarray_combinations(
  3597. tocarry, n, replacement, starts, startsoffset, stops, stopsoffset, length
  3598. )
  3599.  
  3600.  
  3601. awkward_listarrayU32_combinations_64
  3602. ----------------------------------------------------
  3603.  
  3604. def awkward_listarrayU32_combinations_64(
  3605. tocarry: List[List[int]],
  3606. n: int,
  3607. replacement: bool,
  3608. starts: List[int],
  3609. startsoffset: int,
  3610. stops: List[int],
  3611. stopsoffset: int,
  3612. length: int,
  3613. ):
  3614. return awkward_listarray_combinations(
  3615. tocarry, n, replacement, starts, startsoffset, stops, stopsoffset, length
  3616. )
  3617.  
  3618.  
  3619. awkward_listarray64_combinations_64
  3620. ----------------------------------------------------
  3621.  
  3622. def awkward_listarray64_combinations_64(
  3623. tocarry: List[List[int]],
  3624. n: int,
  3625. replacement: bool,
  3626. starts: List[int],
  3627. startsoffset: int,
  3628. stops: List[int],
  3629. stopsoffset: int,
  3630. length: int,
  3631. ):
  3632. return awkward_listarray_combinations(
  3633. tocarry, n, replacement, starts, startsoffset, stops, stopsoffset, length
  3634. )
  3635.  
  3636.  
  3637. awkward_regulararray_combinations
  3638. ----------------------------------------------------
  3639.  
  3640. for C in int:
  3641. for T in int:
  3642.  
  3643. def awkward_regulararray_combinations(
  3644. tocarry: List[List[int]], n: int, replacement: bool, size: int, length: int
  3645. ):
  3646. toindex = []
  3647. fromindex = []
  3648. for j in range(n):
  3649. toindex[j] = 0
  3650. for i in range(length):
  3651. start = size * i
  3652. stop = start + size
  3653. fromindex[0] = start
  3654. awkward_listarray_combinations_step(
  3655. tocarry, toindex, fromindex, 0, stop, n, replacement
  3656. )
  3657. return
  3658.  
  3659.  
  3660. awkward_regulararray_combinations_64
  3661. ----------------------------------------------------
  3662.  
  3663. def awkward_regulararray_combinations_64(
  3664. tocarry: List[List[int]], n: int, replacement: bool, size: int, length: int
  3665. ):
  3666. return awkward_regulararray_combinations(tocarry, n, replacement, size, length)
  3667.  
  3668.  
  3669. awkward_bytemaskedarray_overlay_mask
  3670. ----------------------------------------------------
  3671.  
  3672. for M in int:
  3673.  
  3674. def awkward_bytemaskedarray_overlay_mask(
  3675. tomask: List[M],
  3676. theirmask: List[M],
  3677. theirmaskoffset: int,
  3678. mymask: List[M],
  3679. mymaskoffset: int,
  3680. length: int,
  3681. validwhen: bool,
  3682. ):
  3683. for i in range(length):
  3684. theirs = theirmask[theirmaskoffset + i]
  3685. mine = (mymask[mymaskoffset + i] != 0) != validwhen
  3686. tomask[i] = 1 if theirs | mine else 0
  3687. return
  3688.  
  3689.  
  3690. awkward_bytemaskedarray_overlay_mask8
  3691. ----------------------------------------------------
  3692.  
  3693. def awkward_bytemaskedarray_overlay_mask8(
  3694. tomask: List[int],
  3695. theirmask: List[int],
  3696. theirmaskoffset: int,
  3697. mymask: List[int],
  3698. mymaskoffset: int,
  3699. length: int,
  3700. validwhen: bool,
  3701. ):
  3702. return awkward_bytemaskedarray_overlay_mask(
  3703. tomask, theirmask, theirmaskoffset, mymask, mymaskoffset, length, validwhen
  3704. )
  3705.  
  3706.  
  3707. awkward_bitmaskedarray_to_bytemaskedarray
  3708. ----------------------------------------------------
  3709.  
  3710. def awkward_bitmaskedarray_to_bytemaskedarray(
  3711. tobytemask: List[int],
  3712. frombitmask: List[int],
  3713. bitmaskoffset: int,
  3714. bitmasklength: int,
  3715. validwhen: bool,
  3716. lsb_order: int,
  3717. ):
  3718. if lsb_order:
  3719. for i in range(bitmasklength):
  3720. byte = frombitmask[bitmaskoffset + i]
  3721. tobytemask[(i * 8) + 0] = (byte & int(1)) != validwhen
  3722. byte = 1
  3723. tobytemask[(i * 8) + 1] = (byte & int(1)) != validwhen
  3724. byte = 1
  3725. tobytemask[(i * 8) + 2] = (byte & int(1)) != validwhen
  3726. byte = 1
  3727. tobytemask[(i * 8) + 3] = (byte & int(1)) != validwhen
  3728. byte = 1
  3729. tobytemask[(i * 8) + 4] = (byte & int(1)) != validwhen
  3730. byte = 1
  3731. tobytemask[(i * 8) + 5] = (byte & int(1)) != validwhen
  3732. byte = 1
  3733. tobytemask[(i * 8) + 6] = (byte & int(1)) != validwhen
  3734. byte = 1
  3735. tobytemask[(i * 8) + 7] = (byte & int(1)) != validwhen
  3736. else:
  3737. for i in range(bitmasklength):
  3738. byte = frombitmask[bitmaskoffset + i]
  3739. tobytemask[(i * 8) + 0] = ((byte & int(128)) != 0) != validwhen
  3740. byte = 1
  3741. tobytemask[(i * 8) + 1] = ((byte & int(128)) != 0) != validwhen
  3742. byte = 1
  3743. tobytemask[(i * 8) + 2] = ((byte & int(128)) != 0) != validwhen
  3744. byte = 1
  3745. tobytemask[(i * 8) + 3] = ((byte & int(128)) != 0) != validwhen
  3746. byte = 1
  3747. tobytemask[(i * 8) + 4] = ((byte & int(128)) != 0) != validwhen
  3748. byte = 1
  3749. tobytemask[(i * 8) + 5] = ((byte & int(128)) != 0) != validwhen
  3750. byte = 1
  3751. tobytemask[(i * 8) + 6] = ((byte & int(128)) != 0) != validwhen
  3752. byte = 1
  3753. tobytemask[(i * 8) + 7] = ((byte & int(128)) != 0) != validwhen
  3754. return
  3755.  
  3756.  
  3757. awkward_bitmaskedarray_to_indexedoptionarray
  3758. ----------------------------------------------------
  3759.  
  3760. for T in int:
  3761.  
  3762. def awkward_bitmaskedarray_to_indexedoptionarray(
  3763. toindex: List[T],
  3764. frombitmask: List[int],
  3765. bitmaskoffset: int,
  3766. bitmasklength: int,
  3767. validwhen: bool,
  3768. lsb_order: int,
  3769. ):
  3770. if lsb_order:
  3771. for i in range(bitmasklength):
  3772. byte = frombitmask[bitmaskoffset + i]
  3773. if (byte & int(1)) == validwhen:
  3774. toindex[(i * 8) + 0] = (i * 8) + 0
  3775. else:
  3776. toindex[(i * 8) + 0] = -1
  3777. byte = 1
  3778. if (byte & int(1)) == validwhen:
  3779. toindex[(i * 8) + 1] = (i * 8) + 1
  3780. else:
  3781. toindex[(i * 8) + 1] = -1
  3782. byte = 1
  3783. if (byte & int(1)) == validwhen:
  3784. toindex[(i * 8) + 2] = (i * 8) + 2
  3785. else:
  3786. toindex[(i * 8) + 2] = -1
  3787. byte = 1
  3788. if (byte & int(1)) == validwhen:
  3789. toindex[(i * 8) + 3] = (i * 8) + 3
  3790. else:
  3791. toindex[(i * 8) + 3] = -1
  3792. byte = 1
  3793. if (byte & int(1)) == validwhen:
  3794. toindex[(i * 8) + 4] = (i * 8) + 4
  3795. else:
  3796. toindex[(i * 8) + 4] = -1
  3797. byte = 1
  3798. if (byte & int(1)) == validwhen:
  3799. toindex[(i * 8) + 5] = (i * 8) + 5
  3800. else:
  3801. toindex[(i * 8) + 5] = -1
  3802. byte = 1
  3803. if (byte & int(1)) == validwhen:
  3804. toindex[(i * 8) + 6] = (i * 8) + 6
  3805. else:
  3806. toindex[(i * 8) + 6] = -1
  3807. byte = 1
  3808. if (byte & int(1)) == validwhen:
  3809. toindex[(i * 8) + 7] = (i * 8) + 7
  3810. else:
  3811. toindex[(i * 8) + 7] = -1
  3812. else:
  3813. for i in range(bitmasklength):
  3814. byte = frombitmask[bitmaskoffset + i]
  3815. if ((byte & int(128)) != 0) == validwhen:
  3816. toindex[(i * 8) + 0] = (i * 8) + 0
  3817. else:
  3818. toindex[(i * 8) + 0] = -1
  3819. byte = 1
  3820. if ((byte & int(128)) != 0) == validwhen:
  3821. toindex[(i * 8) + 1] = (i * 8) + 1
  3822. else:
  3823. toindex[(i * 8) + 1] = -1
  3824. byte = 1
  3825. if ((byte & int(128)) != 0) == validwhen:
  3826. toindex[(i * 8) + 2] = (i * 8) + 2
  3827. else:
  3828. toindex[(i * 8) + 2] = -1
  3829. byte = 1
  3830. if ((byte & int(128)) != 0) == validwhen:
  3831. toindex[(i * 8) + 3] = (i * 8) + 3
  3832. else:
  3833. toindex[(i * 8) + 3] = -1
  3834. byte = 1
  3835. if ((byte & int(128)) != 0) == validwhen:
  3836. toindex[(i * 8) + 4] = (i * 8) + 4
  3837. else:
  3838. toindex[(i * 8) + 4] = -1
  3839. byte = 1
  3840. if ((byte & int(128)) != 0) == validwhen:
  3841. toindex[(i * 8) + 5] = (i * 8) + 5
  3842. else:
  3843. toindex[(i * 8) + 5] = -1
  3844. byte = 1
  3845. if ((byte & int(128)) != 0) == validwhen:
  3846. toindex[(i * 8) + 6] = (i * 8) + 6
  3847. else:
  3848. toindex[(i * 8) + 6] = -1
  3849. byte = 1
  3850. if ((byte & int(128)) != 0) == validwhen:
  3851. toindex[(i * 8) + 7] = (i * 8) + 7
  3852. else:
  3853. toindex[(i * 8) + 7] = -1
  3854. return
  3855.  
  3856.  
  3857. awkward_bitmaskedarray_to_indexedoptionarray_64
  3858. ----------------------------------------------------
  3859.  
  3860. def awkward_bitmaskedarray_to_indexedoptionarray_64(
  3861. toindex: List[int],
  3862. frombitmask: List[int],
  3863. bitmaskoffset: int,
  3864. bitmasklength: int,
  3865. validwhen: bool,
  3866. lsb_order: int,
  3867. ):
  3868. return awkward_bitmaskedarray_to_indexedoptionarray(
  3869. toindex, frombitmask, bitmaskoffset, bitmasklength, validwhen, lsb_order
  3870. )
Add Comment
Please, Sign In to add comment