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
data/lib/carray/fusion.rb CHANGED
@@ -117,7 +117,7 @@ class CArray
117
117
  THRESHOLD = 10_000
118
118
 
119
119
  # Returns the array, or nil where nothing computed it.
120
- def self.evaluate (view)
120
+ def self.evaluate(view)
121
121
  plan = worth_asking(view) or return nil
122
122
  out = CArray.__alloc_uninit__(view.data_type, view.shape)
123
123
  ask(plan, out) ? out : nil
@@ -126,7 +126,7 @@ class CArray
126
126
  # Fills an array the caller already has. Called from the store as well,
127
127
  # where making one and copying it over would be most of the work.
128
128
  # Returns true when something computed it.
129
- def self.evaluate_into (view, out)
129
+ def self.evaluate_into(view, out)
130
130
  plan = worth_asking(view) or return false
131
131
  ask(plan, out)
132
132
  end
@@ -136,7 +136,7 @@ class CArray
136
136
  # is the evaluator's doing, so nothing here retires it: an array that
137
137
  # raises when it is looked at (a CAObject whose backing is gone) raises
138
138
  # again in the walk, where the caller sees it.
139
- def self.worth_asking (view)
139
+ def self.worth_asking(view)
140
140
  return nil unless askable?(view)
141
141
  plan = plan(view) or return nil
142
142
  plan.nodes.any? { |n| n.is_a?(Op) } ? plan : nil
@@ -144,7 +144,7 @@ class CArray
144
144
  nil
145
145
  end
146
146
 
147
- def self.ask (plan, out)
147
+ def self.ask(plan, out)
148
148
  evaluator = CArray.expression_evaluator or return false
149
149
  return false if overlaps?(plan, out)
150
150
  return false unless ready_mask(plan, out)
@@ -164,7 +164,7 @@ class CArray
164
164
  # destination that arrives masked loses its mask to an expression that
165
165
  # has none. A destination that cannot hold a mask (a value array) is
166
166
  # left to the walk, which says so.
167
- def self.ready_mask (plan, out)
167
+ def self.ready_mask(plan, out)
168
168
  if plan.masked
169
169
  out.mask = 0 unless out.has_mask?
170
170
  elsif out.has_mask?
@@ -181,7 +181,7 @@ class CArray
181
181
  # reads what it has just written. The walk reads every operand before
182
182
  # it writes. The destination itself as a leaf is fine as long as it is
183
183
  # read at the cell being written, not shifted.
184
- def self.overlaps? (plan, out)
184
+ def self.overlaps?(plan, out)
185
185
  mine = storages(out)
186
186
  shifted = plan.nodes.grep(Shifted).map(&:index)
187
187
  plan.leaves.each_with_index.any? do |leaf, index|
@@ -197,7 +197,7 @@ class CArray
197
197
  # where a view stands over several. Two of them share storage when
198
198
  # they are one array, or entities whose memory overlaps (an array and a
199
199
  # wrap_memory_view of it).
200
- def self.storages (array, found = [])
200
+ def self.storages(array, found = [])
201
201
  root = array.root_array
202
202
  if ! root.entity? && root.respond_to?(:parents)
203
203
  root.parents.each { |parent| storages(parent, found) }
@@ -207,26 +207,26 @@ class CArray
207
207
  found
208
208
  end
209
209
 
210
- def self.retire (error)
210
+ def self.retire(error)
211
211
  CArray.expression_evaluator = nil
212
212
  warn "CArray: the registered expression evaluator raised " \
213
213
  "(#{error.class}: #{error.message}); expressions will be walked " \
214
214
  "from here on"
215
215
  end
216
216
 
217
- def self.askable? (view)
217
+ def self.askable?(view)
218
218
  ! CArray.expression_evaluator.nil? && view.elements >= THRESHOLD
219
219
  end
220
220
 
221
221
  # Returns a Plan, or nil where the expression holds something a plan
222
222
  # cannot describe. Refusing is ordinary: the caller walks instead.
223
- def self.plan (view)
223
+ def self.plan(view)
224
224
  build(view)
225
225
  rescue Refused
226
226
  nil
227
227
  end
228
228
 
229
- def self.build (view)
229
+ def self.build(view)
230
230
  raise Refused, "not a lazy expression" unless lazy?(view)
231
231
  w = Walk.new
232
232
  w.visit(view)
@@ -235,7 +235,7 @@ class CArray
235
235
  Plan.new(w.nodes, w.leaves, view.data_type, view.shape, masked, w.signature)
236
236
  end
237
237
 
238
- def self.lazy? (x)
238
+ def self.lazy?(x)
239
239
  LAZY_CLASSES.any? { |k| x.is_a?(k) }
240
240
  end
241
241
 
@@ -252,13 +252,13 @@ class CArray
252
252
  @signature = +""
253
253
  end
254
254
 
255
- def visit (n)
255
+ def visit(n)
256
256
  @seen[n.object_id] ||= build(n)
257
257
  end
258
258
 
259
259
  private
260
260
 
261
- def build (n)
261
+ def build(n)
262
262
  case n
263
263
  when CALazyMarker then visit(n.parent)
264
264
  when CAMonOp then unary(n)
@@ -273,7 +273,7 @@ class CArray
273
273
  end
274
274
  end
275
275
 
276
- def unary (n)
276
+ def unary(n)
277
277
  return conversion(n) if n.__op_id__ >= CAMonOp::CAST_BASE
278
278
  name = spell(MONOP_BY_ID, n.__op_id__, {})
279
279
  args = [visit(n.parent)]
@@ -284,7 +284,7 @@ class CArray
284
284
 
285
285
  # A cast node is named by the type it converts to, cast_<data_type>,
286
286
  # and its body is keyed by the type it converts from.
287
- def conversion (n)
287
+ def conversion(n)
288
288
  from = n.parent.data_type
289
289
  name = :"cast_#{n.data_type}"
290
290
  body = CArray.__kernel_body__(:monop, name, from) or
@@ -294,7 +294,7 @@ class CArray
294
294
  push Op.new(:monop, name, n.data_type, args, body, :pass, n.__trapping__)
295
295
  end
296
296
 
297
- def binary (n)
297
+ def binary(n)
298
298
  name = spell(BINOP_BY_ID, n.__op_id__, BINOP_NAMES)
299
299
  args = [visit(n.parent), visit(n.__binop_right__)]
300
300
  # Boolean `&` and `|` are three-valued: a masked cell whose known
@@ -306,7 +306,7 @@ class CArray
306
306
  op(:binop, name, n.data_type, args, rule, n.__trapping__)
307
307
  end
308
308
 
309
- def ternary (n)
309
+ def ternary(n)
310
310
  name = spell(TRIOP_BY_ID, n.__op_id__, TRIOP_NAMES)
311
311
  args = [visit(n.parent), visit(n.__triop_op2__), visit(n.__triop_op3__)]
312
312
  # select is masked where its condition is, or where the branch the
@@ -317,14 +317,14 @@ class CArray
317
317
 
318
318
  # A comparison is masked where its operands are (ca_obj_moncmp.c,
319
319
  # ca_obj_bincmp.c): there is no three-valued comparison.
320
- def unary_comparison (n)
320
+ def unary_comparison(n)
321
321
  name = spell(MONCMP_BY_ID, n.__op_id__, {})
322
322
  operand = n.parent
323
323
  args = [visit(operand)]
324
324
  comparison(:moncmp, name, operand.data_type, args, :pass, n.__trapping__)
325
325
  end
326
326
 
327
- def binary_comparison (n)
327
+ def binary_comparison(n)
328
328
  name = spell(BINCMP_BY_ID, n.__op_id__, {})
329
329
  right = n.__bincmp_right__
330
330
  # Both sides are already of the type compared (CABinCmp casts one
@@ -339,7 +339,7 @@ class CArray
339
339
  # `trapping`: the node skips the cells its operands mask rather than
340
340
  # computing them -- one that can raise on a cell or calls Ruby for it.
341
341
  # Each lazy view answers it from the rule its own kernel follows.
342
- def comparison (kind, name, compared, args, mask, trapping)
342
+ def comparison(kind, name, compared, args, mask, trapping)
343
343
  body = CArray.__kernel_body__(kind, name, compared) or
344
344
  raise Refused, "#{kind} #{name} has no body at #{compared}"
345
345
  # A body written against its compared type or a tolerance (`feq`)
@@ -351,14 +351,14 @@ class CArray
351
351
  push Op.new(kind, name, :boolean, args, body, mask, trapping)
352
352
  end
353
353
 
354
- def op (kind, name, type, args, mask, trapping)
354
+ def op(kind, name, type, args, mask, trapping)
355
355
  body = CArray.__kernel_body__(kind, name, type) or
356
356
  raise Refused, "#{kind} #{name} has no body at #{type}"
357
357
  note(kind.to_s[0], name, type, args.join(","))
358
358
  push Op.new(kind, name, type, args, body, mask, trapping)
359
359
  end
360
360
 
361
- def leaf (n)
361
+ def leaf(n)
362
362
  index = leaf_index(n)
363
363
  note("a", index, n.data_type, n.has_mask? ? 1 : 0)
364
364
  push Leaf.new(index, n.data_type, n.has_mask?)
@@ -367,7 +367,7 @@ class CArray
367
367
  # A shift of an array is that array read elsewhere, so it is the
368
368
  # array that becomes a leaf. A shift of anything else -- an
369
369
  # expression, say -- has no array to read and is taken as a whole.
370
- def shifted (n)
370
+ def shifted(n)
371
371
  array = n.parent
372
372
  bounds = n.__boundary_rule_of_each_axis__
373
373
  if Fusion.lazy?(array) || array.shape != n.shape ||
@@ -387,7 +387,7 @@ class CArray
387
387
 
388
388
  # A leaf the address bases would refuse to lend cannot be read by an
389
389
  # evaluator, so the expression is not described.
390
- def leaf_index (array)
390
+ def leaf_index(array)
391
391
  @leaf_index.fetch(array.object_id) do
392
392
  if (reason = AddressBasis.classify(array)[:refusal])
393
393
  raise Refused, "a leaf: #{reason}"
@@ -398,25 +398,25 @@ class CArray
398
398
  end
399
399
 
400
400
  # A masked scalar has no value to write into the expression.
401
- def constant (n)
401
+ def constant(n)
402
402
  raise Refused, "a masked scalar" if n.has_mask? && n.is_masked[0]
403
403
  value = n[0]
404
404
  note("k", value.inspect, n.data_type)
405
405
  push Const.new(value, n.data_type)
406
406
  end
407
407
 
408
- def as_cell (value, data_type)
408
+ def as_cell(value, data_type)
409
409
  cell = CScalar.new(data_type)
410
410
  cell[0] = value
411
411
  cell[0]
412
412
  end
413
413
 
414
- def push (node)
414
+ def push(node)
415
415
  @nodes << node
416
416
  @nodes.size - 1
417
417
  end
418
418
 
419
- def spell (table, id, renames)
419
+ def spell(table, id, renames)
420
420
  ruby = table[id] or raise Refused, "operation id #{id}"
421
421
  renames.fetch(ruby, ruby)
422
422
  end
@@ -425,7 +425,7 @@ class CArray
425
425
  # they are over, so a consumer can keep one compiled kernel for both.
426
426
  # The shape includes which node each operation reads and which leaf
427
427
  # each read is: `(a - b) - b` and `(a - b) - a` differ only there.
428
- def note (*parts)
428
+ def note(*parts)
429
429
  @signature << parts.join(":") << ";"
430
430
  end
431
431
  end
@@ -43,7 +43,7 @@
43
43
  # closed, right-open). See `include_max:` for the upper-edge variant.
44
44
  # * **bin** — half-open interval between two consecutive edges. Bin index
45
45
  # k in 0..N-1.
46
- # * **N** (= n_list[k]) — number of bins along dimension k (= edges.size - 1).
46
+ # * **N** — number of bins along dimension k (= edges.size - 1).
47
47
  # * **midpoints** — bin center points: `(edges[0..-2] + edges[1..-1]) / 2`,
48
48
  # shape (N,). Returned per-dim (single CArray for M=1, Array of M for M>=2).
49
49
  #
@@ -144,12 +144,13 @@ class CArray
144
144
  # (non-sample, non-channel) axes.
145
145
  # @param include_max [Boolean, Array<Boolean>] whether values
146
146
  # equal to the last edge fold into the last bin; a scalar
147
- # broadcasts across dimensions.
147
+ # broadcasts across dimensions. Off by default: the edges are bin
148
+ # bounds, each bin half-open.
148
149
  # @param weights_data_type [Symbol, nil] `data_type` of the
149
150
  # accumulator when weighted; `nil` for a count-only
150
151
  # accumulator (int64 counts).
151
152
  # @return [Histogram]
152
- def initialize (edges:, fiber_shape: [], include_max: false, weights_data_type: nil)
153
+ def initialize(edges:, fiber_shape: [], include_max: false, weights_data_type: nil)
153
154
  @edges_list = edges.map { |e| CArray.wrap_readonly(e, :float64) }
154
155
  raise ArgumentError, "edges must be a non-empty list" if @edges_list.empty?
155
156
  @edges_list.each_with_index do |e, k|
@@ -162,9 +163,9 @@ class CArray
162
163
  @include_max = case include_max
163
164
  when Array
164
165
  raise ArgumentError, "include_max length mismatch" unless include_max.size == @m
165
- include_max.map { |v| !!v }
166
+ include_max.map { |v| CArray.send(:bool_arg, v, "include_max", "histogram") }
166
167
  else
167
- [!!include_max] * @m
168
+ [CArray.send(:bool_arg, include_max, "include_max", "histogram")] * @m
168
169
  end
169
170
  @weighted = !weights_data_type.nil?
170
171
  @counts_data_type = @weighted ? weights_data_type : :int64
@@ -176,7 +177,12 @@ class CArray
176
177
  end
177
178
  private_class_method :new
178
179
 
179
- attr_reader :edges_list, :fiber_shape, :include_max, :n_list, :full_counts, :m
180
+ attr_reader :edges_list, :fiber_shape, :include_max, :full_counts
181
+
182
+ # Read by #+ from the other accumulator. The number of bins on each
183
+ # dimension is counts.shape after fiber_shape.
184
+ attr_reader :m
185
+ protected :m
180
186
 
181
187
  # @overload edges
182
188
  # Returns the bin edges: a single CArray when the accumulator
@@ -203,7 +209,7 @@ class CArray
203
209
  # @param axis [Integer, nil] bin dimension to marginalise.
204
210
  # @return [CArray]
205
211
  # @raise [ArgumentError] when `axis` is required but omitted.
206
- def under (axis: nil)
212
+ def under(axis: nil)
207
213
  raise ArgumentError, "axis: keyword required (M=#{@m})" if axis.nil? && @m > 1
208
214
  ax = axis.nil? ? 0 : CArray.normalize_axis(axis, @m, "under")
209
215
  outlier_marginal(ax, 0)
@@ -215,7 +221,7 @@ class CArray
215
221
  # @param axis [Integer, nil] bin dimension to marginalise.
216
222
  # @return [CArray]
217
223
  # @raise [ArgumentError] when `axis` is required but omitted.
218
- def over (axis: nil)
224
+ def over(axis: nil)
219
225
  raise ArgumentError, "axis: keyword required (M=#{@m})" if axis.nil? && @m > 1
220
226
  ax = axis.nil? ? 0 : CArray.normalize_axis(axis, @m, "over")
221
227
  outlier_marginal(ax, -1)
@@ -231,6 +237,17 @@ class CArray
231
237
  @m == 1 ? arr[0] : arr
232
238
  end
233
239
 
240
+ # @overload inspect
241
+ # Returns the class, the data type and shape of {#counts}, and
242
+ # either {#fiber_shape} or, with no fiber axes, the sample {#total}.
243
+ # The counts themselves are not shown.
244
+ # @return [String]
245
+ def inspect
246
+ c = counts
247
+ tail = @fiber_shape.empty? ? "total=#{total}" : "fiber_shape=#{@fiber_shape}"
248
+ "#<#{self.class} counts=#{c.data_type_name}#{c.shape} #{tail}>"
249
+ end
250
+
234
251
  # @overload total
235
252
  # Returns the per-fiber sample total, including outliers, with
236
253
  # shape `fiber_shape` (or a scalar when `fiber_shape` is
@@ -263,7 +280,7 @@ class CArray
263
280
  # @return [self]
264
281
  # @raise [ArgumentError] on shape / axis / weighted-state
265
282
  # mismatch.
266
- def add (chunk, axis: nil, weights: nil)
283
+ def add(chunk, axis: nil, weights: nil)
267
284
  chunk = CArray.wrap_readonly(chunk, :float64)
268
285
 
269
286
  # For M=1, accept chunks without the trailing channel axis (= the 1-D
@@ -321,6 +338,7 @@ class CArray
321
338
 
322
339
  if weights
323
340
  raise ArgumentError, "weights given but accumulator is unweighted" unless @weighted
341
+ CArray.send(:refuse_ruby_array, "histogram", "a weight array") if weights.is_a?(Array)
324
342
  # coerce: the accumulator's type, declared by weights_data_type:
325
343
  weights = CArray.wrap_readonly(weights, @counts_data_type)
326
344
  expected_w_shape = chunk.shape.dup
@@ -365,7 +383,7 @@ class CArray
365
383
  # @param other [Histogram] compatible accumulator.
366
384
  # @return [Histogram]
367
385
  # @raise [ArgumentError] when the structure does not match.
368
- def + (other)
386
+ def +(other)
369
387
  # --- semantic guards: structure must match exactly ---------------
370
388
  raise ArgumentError, "type mismatch" unless other.is_a?(Histogram)
371
389
  raise ArgumentError, "M mismatch" unless @m == other.m
@@ -406,7 +424,7 @@ class CArray
406
424
  # unlike `sum` which always lifts to float64. Caveat: int64 overflows at
407
425
  # ~9.2e18 (silent wrap); weighted float64 loses precision past 2^53 but
408
426
  # does not overflow. Realistic histograms do not hit these limits.
409
- def sum_along_bin_axes (arr)
427
+ def sum_along_bin_axes(arr)
410
428
  out = arr
411
429
  @m.times { out = out.accumulate(axis: out.ndim - 1) }
412
430
  out
@@ -415,7 +433,7 @@ class CArray
415
433
  # axis k of the bin dims (= which channel's outlier to look at).
416
434
  # offset = 0 (under) or -1 (over). Other bin axes are marginalised away
417
435
  # (= including their outlier positions).
418
- def outlier_marginal (axis, offset)
436
+ def outlier_marginal(axis, offset)
419
437
  base = [nil] * @fiber_shape.size
420
438
  bin_idx = (0...@m).map { |k|
421
439
  if k == axis
@@ -444,10 +462,11 @@ class CArray
444
462
  # @param edges [CArray, Array<Numeric>] 1-D ascending bin edges.
445
463
  # @param axis [Integer] sample axis.
446
464
  # @param include_max [Boolean] fold last-edge equality into the
447
- # last bin.
465
+ # last bin. Off by default: each bin is half-open.
448
466
  # @param weights [CArray, nil] optional per-sample weights.
449
467
  # @return [Histogram] 1-D accumulator (`m == 1`).
450
- def histogram1d (edges:, axis: -1, include_max: false, weights: nil)
468
+ def histogram1d(edges:, axis: -1, include_max: false, weights: nil)
469
+ include_max = CArray.send(:bool_arg, include_max, "include_max", "histogram1d")
451
470
  ax = normalize_axis(axis.nil? ? -1 : axis, "histogram1d")
452
471
 
453
472
  new_shape = shape + [1]
@@ -472,7 +491,7 @@ class CArray
472
491
  # @param weights [CArray, nil] optional per-sample weights.
473
492
  # @return [Histogram] 2-D accumulator (`m == 2`).
474
493
  # @raise [ArgumentError] when `edges` is not a length-2 Array.
475
- def histogram2d (edges:, axis: [-2, -1], include_max: false, weights: nil)
494
+ def histogram2d(edges:, axis: [-2, -1], include_max: false, weights: nil)
476
495
  raise ArgumentError, "edges must be a list of 2" unless edges.is_a?(Array) && edges.size == 2
477
496
  histogram(edges: edges, axis: axis, include_max: include_max, weights: weights)
478
497
  end
@@ -489,7 +508,7 @@ class CArray
489
508
  # @param weights [CArray, nil] optional per-sample weights.
490
509
  # @return [Histogram]
491
510
  # @raise [ArgumentError] when `edges` is not an Array.
492
- def histogram (edges:, axis: [-2, -1], include_max: false, weights: nil)
511
+ def histogram(edges:, axis: [-2, -1], include_max: false, weights: nil)
493
512
  raise ArgumentError, "edges must be an Array of edges arrays" unless edges.is_a?(Array)
494
513
  arr = self
495
514
  axis = [-2, -1] if axis.nil?
@@ -2,7 +2,7 @@ require "pp" # CArray#source_code uses Array#pretty_inspect
2
2
 
3
3
  class CArray::Inspector # :nodoc:
4
4
 
5
- def initialize (carray)
5
+ def initialize(carray)
6
6
  @carray = carray
7
7
  end
8
8
 
@@ -12,7 +12,7 @@ class CArray::Inspector # :nodoc:
12
12
  # It is the one difference between #inspect and #inspect_full: the
13
13
  # header and the layout are the same, so there is one renderer rather
14
14
  # than two that could drift apart.
15
- def inspect_string (abbrev: true)
15
+ def inspect_string(abbrev: true)
16
16
  if @carray.ndim == 0
17
17
  raise "can't inspect CArray of ndim == 0"
18
18
  end
@@ -53,11 +53,11 @@ class CArray::Inspector # :nodoc:
53
53
  # Face by its name (face_label), any other array by its data type name.
54
54
  # Every message and listing that names a type goes through here, so a
55
55
  # Face is never named by its storage (:fixlen for a time).
56
- def self.type_label (ca)
56
+ def self.type_label(ca)
57
57
  ca.face? ? face_label(ca) : CArray.data_type_name(ca.data_type).to_s
58
58
  end
59
59
 
60
- def self.face_label (ca)
60
+ def self.face_label(ca)
61
61
  return ca.send(:inspect_label) if ca.respond_to?(:inspect_label, true)
62
62
  klass = ca.class
63
63
  klass = klass.superclass while klass.name.nil?
@@ -130,7 +130,7 @@ class CArray::Inspector # :nodoc:
130
130
  list << "ro"
131
131
  end
132
132
  # ---
133
- if virtual? and attached?
133
+ if view? and attached?
134
134
  list << "attached"
135
135
  end
136
136
  # ---
@@ -152,7 +152,7 @@ class CArray::Inspector # :nodoc:
152
152
  # to do with the storage data_type, so the formatter must follow the decoded
153
153
  # value, not the storage. Faces without the hook (CAString) hand back the
154
154
  # stored value itself and fall through to the storage formatters below.
155
- if @carray.face? and @carray.respond_to?(:storage_to_element)
155
+ if @carray.face? and @carray.respond_to?(:storage_to_element, true)
156
156
  return lambda { |x| x.inspect }
157
157
  end
158
158
  data_type = @carray.data_type
@@ -192,7 +192,7 @@ class CArray::Inspector # :nodoc:
192
192
  end
193
193
  end
194
194
 
195
- def get_data_spec (level, idx, formatter, abbrev = true)
195
+ def get_data_spec(level, idx, formatter, abbrev = true)
196
196
  io = +"[ " # mutable buffer; `<<` below appends into it
197
197
  ndim = @carray.ndim
198
198
  dim = @carray.shape
@@ -8,11 +8,11 @@
8
8
  # implement (surface uniformity is the value: "this is an iterator, so it must
9
9
  # answer these").
10
10
  #
11
- # `shape` is canonical; `dim` is a legacy alias. A member exposes what it
12
- # actually holds (source / reference / labels) and adds its own methods
13
- # (min_index / max_index / map / correlate / convolve / sort_addr / ...);
14
- # those are NOT part of the common contract because some members legitimately
15
- # omit them (a window has no map, a group has no within-piece min_index).
11
+ # A member exposes what it actually holds (source / reference / labels) and
12
+ # adds its own methods (min_index / max_index / map / correlate / convolve /
13
+ # sort_addr / ...); those are NOT part of the common contract because some
14
+ # members legitimately omit them (a window has no map, a group has no
15
+ # within-piece min_index).
16
16
  #
17
17
  # The 2.0 generic dispatch (calculate / filter / evaluate over a
18
18
  # kernel_at_addr slot) was retired in 3.0.
@@ -27,22 +27,27 @@ class CAIterator
27
27
  # that a member does not define is a clean NoMethodError, not a wrong answer.
28
28
 
29
29
  attr_reader :ndim, :shape
30
- alias dim shape
30
+
31
+ # @overload source
32
+ # Returns the array the iterator was made from: the array being
33
+ # sliced, tiled, rolled over, grouped or split into segments.
34
+ # @return [CArray]
35
+ attr_reader :source
31
36
 
32
37
  # The keywords a member passes on to a core reduction over its own axes.
33
38
  # The member sets `axis:`, so one from the caller is refused; the rest go
34
39
  # to the core, which checks them.
35
- # Whether a fill method carries values backward: :forward / :ffill carry
36
- # them forward, :backward / :bfill back. A member fills within its own
40
+ # Whether a fill method carries values backward: :forward carries them
41
+ # forward, :backward back. A member fills within its own
37
42
  # pieces by holding the nearest present value; :linear, which needs a
38
43
  # coordinate, is the core's alone.
39
- def self.hold_backward? (method) # :nodoc:
44
+ private_class_method def self.hold_backward?(method) # :nodoc:
40
45
  case method
41
- when :forward, :ffill then false
42
- when :backward, :bfill then true
46
+ when :forward then false
47
+ when :backward then true
43
48
  else
44
49
  raise ArgumentError,
45
- "strip_mask: method must be :forward, :ffill, :backward or :bfill " \
50
+ "strip_mask: method must be :forward or :backward " \
46
51
  "within a piece (got #{method.inspect})"
47
52
  end
48
53
  end
@@ -58,12 +63,12 @@ class CAIterator
58
63
  # is asked with the blank cell its resize gives, so a reduction over no
59
64
  # groups answers in the same kind as over some; this is nil only when the
60
65
  # Face has no blank cell.
61
- def self.core_probe (value) # :nodoc:
66
+ private_class_method def self.core_probe(value) # :nodoc:
62
67
  unless value.face?
63
68
  return CArray.new(value.data_type, [1, 1], bytes: value.bytes)
64
69
  end
65
70
  flat = value.reshape(value.elements)
66
- return flat[[0]].reshape(1, 1) if value.elements > 0
71
+ return flat[0..0].reshape(1, 1) if value.elements > 0
67
72
  begin
68
73
  flat.resize(1).reshape(1, 1)
69
74
  rescue StandardError
@@ -71,13 +76,44 @@ class CAIterator
71
76
  end
72
77
  end
73
78
 
79
+ # Below 2**53 every integer is a float64, so a float64 running sum or
80
+ # product of integers is exact while every running value stays below it.
81
+ EXACT_RUNNING_IN_FLOAT64 = 2.0 ** 53
82
+ private_constant :EXACT_RUNNING_IN_FLOAT64
83
+
84
+ # Whether +op+ is a running sum or product of an integer value, which the
85
+ # core answers in int64 / uint64, or float64 where a running value is out
86
+ # of range (+answer+ is the core's scan of one cell).
87
+ private_class_method def self.integer_running?(op, value, answer) # :nodoc:
88
+ (op == :cumsum || op == :cumprod) && value.integer? && !value.face? && answer.integer?
89
+ end
90
+
91
+ # A fused scan kernel's float64 running values +out+ of an integer value,
92
+ # in the core's type when every one is below 2**53 (so exact); otherwise
93
+ # the block answers, piece by piece through the core.
94
+ private_class_method def self.integer_running(out, answer) # :nodoc:
95
+ # coerce: the core's type for the answer, which the exact float64 values fit
96
+ out.abs.lt(EXACT_RUNNING_IN_FLOAT64).all ? out.to_type(answer.data_type) : yield
97
+ end
98
+
99
+ # +out+, widened to float64 when +answer+ (a piece's running values from
100
+ # the core) is float64 and +out+ is an integer array: one running value out
101
+ # of range makes the whole answer float64, as it does for the core.
102
+ private_class_method def self.widen_for_running(out, answer) # :nodoc:
103
+ if answer.is_a?(CArray) && answer.float? && out.integer?
104
+ out.to_type(CA_FLOAT64)
105
+ else
106
+ out
107
+ end
108
+ end
109
+
74
110
  # A member that keeps what it built from its source's values or mask (a
75
111
  # padded copy, the views over it, counts of the cells present) names those
76
112
  # instance variables here. They are dropped when a public method of the
77
113
  # member is entered from outside, so every call reads the source as it is
78
114
  # then; within one call the helpers it runs share them. What follows from
79
115
  # the source's shape alone is kept for good.
80
- def self.read_source_per_call (*state)
116
+ def self.read_source_per_call(*state)
81
117
  names = public_instance_methods(false)
82
118
  prepend(Module.new do
83
119
  module_eval(<<~RUBY, __FILE__, __LINE__ + 1)
@@ -87,7 +123,7 @@ class CAIterator
87
123
  RUBY
88
124
  names.each do |name|
89
125
  module_eval(<<~RUBY, __FILE__, __LINE__ + 1)
90
- def #{name} (...)
126
+ def #{name}(...)
91
127
  return super if @reading_source
92
128
  forget_source_state
93
129
  @reading_source = true
@@ -103,7 +139,27 @@ class CAIterator
103
139
  end
104
140
  private_class_method :read_source_per_call
105
141
 
106
- def self.reduce_keywords (op, kw) # :nodoc:
142
+ # percentile with every form of p CArray#percentile takes: `answer` gives
143
+ # the answer for one p, and the answers come back in the form p was
144
+ # written in, as CArray#percentile returns them.
145
+ private_class_method def self.percentile_in_form(pers) # :nodoc:
146
+ list, form = CArray.send(:percentile_arguments, pers)
147
+ CArray.send(:percentile_answer, list.map { |p| yield(p) }, form)
148
+ end
149
+
150
+ # quantile takes no p, as CArray#quantile takes none.
151
+ private_class_method def self.refuse_quantile_arguments(args, kw = {}) # :nodoc:
152
+ unless kw.empty?
153
+ raise ArgumentError,
154
+ "unknown keyword#{kw.size > 1 ? "s" : ""}: #{kw.keys.map(&:inspect).join(", ")}"
155
+ end
156
+ return if args.empty?
157
+ raise ArgumentError,
158
+ "quantile: takes no positional arguments (got #{args.size}); " \
159
+ "for the value at p percent, use percentile(p)"
160
+ end
161
+
162
+ private_class_method def self.reduce_keywords(op, kw) # :nodoc:
107
163
  if kw.key?(:axis)
108
164
  raise ArgumentError, "#{op}: unknown keyword: :axis (the iterator sets the axes)"
109
165
  end
@@ -256,6 +312,31 @@ class CAIterator
256
312
  end))
257
313
  end
258
314
 
315
+ # CArray#count over a view: CABlock / CAWindow shadow #count with a geometry
316
+ # accessor, so it is dispatched explicitly, while a Face keeps a #count of
317
+ # its own (CAConstString reads its cells as Strings).
318
+ # The three-valued fold of `all` / `any` (skip_masked: false) from the
319
+ # two-valued answer `r` and the count of masked cells `cm`, piece by
320
+ # piece, as CArray#all / #any compose it: a masked cell leaves a piece
321
+ # UNDEF unless a present cell settles it (a false for all, a true for
322
+ # any).
323
+ private def kleene_settle(kind, r, cm)
324
+ unless r.is_a?(CArray)
325
+ settled = ( kind == :any ) ? r : !r
326
+ return ( settled || cm == 0 ) ? r : UNDEF
327
+ end
328
+ settled = ( kind == :any ) ? r : r.not
329
+ out = r.copy
330
+ unsettled = settled.not & cm.gt(0)
331
+ out[unsettled] = UNDEF if unsettled.any
332
+ out
333
+ end
334
+
335
+ private def count_cells(view, *args, **kw)
336
+ return view.count(*args, **kw) if view.face?
337
+ CArray.instance_method(:count).bind_call(view, *args, **kw)
338
+ end
339
+
259
340
  # Recommended (should) surface -- template methods. These are well-defined
260
341
  # for some members and structurally impossible for others, so they are not
261
342
  # required: `map` is a per-piece element-wise transform scattered back to the
@@ -318,19 +399,19 @@ class CAIterator
318
399
  # cell has no single position within a piece.
319
400
  # @!method strip_mask(method:)
320
401
  # Returns a source-shaped array with each masked cell filled from its own
321
- # piece, as `CArray#strip_mask(method:)` fills: `:forward` (`:ffill`)
322
- # carries the last present value forward, `:backward` (`:bfill`) the next
402
+ # piece, as `CArray#strip_mask(method:)` fills: `:forward`
403
+ # carries the last present value forward, `:backward` the next
323
404
  # one back, never across into another piece.
324
- # @param method [Symbol] `:forward`, `:ffill`, `:backward` or `:bfill`.
405
+ # @param method [Symbol] `:forward` or `:backward`.
325
406
  # @return [CArray] shaped like the source.
326
407
  # @raise [NotImplementedError] for a member whose pieces overlap.
327
- # @!method order(descending: false, method: :ordinal, kind: :quick)
408
+ # @!method rank_index(descending: false, method: :ordinal, kind: :quick)
328
409
  # Returns a source-shaped int64 array of each cell's rank among the cells
329
- # of its piece, as `CArray#order` ranks them (`0` the smallest).
410
+ # of its piece, as `CArray#rank_index` ranks them (`0` the smallest).
330
411
  # @return [CArray] shaped like the source.
331
412
  # @raise [NotImplementedError] for a member whose pieces overlap, where a
332
413
  # cell has no single rank.
333
- [:map, :sort_addr, :order, :strip_mask,
414
+ [:map, :sort_addr, :rank_index, :strip_mask,
334
415
  :cumsum, :cumprod, :cummax, :cummin, :cumcount, :lag].each do |name|
335
416
  # define_method: a stub that names itself in its own message
336
417
  define_method(name, &Ractor.make_shareable(proc do |*, **, &_blk|