carray 3.0.6 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (277) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -1
  3. data/CHANGELOG.md +7 -1830
  4. data/README.md +62 -35
  5. data/carray.gemspec +16 -4
  6. data/docs/changelogs/CHANGELOG-3.0.md +2464 -0
  7. data/ext/ca_array_pool.c +4 -5
  8. data/ext/ca_axis_descriptor.h +45 -30
  9. data/ext/ca_axis_dispatch.c +7 -4
  10. data/ext/ca_axis_group.c +12 -15
  11. data/ext/ca_bincmp_dispatch.h +16 -38
  12. data/ext/ca_binop_dispatch.c +35 -0
  13. data/ext/ca_binop_dispatch.h +22 -46
  14. data/ext/ca_categorical_iterator.c +36 -34
  15. data/ext/ca_compare.c +0 -1
  16. data/ext/ca_compare.h +8 -1
  17. data/ext/ca_composite_dispatch.h +6 -0
  18. data/ext/ca_for_buffer.h +6 -1
  19. data/ext/ca_group_iter.c +17 -18
  20. data/ext/ca_iter_state_fields.h +196 -0
  21. data/ext/ca_iter_substrate.h +84 -103
  22. data/ext/ca_kernel_iterator.c +125 -89
  23. data/ext/ca_kernel_iterator.h +229 -1504
  24. data/ext/ca_kernel_iterator_internal.h +1167 -0
  25. data/ext/ca_moncmp_dispatch.h +17 -24
  26. data/ext/ca_monop_dispatch.h +25 -74
  27. data/ext/ca_obj_array.c +92 -165
  28. data/ext/ca_obj_bincmp.c +65 -48
  29. data/ext/ca_obj_binop.c +74 -49
  30. data/ext/ca_obj_bitarray.c +7 -21
  31. data/ext/ca_obj_bitfield.c +93 -26
  32. data/ext/ca_obj_block.c +11 -12
  33. data/ext/ca_obj_byte_swap.c +34 -34
  34. data/ext/ca_obj_const_string.c +464 -304
  35. data/ext/ca_obj_face.c +167 -121
  36. data/ext/ca_obj_face.h +32 -170
  37. data/ext/ca_obj_fake.c +127 -34
  38. data/ext/ca_obj_farray.c +13 -9
  39. data/ext/ca_obj_field.c +17 -13
  40. data/ext/ca_obj_fixlen_string.c +57 -34
  41. data/ext/ca_obj_grid.c +149 -113
  42. data/ext/ca_obj_meld.c +28 -26
  43. data/ext/ca_obj_moncmp.c +10 -21
  44. data/ext/ca_obj_monop.c +88 -73
  45. data/ext/ca_obj_object.c +60 -46
  46. data/ext/ca_obj_record.c +74 -22
  47. data/ext/ca_obj_reduce.c +10 -14
  48. data/ext/ca_obj_refer.c +146 -39
  49. data/ext/ca_obj_remap.c +11 -29
  50. data/ext/ca_obj_repeat.c +41 -23
  51. data/ext/ca_obj_roll.c +20 -28
  52. data/ext/ca_obj_select.c +17 -27
  53. data/ext/ca_obj_select_axis.c +35 -42
  54. data/ext/ca_obj_shift.c +22 -42
  55. data/ext/ca_obj_source.c +1 -5
  56. data/ext/ca_obj_stack.c +33 -29
  57. data/ext/ca_obj_stride.c +99 -62
  58. data/ext/ca_obj_string.c +8 -20
  59. data/ext/ca_obj_tile.c +14 -16
  60. data/ext/ca_obj_time.c +12 -23
  61. data/ext/ca_obj_timedelta.c +12 -23
  62. data/ext/ca_obj_transpose.c +8 -10
  63. data/ext/ca_obj_triop.c +48 -49
  64. data/ext/ca_obj_window.c +87 -99
  65. data/ext/ca_op_cmplx64.h +4 -0
  66. data/ext/ca_op_ipower.c +97 -27
  67. data/ext/ca_op_powi.h +9 -28
  68. data/ext/ca_pow5_table.h +2 -1
  69. data/ext/ca_rng_normal.h +4 -0
  70. data/ext/ca_rng_xoshiro256pp.h +3 -0
  71. data/ext/ca_sort_kernels.h +23 -26
  72. data/ext/ca_sweep_engine.c +92 -26
  73. data/ext/ca_sweep_engine.h +22 -15
  74. data/ext/ca_transform_common.c +3 -8
  75. data/ext/ca_triop_dispatch.h +20 -32
  76. data/ext/caframe_csv_reader.c +12 -12
  77. data/ext/carray.h +300 -1009
  78. data/ext/carray_access.c +320 -207
  79. data/ext/carray_address_basis.c +128 -59
  80. data/ext/carray_attribute.c +81 -104
  81. data/ext/carray_bincount.c +12 -14
  82. data/ext/carray_broadcast.c +31 -27
  83. data/ext/carray_call_cfunc.c +174 -285
  84. data/ext/carray_call_cfunc.h +36 -28
  85. data/ext/carray_cast.c +1191 -351
  86. data/ext/carray_cast_func.rb +68 -8
  87. data/ext/carray_class.c +6 -11
  88. data/ext/carray_conversion.c +98 -39
  89. data/ext/carray_copy.c +52 -26
  90. data/ext/carray_core.c +286 -132
  91. data/ext/carray_count.c +53 -22
  92. data/ext/carray_element.c +49 -28
  93. data/ext/carray_factorize.c +64 -63
  94. data/ext/carray_generate.c +26 -19
  95. data/ext/carray_histogram.c +9 -11
  96. data/ext/carray_hold.c +7 -9
  97. data/ext/carray_index_classifier.c +127 -230
  98. data/ext/carray_index_classifier.h +11 -10
  99. data/ext/carray_integer_total.c +523 -0
  100. data/ext/carray_internal.h +1364 -156
  101. data/ext/carray_key_windows.c +3 -3
  102. data/ext/carray_lazy.c +37 -37
  103. data/ext/carray_loop.c +27 -23
  104. data/ext/carray_mask.c +235 -150
  105. data/ext/carray_math_kernel.h +23 -47
  106. data/ext/carray_mathfunc.c +10 -3
  107. data/ext/carray_median_percentile.c +106 -100
  108. data/ext/carray_memory_view.c +83 -69
  109. data/ext/carray_operator.c +490 -128
  110. data/ext/carray_order.c +163 -84
  111. data/ext/carray_partition.c +14 -16
  112. data/ext/carray_random.c +48 -42
  113. data/ext/carray_round.c +33 -5
  114. data/ext/carray_scatter.c +57 -39
  115. data/ext/carray_segment.c +42 -46
  116. data/ext/carray_slab.c +77 -51
  117. data/ext/carray_slab.h +44 -33
  118. data/ext/carray_sort.c +37 -31
  119. data/ext/carray_sort_kernel.c +36 -10
  120. data/ext/carray_struct.c +44 -34
  121. data/ext/carray_test.c +131 -81
  122. data/ext/carray_time_text.c +30 -31
  123. data/ext/carray_undef.c +50 -7
  124. data/ext/carray_utils.c +373 -139
  125. data/ext/extconf.rb +24 -17
  126. data/ext/mk_call_cfunc.rb +25 -31
  127. data/ext/mk_pow5_table.rb +2 -1
  128. data/ext/mkkernel.rb +819 -488
  129. data/ext/ruby_carray.c +47 -42
  130. data/ext/version.h +7 -5
  131. data/lib/carray/attribute.rb +19 -18
  132. data/lib/carray/autoload_carray.rb +20 -15
  133. data/lib/carray/autoload_method_extension.rb +64 -57
  134. data/lib/carray/axis_group.rb +272 -185
  135. data/lib/carray/basics.rb +298 -56
  136. data/lib/carray/bincount_nd.rb +41 -18
  137. data/lib/carray/block_iterator.rb +167 -119
  138. data/lib/carray/boolean_reduce.rb +7 -4
  139. data/lib/carray/categorical.rb +84 -59
  140. data/lib/carray/categorical_iterator.rb +90 -67
  141. data/lib/carray/complex.rb +61 -41
  142. data/lib/carray/conditional.rb +98 -23
  143. data/lib/carray/const_string.rb +112 -46
  144. data/lib/carray/core_extensions.rb +20 -69
  145. data/lib/carray/distance_limit.rb +7 -5
  146. data/lib/carray/factories.rb +269 -0
  147. data/lib/carray/fixlen_string.rb +95 -12
  148. data/lib/carray/frame/column_verbs.rb +76 -9
  149. data/lib/carray/frame/concat.rb +51 -7
  150. data/lib/carray/frame/convert.rb +2 -1
  151. data/lib/carray/frame/csv_parser.rb +20 -5
  152. data/lib/carray/frame/frame.rb +73 -31
  153. data/lib/carray/frame/group.rb +247 -187
  154. data/lib/carray/frame/io.rb +36 -12
  155. data/lib/carray/frame/join.rb +56 -17
  156. data/lib/carray/frame/records.rb +7 -5
  157. data/lib/carray/frame/reshape.rb +27 -7
  158. data/lib/carray/frame/sort.rb +10 -8
  159. data/lib/carray/frame/verbs.rb +217 -134
  160. data/lib/carray/frame/windows.rb +254 -19
  161. data/lib/carray/frame.rb +1 -2
  162. data/lib/carray/fuse_source.rb +28 -23
  163. data/lib/carray/fusion.rb +30 -30
  164. data/lib/carray/histogram.rb +35 -16
  165. data/lib/carray/inspect.rb +7 -7
  166. data/lib/carray/iterator.rb +104 -23
  167. data/lib/carray/key_windows.rb +93 -61
  168. data/lib/carray/lazy.rb +208 -111
  169. data/lib/carray/limits.rb +80 -0
  170. data/lib/carray/mask_gap_fill.rb +21 -16
  171. data/lib/carray/math.rb +87 -50
  172. data/lib/carray/meld_reduce.rb +30 -8
  173. data/lib/carray/methods/align_addr.rb +29 -17
  174. data/lib/carray/methods/bin.rb +8 -1
  175. data/lib/carray/methods/bincount.rb +4 -2
  176. data/lib/carray/methods/bit_string.rb +19 -31
  177. data/lib/carray/methods/broadcast.rb +8 -3
  178. data/lib/carray/methods/choose.rb +5 -5
  179. data/lib/carray/methods/composition.rb +73 -72
  180. data/lib/carray/methods/{index.rb → coordinate.rb} +13 -13
  181. data/lib/carray/methods/discovery_along.rb +3 -3
  182. data/lib/carray/methods/factorize.rb +2 -0
  183. data/lib/carray/methods/gather_nd.rb +106 -103
  184. data/lib/carray/methods/insert_block.rb +2 -2
  185. data/lib/carray/methods/is_between.rb +6 -4
  186. data/lib/carray/methods/is_in.rb +183 -143
  187. data/lib/carray/methods/join.rb +2 -1
  188. data/lib/carray/methods/lag.rb +6 -2
  189. data/lib/carray/methods/locate_addr.rb +157 -94
  190. data/lib/carray/methods/mask_duplicates.rb +1 -1
  191. data/lib/carray/methods/meshgrid.rb +28 -16
  192. data/lib/carray/methods/mode.rb +67 -67
  193. data/lib/carray/methods/nunique.rb +9 -7
  194. data/lib/carray/methods/repeat.rb +23 -13
  195. data/lib/carray/methods/resize.rb +1 -1
  196. data/lib/carray/methods/snap.rb +24 -20
  197. data/lib/carray/methods/string_format.rb +2 -2
  198. data/lib/carray/methods/unique.rb +4 -2
  199. data/lib/carray/methods/value_counts.rb +1 -1
  200. data/lib/carray/mkmf.rb +25 -28
  201. data/lib/carray/percentile_arguments.rb +82 -0
  202. data/lib/carray/record_order.rb +50 -20
  203. data/lib/carray/rng.rb +1 -0
  204. data/lib/carray/runtime.rb +195 -17
  205. data/lib/carray/segment_iterator.rb +262 -137
  206. data/lib/carray/serialize.rb +635 -566
  207. data/lib/carray/slab_iterator.rb +114 -114
  208. data/lib/carray/stack.rb +14 -15
  209. data/lib/carray/string.rb +16 -22
  210. data/lib/carray/string_operation_extension.rb +97 -52
  211. data/lib/carray/struct.rb +122 -164
  212. data/lib/carray/struct_builder.rb +247 -73
  213. data/lib/carray/time.rb +663 -365
  214. data/lib/carray/window_iterator.rb +232 -155
  215. data/lib/carray.rb +6 -11
  216. data/yard-stubs/ca_obj_array.rb +20 -135
  217. data/yard-stubs/ca_obj_bitarray.rb +1 -8
  218. data/yard-stubs/ca_obj_bitfield.rb +6 -2
  219. data/yard-stubs/ca_obj_byte_swap.rb +21 -7
  220. data/yard-stubs/ca_obj_fake.rb +3 -1
  221. data/yard-stubs/ca_obj_farray.rb +1 -1
  222. data/yard-stubs/ca_obj_field.rb +8 -6
  223. data/yard-stubs/ca_obj_refer.rb +10 -5
  224. data/yard-stubs/ca_obj_roll.rb +7 -6
  225. data/yard-stubs/ca_obj_shift.rb +2 -3
  226. data/yard-stubs/ca_obj_stride.rb +5 -7
  227. data/yard-stubs/ca_obj_tile.rb +1 -1
  228. data/yard-stubs/ca_obj_time.rb +43 -0
  229. data/yard-stubs/ca_obj_transpose.rb +1 -1
  230. data/yard-stubs/ca_obj_window.rb +28 -16
  231. data/yard-stubs/carray_access.rb +55 -6
  232. data/yard-stubs/carray_attribute.rb +26 -38
  233. data/yard-stubs/carray_cast.rb +121 -162
  234. data/yard-stubs/carray_class.rb +3 -4
  235. data/yard-stubs/carray_conversion.rb +6 -7
  236. data/yard-stubs/carray_copy.rb +2 -1
  237. data/yard-stubs/carray_count.rb +10 -5
  238. data/yard-stubs/carray_element.rb +4 -3
  239. data/yard-stubs/carray_limits.rb +100 -0
  240. data/yard-stubs/carray_loop.rb +0 -20
  241. data/yard-stubs/carray_mask.rb +59 -41
  242. data/yard-stubs/carray_math.rb +162 -100
  243. data/yard-stubs/carray_mathfunc.rb +415 -3
  244. data/yard-stubs/carray_median_percentile.rb +29 -11
  245. data/yard-stubs/carray_memory_view.rb +2 -2
  246. data/yard-stubs/carray_order.rb +72 -33
  247. data/yard-stubs/carray_random.rb +6 -6
  248. data/yard-stubs/carray_reduce.rb +353 -0
  249. data/yard-stubs/carray_rng.rb +92 -0
  250. data/yard-stubs/carray_scatter.rb +12 -3
  251. data/yard-stubs/carray_slab.rb +7 -4
  252. data/yard-stubs/carray_sort.rb +7 -6
  253. data/yard-stubs/carray_test.rb +18 -5
  254. data/yard-stubs/carray_undef.rb +44 -5
  255. data/yard-stubs/ruby_carray.rb +75 -40
  256. metadata +63 -25
  257. data/CHANGELOG.v1.md +0 -126
  258. data/ext/carray_build_flags.h +0 -3
  259. data/ext/carray_config.h +0 -28
  260. data/ext/carray_data_type.c +0 -90
  261. data/ext/carray_kernels_bincmp.c +0 -6457
  262. data/ext/carray_kernels_binop.c +0 -31534
  263. data/ext/carray_kernels_init.c +0 -1734
  264. data/ext/carray_kernels_moncmp.c +0 -2104
  265. data/ext/carray_kernels_monop.c +0 -25387
  266. data/ext/carray_kernels_reduce_aggregate.c +0 -27545
  267. data/ext/carray_kernels_reduce_boolean.c +0 -1924
  268. data/ext/carray_kernels_reduce_cumulative.c +0 -11646
  269. data/ext/carray_kernels_reduce_extreme.c +0 -21631
  270. data/ext/carray_kernels_reduce_variance.c +0 -5981
  271. data/ext/carray_kernels_scan.c +0 -4302
  272. data/ext/carray_kernels_search.c +0 -37776
  273. data/ext/carray_kernels_sort.c +0 -10814
  274. data/ext/carray_kernels_triop.c +0 -1864
  275. data/lib/carray/construct.rb +0 -360
  276. data/lib/carray/data_type_extension.rb +0 -261
  277. data/lib/carray/data_type_limits.rb +0 -91
@@ -6,11 +6,24 @@
6
6
  # In-range cells alias the parent, out-of-range cells take the fill value
7
7
  # (or are masked). {CAShift} is the same view expressed as a translation.
8
8
  class CAWindow < CAView
9
+ # @overload bounds
10
+ # Returns the boundary rule as a Symbol: `:fill`, `:mask`, `:nearest`,
11
+ # `:strict` or `:ruby`. A window made with `fill_value: UNDEF`
12
+ # answers `:mask`. A {CAShift} with `roll:` on some axes has a rule
13
+ # per axis; this answers the rule of axis 0.
14
+ # @return [Symbol]
15
+ def bounds; end
16
+
17
+ # @overload fill_value
18
+ # Returns the value given to out-of-range cells. It is fixed when the
19
+ # window is made; to change it, make the window again.
20
+ # @return [Object]
21
+ def fill_value; end
9
22
  end
10
23
 
11
24
  # Mask companion of {CAWindow}.
12
25
  # @private
13
- class CAWindowMask < CAWindow
26
+ class CAWindow::Mask < CAWindow
14
27
  end
15
28
 
16
29
  class CArray
@@ -25,7 +38,7 @@ class CArray
25
38
  # through `unmask` too.
26
39
  #
27
40
  # A range wider than its axis is how an array is **padded**: `a.window(-1..
28
- # a.dim0, -1..a.dim1)` puts a one-cell border all round, which is NumPy's
41
+ # a.shape[0], -1..a.shape[1])` puts a one-cell border all round, which is NumPy's
29
42
  # `pad` with no allocation (`fill_value:` is its `constant`, `bounds:
30
43
  # :nearest` its `edge`). {#windows} is the different, plural thing: one
31
44
  # such window anchored on every cell, folded.
@@ -33,29 +46,28 @@ class CArray
33
46
  # Only unit-step ranges are accepted, and each range must run forward, so
34
47
  # the `0..-1` end-relative notation cannot be used here.
35
48
  #
36
- # @overload window(*ranges, fill_value: 0, bounds: "fill")
49
+ # @overload window(*ranges, fill_value: 0, bounds: :fill)
37
50
  # @param ranges [Array<Range, Integer>] one range per axis; the count
38
51
  # must equal `self.ndim`.
39
52
  # @param fill_value [Object] value given to out-of-range cells, written
40
53
  # as a store writes it (a Time for a time array; a CAString's default
41
54
  # is `""`); `UNDEF` masks them instead.
42
- # @param bounds [String, Symbol] what an out-of-range index means; a
43
- # Symbol says the same as the String, matching {#windows}: `"fill"`
44
- # (default) uses `fill_value`, `"nearest"` clamps to the edge cell,
45
- # `"ruby"` reads negative indices from the far end, `"strict"` raises.
46
- # `"mask"` masks the cell but warns — pass `fill_value: UNDEF` instead.
55
+ # @param bounds [Symbol] what an out-of-range index means: `:fill`
56
+ # (default) uses `fill_value`, `:nearest` clamps to the edge cell,
57
+ # `:ruby` reads negative indices from the far end, `:strict` raises.
58
+ # To mask the cells outside, pass `fill_value: UNDEF`.
47
59
  # @return [CAWindow]
48
60
  # @raise [ArgumentError] when the number of ranges does not equal `ndim`,
49
- # when a range has a step other than 1 or runs backwards, when a block
50
- # is passed (the block form was removed in 3.0), or when `bounds` is
51
- # `"periodic"` / `"reflect"` (both removed in 3.0; use {#roll} for a
52
- # cyclic shift).
53
- # @raise [ArgumentError] when `bounds` conflicts with `fill_value: UNDEF`,
54
- # or when `bounds` is not a recognised value.
61
+ # when a range has a step other than 1 or runs backwards, or when a
62
+ # block is passed.
63
+ # @raise [ArgumentError] when `fill_value:` is given with a `bounds`
64
+ # other than `:fill`, or when `bounds` is not a recognised value.
65
+ # @raise [TypeError] when `bounds` is not a Symbol.
55
66
  # @raise [IndexError] when `bounds` is `"strict"` and a range reaches
56
67
  # outside `self`, or `"ruby"` and a range reaches past the end or
57
- # before the first cell counted from the end.
58
- def window(*ranges, fill_value: 0, bounds: "fill"); end
68
+ # before the first cell counted from the end, or `"nearest"` and a
69
+ # range takes cells of an axis of length 0.
70
+ def window(*ranges, fill_value: 0, bounds: :fill); end
59
71
 
60
72
  # @!endgroup
61
73
  end
@@ -25,8 +25,24 @@ class CArray
25
25
  # to land in and is discarded.
26
26
  # - `:_` — newaxis: insert a size-1 axis at this position.
27
27
  # - `:%` — repeat / tiling sugar.
28
+ # - `:~` — all the remaining axes.
28
29
  # - `:>` — slab axis: wrap the result in a `CASlabIterator`.
29
- # - a member name Symbol — project a struct field (see `CARecord`).
30
+ # - a member name String — project a struct field (see `CARecord`).
31
+ #
32
+ # Any other one-character Symbol raises IndexError.
33
+ #
34
+ # A single boolean CArray as the whole index selects the cells where it
35
+ # is true, in row-major order, as a 1-D view. It must have the shape
36
+ # of `self`, or be 1-D with as many elements as `self` (a 1-D selector
37
+ # picks by position in the flattened array). A boolean array of any
38
+ # other shape raises ArgumentError -- a transposed one included; use
39
+ # `.flatten` to pick by position on purpose.
40
+ #
41
+ # A Symbol of two characters or more names a predicate: `a[:gt, 0]` is
42
+ # `a[a.gt(0)]`, with the arguments after the Symbol (keywords included)
43
+ # passed to the method. The method must return a boolean array of the
44
+ # shape of `self`; any other answer raises, so that a number, a list of
45
+ # addresses or an array of ranks is never read as an index.
30
46
  #
31
47
  # A single flat Integer (fewer indices than `ndim`) addresses the
32
48
  # array in row-major flat order.
@@ -35,8 +51,12 @@ class CArray
35
51
  # @return [CArray, Object] a view for a slicing form, or the element
36
52
  # value (or `UNDEF` if masked) for an all-scalar index.
37
53
  # @raise [IndexError] on an out-of-range index or an unrecognised form.
38
- # @see file:docs/drafts/02_indexing_and_slicing.md Indexing and slicing
39
- # @see file:docs/drafts/16_indexer_reference.md Indexer reference
54
+ # @raise [TypeError] when a predicate named by a Symbol returns
55
+ # anything but a boolean array.
56
+ # @raise [ArgumentError] when a boolean selector, or the answer of a
57
+ # predicate, has another shape.
58
+ # @see file:guides/users/02_indexing_and_slicing.md Indexing and slicing
59
+ # @see file:docs/topics/Indexer_decision_tree.md Indexer decision tree
40
60
  def [](*index); end
41
61
 
42
62
  # @overload []=(*index, value)
@@ -56,9 +76,36 @@ class CArray
56
76
  # `UNDEF` to mask.
57
77
  # @return [Object] `value`.
58
78
  # @raise [IndexError] on an out-of-range index or an unsupported form.
59
- # @see file:docs/drafts/16_indexer_reference.md Indexer reference
79
+ # @raise [ArgumentError] when a boolean selector has another shape
80
+ # (the rule of {#[]}).
81
+ # @see file:docs/topics/Indexer_decision_tree.md Indexer decision tree
60
82
  def []=(*index, value); end
61
83
 
84
+ # @overload scan_index(shape, index)
85
+ # Classifies an index expression the way {#[]} would read it, for an
86
+ # array of the given shape, without building a view. For authors of
87
+ # wrappers that translate CArray's `[]` syntax into another form.
88
+ # @param shape [Array<Integer>] the shape of the array being indexed.
89
+ # @param index [Array] the arguments that would be passed to {#[]}.
90
+ # @return [CArray::IndexInfo] `type` is a Symbol naming the region
91
+ # type (`:all`, `:address`, `:flatten`, `:address_complex`, `:point`,
92
+ # `:block`, `:select`, `:iterator`, `:repeat`, `:grid`,
93
+ # `:address_array`, `:method_call`, `:member`), `index` is the
94
+ # payload for that type.
95
+ # @see file:docs/topics/Indexer_decision_tree.md Indexer decision tree
96
+ # (every pattern, region and payload format)
97
+ def self.scan_index(shape, index); end
98
+
99
+ # What {CArray.scan_index} returns: the region type an index expression
100
+ # selects and the payload of that type.
101
+ class IndexInfo < Struct
102
+ # @return [Symbol] the region type (`:block`, `:point`, `:grid`, ...).
103
+ attr_accessor :type
104
+
105
+ # @return [Object] the payload of the region type.
106
+ attr_accessor :index
107
+ end
108
+
62
109
  # @!endgroup
63
110
 
64
111
  # @!group Indexing and slicing
@@ -90,7 +137,8 @@ class CArray
90
137
  # or a CArray of such addresses (arbitrary shape). A negative
91
138
  # address counts from the end.
92
139
  # @return [Array<Integer>, Array<CArray>] one entry per axis.
93
- # @raise [IndexError] when any `addr` is out of range.
140
+ # @raise [IndexError] when any `addr` is out of range, or when `addr` is
141
+ # float, complex, object or boolean.
94
142
  def addr2index(addr); end
95
143
 
96
144
  # @overload index2addr(*index)
@@ -101,7 +149,8 @@ class CArray
101
149
  # must match that shape). Mask propagates from the inputs.
102
150
  # @param index [Array<Integer, CArray>] one entry per axis.
103
151
  # @return [Integer, CArray] the flat address(es).
104
- # @raise [IndexError] on an out-of-range index.
152
+ # @raise [IndexError] on an out-of-range index, or an index array that
153
+ # is float, complex, object or boolean.
105
154
  # @raise [ArgumentError] on shape mismatch between non-scalar inputs.
106
155
  def index2addr(*index); end
107
156
 
@@ -6,11 +6,9 @@ class CArray
6
6
  # @!group Attributes
7
7
 
8
8
  # @overload obj_type
9
- # Returns the object-type integer of `self` (e.g. `CA_OBJ_ARRAY`,
10
- # `CA_OBJ_BLOCK`).
11
- #
12
- # Rarely needed in user code; the same information is available
13
- # from `self.class`.
9
+ # Returns the integer that tells the C code what kind of array
10
+ # `self` is (the `CA_OBJ_*` value of the C API). Ruby code asks
11
+ # `self.class` instead.
14
12
  # @return [Integer]
15
13
  def obj_type; end
16
14
 
@@ -81,43 +79,31 @@ class CArray
81
79
  # @return [Array<Integer>]
82
80
  def dim; end
83
81
 
84
- # @overload dim0
85
- # Returns `shape[0]`.
86
- # @return [Integer]
87
- def dim0; end
88
-
89
- # @overload dim1
90
- # Returns `shape[1]`, or `nil` if `ndim < 2`.
91
- # @return [Integer, nil]
92
- def dim1; end
93
-
94
- # @overload dim2
95
- # Returns `shape[2]`, or `nil` if `ndim < 3`.
96
- # @return [Integer, nil]
97
- def dim2; end
98
-
99
- # @overload dim3
100
- # Returns `shape[3]`, or `nil` if `ndim < 4`.
101
- # @return [Integer, nil]
102
- def dim3; end
103
-
104
82
  # @overload parent
105
83
  # Returns the parent CArray of `self`, or `nil` if `self` has no
106
- # parent (i.e. is an entity). For a Face (CATime, CARecord, ...) it
107
- # is a read-only view of the storage; a Face whose storage may be
108
- # written names a method for it (`CATime#ticks`).
84
+ # parent (i.e. is an entity). For a Face (CATime, CARecord, ...,
85
+ # and a Face written in Ruby with `face: true`) it is a read-only
86
+ # view of the storage; a Face whose storage may be written names a
87
+ # method for it (`CATime#ticks`).
88
+ #
89
+ # A view that reads several arrays (a stack, a meld, a lazy
90
+ # expression of two or three operands) returns the first of them
91
+ # here and all of them from `parents`.
109
92
  # @return [CArray, nil]
110
93
  def parent; end
111
94
 
112
95
  # @overload root_array
113
- # Returns the array at the root of the view chain (the entity).
114
- # Returns `self` if `self` is already an entity.
96
+ # Returns the array at the end of the chain of single parents that
97
+ # starts at `self`: an entity, or a view that reads several arrays (a
98
+ # stack, a meld, a lazy expression of two or three operands). Such a
99
+ # view ends the chain, and its `parents` lead on to each of the arrays
100
+ # it reads. Returns `self` if `self` is an entity or such a view.
115
101
  # @return [CArray]
116
102
  def root_array; end
117
103
 
118
104
  # @overload ancestors
119
- # Returns the list of arrays in the view chain, ordered from root
120
- # to `self`.
105
+ # Returns the list of arrays in the chain of single parents, ordered
106
+ # from the root (see {#root_array}) to `self`.
121
107
  # @return [Array<CArray>]
122
108
  def ancestors; end
123
109
 
@@ -148,16 +134,18 @@ class CArray
148
134
  def scalar?; end
149
135
 
150
136
  # @overload entity?
151
- # Returns `true` if `self` is an entity array (not a virtual
152
- # view).
137
+ # Returns `true` if `self` is an entity: an array whose `ptr`
138
+ # always holds its memory. The memory may be its own or, for a
139
+ # {CAWrap}, memory owned elsewhere. The opposite of {#view?}.
153
140
  # @return [Boolean]
154
141
  def entity?; end
155
142
 
156
- # @overload virtual?
157
- # Returns `true` if `self` is a virtual array (a view, not an
158
- # entity).
143
+ # @overload view?
144
+ # Returns `true` if `self` is a view: an array that holds no
145
+ # memory of its own and takes its values from a parent or from a
146
+ # computation. The opposite of {#entity?}.
159
147
  # @return [Boolean]
160
- def virtual?; end
148
+ def view?; end
161
149
 
162
150
  # @overload attached?
163
151
  # Returns `true` if `self` is currently attached