carray 3.0.7 → 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 (275) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -1
  3. data/CHANGELOG.md +7 -1940
  4. data/README.md +38 -32
  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 +6 -9
  11. data/ext/ca_bincmp_dispatch.h +16 -38
  12. data/ext/ca_binop_dispatch.c +27 -0
  13. data/ext/ca_binop_dispatch.h +22 -47
  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 -1506
  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 +90 -163
  28. data/ext/ca_obj_bincmp.c +47 -46
  29. data/ext/ca_obj_binop.c +38 -38
  30. data/ext/ca_obj_bitarray.c +5 -17
  31. data/ext/ca_obj_bitfield.c +15 -30
  32. data/ext/ca_obj_block.c +11 -12
  33. data/ext/ca_obj_byte_swap.c +32 -30
  34. data/ext/ca_obj_const_string.c +57 -62
  35. data/ext/ca_obj_face.c +99 -91
  36. data/ext/ca_obj_face.h +32 -170
  37. data/ext/ca_obj_fake.c +15 -21
  38. data/ext/ca_obj_farray.c +7 -9
  39. data/ext/ca_obj_field.c +17 -13
  40. data/ext/ca_obj_fixlen_string.c +8 -19
  41. data/ext/ca_obj_grid.c +137 -106
  42. data/ext/ca_obj_meld.c +23 -21
  43. data/ext/ca_obj_moncmp.c +10 -21
  44. data/ext/ca_obj_monop.c +24 -35
  45. data/ext/ca_obj_object.c +51 -37
  46. data/ext/ca_obj_record.c +74 -22
  47. data/ext/ca_obj_reduce.c +8 -10
  48. data/ext/ca_obj_refer.c +42 -29
  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 +18 -24
  52. data/ext/ca_obj_select.c +10 -22
  53. data/ext/ca_obj_select_axis.c +27 -36
  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 +28 -24
  57. data/ext/ca_obj_stride.c +53 -54
  58. data/ext/ca_obj_string.c +6 -18
  59. data/ext/ca_obj_tile.c +12 -12
  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 +35 -39
  64. data/ext/ca_obj_window.c +67 -86
  65. data/ext/ca_op_cmplx64.h +4 -0
  66. data/ext/ca_op_ipower.c +34 -12
  67. data/ext/ca_op_powi.h +4 -0
  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 +20 -26
  72. data/ext/ca_sweep_engine.c +2 -3
  73. data/ext/ca_sweep_engine.h +17 -9
  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 +11 -11
  77. data/ext/carray.h +300 -1011
  78. data/ext/carray_access.c +234 -180
  79. data/ext/carray_address_basis.c +33 -38
  80. data/ext/carray_attribute.c +81 -104
  81. data/ext/carray_bincount.c +12 -14
  82. data/ext/carray_broadcast.c +30 -26
  83. data/ext/carray_call_cfunc.c +169 -277
  84. data/ext/carray_call_cfunc.h +36 -28
  85. data/ext/carray_cast.c +912 -346
  86. data/ext/carray_cast_func.rb +31 -3
  87. data/ext/carray_class.c +6 -11
  88. data/ext/carray_conversion.c +43 -38
  89. data/ext/carray_copy.c +28 -26
  90. data/ext/carray_core.c +217 -126
  91. data/ext/carray_count.c +27 -15
  92. data/ext/carray_element.c +40 -25
  93. data/ext/carray_factorize.c +53 -52
  94. data/ext/carray_generate.c +26 -19
  95. data/ext/carray_histogram.c +8 -10
  96. data/ext/carray_hold.c +7 -9
  97. data/ext/carray_index_classifier.c +123 -228
  98. data/ext/carray_index_classifier.h +11 -10
  99. data/ext/carray_integer_total.c +523 -0
  100. data/ext/carray_internal.h +1274 -160
  101. data/ext/carray_key_windows.c +3 -3
  102. data/ext/carray_lazy.c +21 -36
  103. data/ext/carray_loop.c +19 -22
  104. data/ext/carray_mask.c +123 -145
  105. data/ext/carray_math_kernel.h +23 -47
  106. data/ext/carray_mathfunc.c +10 -3
  107. data/ext/carray_median_percentile.c +95 -94
  108. data/ext/carray_memory_view.c +42 -47
  109. data/ext/carray_operator.c +423 -122
  110. data/ext/carray_order.c +121 -85
  111. data/ext/carray_partition.c +13 -15
  112. data/ext/carray_random.c +47 -41
  113. data/ext/carray_round.c +9 -4
  114. data/ext/carray_scatter.c +54 -40
  115. data/ext/carray_segment.c +41 -45
  116. data/ext/carray_slab.c +64 -47
  117. data/ext/carray_slab.h +44 -33
  118. data/ext/carray_sort.c +32 -29
  119. data/ext/carray_sort_kernel.c +12 -10
  120. data/ext/carray_struct.c +38 -43
  121. data/ext/carray_test.c +47 -43
  122. data/ext/carray_time_text.c +24 -31
  123. data/ext/carray_undef.c +50 -7
  124. data/ext/carray_utils.c +258 -94
  125. data/ext/extconf.rb +24 -17
  126. data/ext/mk_call_cfunc.rb +19 -20
  127. data/ext/mk_pow5_table.rb +2 -1
  128. data/ext/mkkernel.rb +782 -461
  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 +264 -180
  135. data/lib/carray/basics.rb +272 -48
  136. data/lib/carray/bincount_nd.rb +33 -16
  137. data/lib/carray/block_iterator.rb +123 -102
  138. data/lib/carray/boolean_reduce.rb +7 -4
  139. data/lib/carray/categorical.rb +63 -51
  140. data/lib/carray/categorical_iterator.rb +89 -67
  141. data/lib/carray/complex.rb +61 -41
  142. data/lib/carray/conditional.rb +49 -22
  143. data/lib/carray/const_string.rb +54 -62
  144. data/lib/carray/core_extensions.rb +1 -1
  145. data/lib/carray/distance_limit.rb +7 -5
  146. data/lib/carray/factories.rb +269 -0
  147. data/lib/carray/fixlen_string.rb +25 -24
  148. data/lib/carray/frame/column_verbs.rb +20 -8
  149. data/lib/carray/frame/concat.rb +3 -3
  150. data/lib/carray/frame/convert.rb +2 -1
  151. data/lib/carray/frame/csv_parser.rb +7 -1
  152. data/lib/carray/frame/frame.rb +35 -25
  153. data/lib/carray/frame/group.rb +183 -150
  154. data/lib/carray/frame/io.rb +26 -7
  155. data/lib/carray/frame/join.rb +37 -12
  156. data/lib/carray/frame/records.rb +1 -1
  157. data/lib/carray/frame/reshape.rb +3 -3
  158. data/lib/carray/frame/sort.rb +10 -8
  159. data/lib/carray/frame/verbs.rb +148 -118
  160. data/lib/carray/frame/windows.rb +232 -21
  161. data/lib/carray/frame.rb +1 -2
  162. data/lib/carray/fuse_source.rb +24 -21
  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 +97 -24
  167. data/lib/carray/key_windows.rb +83 -57
  168. data/lib/carray/lazy.rb +196 -94
  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 +5 -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 +72 -71
  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/gather_nd.rb +106 -106
  183. data/lib/carray/methods/insert_block.rb +2 -2
  184. data/lib/carray/methods/is_between.rb +6 -4
  185. data/lib/carray/methods/is_in.rb +165 -145
  186. data/lib/carray/methods/join.rb +2 -1
  187. data/lib/carray/methods/lag.rb +6 -2
  188. data/lib/carray/methods/locate_addr.rb +150 -138
  189. data/lib/carray/methods/mask_duplicates.rb +1 -1
  190. data/lib/carray/methods/meshgrid.rb +28 -16
  191. data/lib/carray/methods/mode.rb +67 -67
  192. data/lib/carray/methods/nunique.rb +9 -7
  193. data/lib/carray/methods/repeat.rb +12 -12
  194. data/lib/carray/methods/resize.rb +1 -1
  195. data/lib/carray/methods/snap.rb +24 -20
  196. data/lib/carray/methods/string_format.rb +2 -2
  197. data/lib/carray/methods/unique.rb +4 -2
  198. data/lib/carray/methods/value_counts.rb +1 -1
  199. data/lib/carray/mkmf.rb +25 -28
  200. data/lib/carray/percentile_arguments.rb +82 -0
  201. data/lib/carray/record_order.rb +18 -17
  202. data/lib/carray/rng.rb +1 -0
  203. data/lib/carray/runtime.rb +190 -22
  204. data/lib/carray/segment_iterator.rb +251 -129
  205. data/lib/carray/serialize.rb +618 -571
  206. data/lib/carray/slab_iterator.rb +114 -114
  207. data/lib/carray/stack.rb +11 -12
  208. data/lib/carray/string.rb +16 -22
  209. data/lib/carray/string_operation_extension.rb +76 -52
  210. data/lib/carray/struct.rb +122 -164
  211. data/lib/carray/struct_builder.rb +243 -72
  212. data/lib/carray/time.rb +496 -342
  213. data/lib/carray/window_iterator.rb +191 -150
  214. data/lib/carray.rb +6 -11
  215. data/yard-stubs/ca_obj_array.rb +20 -135
  216. data/yard-stubs/ca_obj_bitarray.rb +1 -8
  217. data/yard-stubs/ca_obj_bitfield.rb +4 -3
  218. data/yard-stubs/ca_obj_byte_swap.rb +21 -7
  219. data/yard-stubs/ca_obj_fake.rb +3 -1
  220. data/yard-stubs/ca_obj_farray.rb +1 -1
  221. data/yard-stubs/ca_obj_field.rb +8 -6
  222. data/yard-stubs/ca_obj_refer.rb +7 -5
  223. data/yard-stubs/ca_obj_roll.rb +7 -6
  224. data/yard-stubs/ca_obj_shift.rb +2 -3
  225. data/yard-stubs/ca_obj_stride.rb +5 -7
  226. data/yard-stubs/ca_obj_tile.rb +1 -1
  227. data/yard-stubs/ca_obj_time.rb +43 -0
  228. data/yard-stubs/ca_obj_transpose.rb +1 -1
  229. data/yard-stubs/ca_obj_window.rb +26 -15
  230. data/yard-stubs/carray_access.rb +51 -4
  231. data/yard-stubs/carray_attribute.rb +26 -38
  232. data/yard-stubs/carray_cast.rb +118 -165
  233. data/yard-stubs/carray_class.rb +3 -4
  234. data/yard-stubs/carray_conversion.rb +6 -7
  235. data/yard-stubs/carray_copy.rb +2 -1
  236. data/yard-stubs/carray_count.rb +5 -3
  237. data/yard-stubs/carray_element.rb +4 -3
  238. data/yard-stubs/carray_limits.rb +100 -0
  239. data/yard-stubs/carray_loop.rb +0 -20
  240. data/yard-stubs/carray_mask.rb +59 -41
  241. data/yard-stubs/carray_math.rb +157 -100
  242. data/yard-stubs/carray_mathfunc.rb +415 -3
  243. data/yard-stubs/carray_median_percentile.rb +29 -11
  244. data/yard-stubs/carray_memory_view.rb +2 -2
  245. data/yard-stubs/carray_order.rb +67 -34
  246. data/yard-stubs/carray_random.rb +6 -6
  247. data/yard-stubs/carray_reduce.rb +353 -0
  248. data/yard-stubs/carray_rng.rb +92 -0
  249. data/yard-stubs/carray_scatter.rb +10 -2
  250. data/yard-stubs/carray_slab.rb +7 -4
  251. data/yard-stubs/carray_sort.rb +7 -6
  252. data/yard-stubs/carray_undef.rb +44 -5
  253. data/yard-stubs/ruby_carray.rb +75 -40
  254. metadata +62 -24
  255. data/CHANGELOG.v1.md +0 -126
  256. data/ext/carray_build_flags.h +0 -3
  257. data/ext/carray_config.h +0 -28
  258. data/ext/carray_data_type.c +0 -90
  259. data/ext/carray_kernels_bincmp.c +0 -6457
  260. data/ext/carray_kernels_binop.c +0 -31534
  261. data/ext/carray_kernels_init.c +0 -1734
  262. data/ext/carray_kernels_moncmp.c +0 -2104
  263. data/ext/carray_kernels_monop.c +0 -25337
  264. data/ext/carray_kernels_reduce_aggregate.c +0 -27545
  265. data/ext/carray_kernels_reduce_boolean.c +0 -1924
  266. data/ext/carray_kernels_reduce_cumulative.c +0 -11646
  267. data/ext/carray_kernels_reduce_extreme.c +0 -21631
  268. data/ext/carray_kernels_reduce_variance.c +0 -5981
  269. data/ext/carray_kernels_scan.c +0 -4302
  270. data/ext/carray_kernels_search.c +0 -37776
  271. data/ext/carray_kernels_sort.c +0 -10814
  272. data/ext/carray_kernels_triop.c +0 -1864
  273. data/lib/carray/construct.rb +0 -360
  274. data/lib/carray/data_type_extension.rb +0 -262
  275. data/lib/carray/data_type_limits.rb +0 -91
@@ -18,40 +18,30 @@
18
18
  # `ca[..., :>]` evaluation.
19
19
 
20
20
  class CASlabIterator < CAIterator
21
- # Built from C via `CASlabIterator.new(reference, slab_axes)`: `reference`
21
+ # Built from C via `CASlabIterator.new(source, slab_axes)`: `source`
22
22
  # is the sliced base view (with `:>` axes as full range), `slab_axes` are
23
23
  # the positions marked with `:>`.
24
- def initialize (reference, slab_axes)
25
- @reference = reference
24
+ def initialize(source, slab_axes)
25
+ @source = source
26
26
  @slab_axes = slab_axes
27
- rdim = reference.shape
28
- @outer_positions = (0...reference.ndim).reject { |k| slab_axes.include?(k) }.freeze
27
+ rdim = source.shape
28
+ @outer_positions = (0...source.ndim).reject { |k| slab_axes.include?(k) }.freeze
29
29
  @shape = @outer_positions.map { |k| rdim[k] }
30
30
  @ndim = @shape.size
31
31
  self
32
32
  end
33
33
 
34
- # The array being iterated (slab exposes it as `reference`; block / window
35
- # iterators expose theirs as `source`). The base has no common accessor.
36
- attr_reader :reference, :slab_axes
37
-
38
- # Slab view at outer index `idx` (Array, length = self.ndim). Returns
39
- # `@reference[*full_idx]` where slab axes are nil (full range) and
40
- # outer axes take their values from idx.
41
- def kernel_at_index (idx)
42
- full = Array.new(@reference.ndim) # nil at every position
43
- @outer_positions.each_with_index { |k, i| full[k] = idx[i] }
44
- @reference[*full]
45
- end
34
+ attr_reader :slab_axes
46
35
 
47
36
  # @overload each { |slab| ... }
48
37
  # Yields each slab as an inner CArray. Without a block, returns
49
- # an `Enumerator` from `each_slab`.
38
+ # an `Enumerator`.
50
39
  # @yieldparam slab [CArray]
51
40
  # @return [Enumerator, self]
52
- def each (&block)
53
- return @reference.each_slab(axis: @slab_axes) unless block
54
- @reference.each_slab(axis: @slab_axes, &block)
41
+ def each(&block)
42
+ return to_enum(:each) unless block
43
+ @source.each_slab(axis: @slab_axes, &block)
44
+ self
55
45
  end
56
46
 
57
47
  # @overload map { |slab| ... }
@@ -60,28 +50,32 @@ class CASlabIterator < CAIterator
60
50
  # @yieldparam slab [CArray]
61
51
  # @yieldreturn [Object] per-slab result.
62
52
  # @return [CArray]
63
- def map (&block)
64
- @reference.map_slab(axis: @slab_axes, &block)
53
+ def map(&block)
54
+ @source.map_slab(axis: @slab_axes, &block)
65
55
  end
66
56
 
67
- # @overload reduce { |acc, slab| ... }
68
- # Reduces the slabs with `reduce_slab`. The block-only form uses
69
- # the first slab as the seed; the `init` form starts from `init`.
70
- # @yieldparam acc [Object] running accumulator.
71
- # @yieldparam slab [CArray] next slab.
72
- # @yieldreturn [Object] updated accumulator.
73
- # @return [Object]
74
- # @overload reduce(init) { |acc, slab| ... }
75
- # @param init [Object] initial accumulator value.
76
- # @yieldparam acc [Object]
57
+ # @overload reduce(data_type: nil) { |slab| ... }
58
+ # Custom per-slab reduction: the block receives each slab and returns one
59
+ # value for it. The values fill an array of the outer shape, in
60
+ # `:object` cells unless `data_type:` is given, as the other iterators'
61
+ # `reduce` does.
77
62
  # @yieldparam slab [CArray]
78
- # @yieldreturn [Object]
79
- # @return [Object]
80
- def reduce (*args, &block)
63
+ # @return [CArray]
64
+ # @overload reduce(init, data_type: nil) { |acc, elem| ... }
65
+ # Per-slab element fold: each slab's present cells are folded element by
66
+ # element from a copy of `init` (`init.dup`). A masked cell is not passed;
67
+ # a slab with none present answers `init`.
68
+ # @param init [Object] initial accumulator.
69
+ # @return [CArray]
70
+ def reduce(*args, data_type: nil, &block)
71
+ if args.size > 1
72
+ raise ArgumentError, "reduce: wrong number of arguments (given #{args.size}, expected 0..1)"
73
+ end
74
+ data_type ||= CA_OBJECT
81
75
  if args.empty?
82
- @reference.reduce_slab(axis: @slab_axes, &block)
76
+ @source.reduce_slab(axis: @slab_axes, data_type: data_type, &block)
83
77
  else
84
- @reference.reduce_slab(axis: @slab_axes, init: args[0], &block)
78
+ @source.reduce_slab(axis: @slab_axes, init: args[0], data_type: data_type, &block)
85
79
  end
86
80
  end
87
81
 
@@ -89,13 +83,13 @@ class CASlabIterator < CAIterator
89
83
  #
90
84
  # A per-slab reduction that folds each slab to one value is exactly the core
91
85
  # per-axis reduction over the slab axes, so every reduction is a direct
92
- # delegation to `reference.<op>(axis: slab_axes)`. This inherits the core
86
+ # delegation to `source.<op>(axis: slab_axes)`. This inherits the core
93
87
  # data type, mask, empty/all-masked (identity vs UNDEF) and epsilon-close
94
88
  # contracts unchanged -- there is no separate slab reduction kernel. (Unlike
95
89
  # the map / reduce block surface, these are mask-aware: they route through the
96
90
  # core reduction, which handles masked sources.)
97
91
 
98
- # Each reduction below delegates to `reference.<op>(axis: slab_axes)`, so it
92
+ # Each reduction below delegates to `source.<op>(axis: slab_axes)`, so it
99
93
  # inherits the core data type, mask, empty / all-masked and epsilon-close
100
94
  # contracts unchanged. See {CAIterator} for what each one computes.
101
95
  #
@@ -160,16 +154,16 @@ class CASlabIterator < CAIterator
160
154
  :variancep, :stddevp, :minmax, :min_index, :max_index,
161
155
  :min_addr, :max_addr].each do |op|
162
156
  class_eval <<~RUBY, __FILE__, __LINE__ + 1
163
- def #{op} (min_count: nil, fill_value: nil)
164
- @reference.#{op}(axis: @slab_axes, **reduce_options(min_count, fill_value))
157
+ def #{op}(min_count: nil, fill_value: nil)
158
+ @source.#{op}(axis: @slab_axes, **reduce_options(min_count, fill_value))
165
159
  end
166
160
  RUBY
167
161
  end
168
162
 
169
163
  [:all, :any].each do |op|
170
164
  class_eval <<~RUBY, __FILE__, __LINE__ + 1
171
- def #{op} (**kw)
172
- @reference.#{op}(axis: @slab_axes, **CAIterator.reduce_keywords(:#{op}, kw))
165
+ def #{op}(**kw)
166
+ @source.#{op}(axis: @slab_axes, **CAIterator.send(:reduce_keywords, :#{op}, kw))
173
167
  end
174
168
  RUBY
175
169
  end
@@ -189,39 +183,39 @@ class CASlabIterator < CAIterator
189
183
  # These take no `min_count:` or `fill_value:`, as the core ones do not.
190
184
  [:first, :last, :nunique].each do |op|
191
185
  class_eval <<~RUBY, __FILE__, __LINE__ + 1
192
- def #{op} (**kw)
193
- @reference.#{op}(axis: @slab_axes, **CAIterator.reduce_keywords(:#{op}, kw))
186
+ def #{op}(**kw)
187
+ @source.#{op}(axis: @slab_axes, **CAIterator.send(:reduce_keywords, :#{op}, kw))
194
188
  end
195
189
  RUBY
196
190
  end
197
191
 
198
192
  # @overload count(v = <none>)
199
- # Per-slab count, delegating to `reference.count(..., axis: slab_axes)`.
193
+ # Per-slab count, delegating to `source.count(..., axis: slab_axes)`.
200
194
  # No argument counts present (non-masked) cells; `count(UNDEF)` counts
201
195
  # masked cells; `count(v)` counts cells equal to `v`.
202
196
  # @return [CArray] one count per slab
203
- def count (*args, **kw)
197
+ def count(*args, **kw)
204
198
  return count_not_masked(**kw) if args.empty?
205
- # CABlock / CAWindow shadow #count with a geometry accessor, and @reference
199
+ # CABlock / CAWindow shadow #count with a geometry accessor, and @source
206
200
  # may be such a view, so dispatch CArray#count explicitly for count(v).
207
- count_cells(@reference, *args, axis: @slab_axes,
208
- **CAIterator.reduce_keywords(:count, kw))
201
+ count_cells(@source, *args, axis: @slab_axes,
202
+ **CAIterator.send(:reduce_keywords, :count, kw))
209
203
  end
210
204
 
211
205
  # @overload count_not_masked
212
206
  # Per-slab count of present (non-masked) cells.
213
207
  # @return [CArray]
214
- def count_not_masked (**kw)
215
- @reference.count_not_masked(axis: @slab_axes,
216
- **CAIterator.reduce_keywords(:count_not_masked, kw))
208
+ def count_not_masked(**kw)
209
+ @source.count_not_masked(axis: @slab_axes,
210
+ **CAIterator.send(:reduce_keywords, :count_not_masked, kw))
217
211
  end
218
212
 
219
213
  # @overload count_masked
220
214
  # Per-slab count of masked cells.
221
215
  # @return [CArray]
222
- def count_masked (**kw)
223
- @reference.count_masked(axis: @slab_axes,
224
- **CAIterator.reduce_keywords(:count_masked, kw))
216
+ def count_masked(**kw)
217
+ @source.count_masked(axis: @slab_axes,
218
+ **CAIterator.send(:reduce_keywords, :count_masked, kw))
225
219
  end
226
220
 
227
221
  # @overload elements
@@ -230,10 +224,10 @@ class CASlabIterator < CAIterator
230
224
  # space.
231
225
  # @return [CArray]
232
226
  def elements
233
- sz = @slab_axes.inject(1) { |p, ax| p * @reference.shape[ax] }
227
+ sz = @slab_axes.inject(1) { |p, ax| p * @source.shape[ax] }
234
228
  # count_not_masked gives the correct output shape (and, unlike bare #count,
235
229
  # is not shadowed by CABlock / CAWindow); overwrite with the constant size.
236
- out = @reference.count_not_masked(axis: @slab_axes)
230
+ out = @source.count_not_masked(axis: @slab_axes)
237
231
  out[] = sz
238
232
  out
239
233
  end
@@ -248,26 +242,28 @@ class CASlabIterator < CAIterator
248
242
  # @overload median(min_count: nil, fill_value: nil)
249
243
  # Per-slab median.
250
244
  # @return [CArray]
251
- def median (min_count: nil, fill_value: nil)
245
+ def median(min_count: nil, fill_value: nil)
252
246
  opts = reduce_options(min_count, fill_value)
253
247
  if @slab_axes.size == 1
254
- @reference.median(axis: @slab_axes[0], **opts)
248
+ @source.median(axis: @slab_axes[0], **opts)
255
249
  else
256
- @reference.reduce_slab(axis: @slab_axes) { |s| s.median(**opts) }
250
+ @source.reduce_slab(axis: @slab_axes) { |s| s.median(**opts) }
257
251
  end
258
252
  end
259
253
 
260
- # @overload percentile(*pers, min_count: nil, fill_value: nil)
261
- # Per-slab percentile(s). One argument returns one CArray; several return an
262
- # array of CArrays (as `CArray#percentile`).
254
+ # @overload percentile(p, min_count: nil, fill_value: nil)
255
+ # Per-slab percentile(s), in the form `CArray#percentile` returns: one p
256
+ # gives one CArray, an Array of p an Array of CArrays, and several p
257
+ # (or a CArray of p) one CArray with the p axes in front.
263
258
  # @return [CArray, Array<CArray>]
264
- def percentile (*pers, min_count: nil, fill_value: nil)
259
+ def percentile(*pers, min_count: nil, fill_value: nil)
265
260
  opts = reduce_options(min_count, fill_value)
266
261
  if @slab_axes.size == 1
267
- @reference.percentile(*pers, axis: @slab_axes[0], **opts)
262
+ @source.percentile(*pers, axis: @slab_axes[0], **opts)
268
263
  else
269
- rs = pers.map { |p| @reference.reduce_slab(axis: @slab_axes) { |s| s.percentile(p, **opts) } }
270
- pers.size == 1 ? rs[0] : rs
264
+ list, form = CArray.send(:percentile_arguments, pers)
265
+ answers = list.map { |p| @source.reduce_slab(axis: @slab_axes) { |s| s.percentile(p, **opts) } }
266
+ CArray.send(:percentile_answer, answers, form)
271
267
  end
272
268
  end
273
269
 
@@ -275,12 +271,14 @@ class CASlabIterator < CAIterator
275
271
  # Per-slab five-number summary `[min, Q1, median, Q3, max]` (five CArrays),
276
272
  # as `CArray#quantile`.
277
273
  # @return [Array<CArray>]
278
- def quantile
274
+ def quantile(*args, min_count: nil, fill_value: nil)
275
+ CAIterator.send(:refuse_quantile_arguments, args)
276
+ opts = reduce_options(min_count, fill_value)
279
277
  if @slab_axes.size == 1
280
- @reference.quantile(axis: @slab_axes[0])
278
+ @source.quantile(axis: @slab_axes[0], **opts)
281
279
  else
282
280
  [0, 25, 50, 75, 100].map { |p|
283
- @reference.reduce_slab(axis: @slab_axes) { |s| s.percentile(p) }
281
+ @source.reduce_slab(axis: @slab_axes) { |s| s.percentile(p, **opts) }
284
282
  }
285
283
  end
286
284
  end
@@ -292,49 +290,51 @@ class CASlabIterator < CAIterator
292
290
  # the reductions above, sort does not accept an axis array). A multi-axis slab
293
291
  # has no single sort axis, so it raises; sort one axis at a time.
294
292
 
295
- # @overload sort_addr
293
+ # @overload sort_addr(masked_position: :last)
296
294
  # Per-slab sort by flat source address. Delegates to
297
- # `reference.sort_addr(axis: slab_axis)`: reference-shaped, each slab's cells
298
- # carry the flat source addresses that sort that slab ascending.
299
- # @return [CArray] reference-shaped int64
300
- def sort_addr
301
- @reference.sort_addr(axis: single_sort_axis(:sort_addr))
295
+ # `source.sort_addr(axis: slab_axis, masked_position:)`: source-shaped,
296
+ # each slab's cells carry the flat source addresses that sort that slab
297
+ # ascending, the masked cells last (or first with `:first`).
298
+ # @param masked_position [Symbol] `:last` (default) or `:first`.
299
+ # @return [CArray] source-shaped int64
300
+ def sort_addr(masked_position: :last)
301
+ @source.sort_addr(axis: single_sort_axis(:sort_addr), masked_position: masked_position)
302
302
  end
303
303
 
304
304
  # @overload sort_index
305
305
  # Per-slab sort by axis-local index (usable with take_along_axis).
306
- # Delegates to `reference.sort_index(axis: slab_axis)`: reference-shaped, the
306
+ # Delegates to `source.sort_index(axis: slab_axis)`: source-shaped, the
307
307
  # axis-local rank order within the slab axis.
308
- # @return [CArray] reference-shaped int64
308
+ # @return [CArray] source-shaped int64
309
309
  def sort_index
310
- @reference.sort_index(axis: single_sort_axis(:sort_index))
310
+ @source.sort_index(axis: single_sort_axis(:sort_index))
311
311
  end
312
312
 
313
313
  # ---- weighted (tier 2) ------------------------------------------------
314
314
  #
315
315
  # Delegated to the core weighted reduction over the slab axes; `weights` has
316
- # the same shape as the reference (one weight per cell). Core wsum / wmean
316
+ # the same shape as the source (one weight per cell). Core wsum / wmean
317
317
  # accept multi-axis, so this covers multi-axis slabs directly.
318
318
 
319
319
  # @overload wsum(weights, min_count: nil, fill_value: nil)
320
- # Per-slab weighted sum, `weights` shaped like the reference.
320
+ # Per-slab weighted sum, `weights` shaped like the source.
321
321
  # @return [CArray]
322
- def wsum (weights, min_count: nil, fill_value: nil)
323
- @reference.wsum(weights, axis: @slab_axes, **reduce_options(min_count, fill_value))
322
+ def wsum(weights, min_count: nil, fill_value: nil)
323
+ @source.wsum(weights, axis: @slab_axes, **reduce_options(min_count, fill_value))
324
324
  end
325
325
 
326
326
  # @overload wmean(weights, min_count: nil, fill_value: nil)
327
- # Per-slab weighted mean, `weights` shaped like the reference.
327
+ # Per-slab weighted mean, `weights` shaped like the source.
328
328
  # @return [CArray]
329
- def wmean (weights, min_count: nil, fill_value: nil)
330
- @reference.wmean(weights, axis: @slab_axes, **reduce_options(min_count, fill_value))
329
+ def wmean(weights, min_count: nil, fill_value: nil)
330
+ @source.wmean(weights, axis: @slab_axes, **reduce_options(min_count, fill_value))
331
331
  end
332
332
 
333
333
  # ---- segment scan: within-slab running statistics ---------------------
334
334
  #
335
335
  # A per-slab running accumulation along the slab axis is exactly the core
336
336
  # per-axis cumulative over that axis, so every scan delegates to
337
- # `reference.<op>(axis: slab_axis)`, inheriting the core data type / mask (masked
337
+ # `source.<op>(axis: slab_axis)`, inheriting the core data type / mask (masked
338
338
  # cells hold the running total, output unmasked) contracts unchanged. Each
339
339
  # cell is in exactly one slab (a partition), so the running value is
340
340
  # well-defined; the surface is uniform with the family even though it
@@ -343,55 +343,55 @@ class CASlabIterator < CAIterator
343
343
  # scan one axis at a time, like the order surface.
344
344
 
345
345
  # @!method cumsum
346
- # Per-slab inclusive running sum (float64), reference-shaped.
346
+ # Per-slab inclusive running sum (float64), source-shaped.
347
347
  # @return [CArray]
348
348
  # @!method cumprod
349
- # Per-slab inclusive running product (float64), reference-shaped.
349
+ # Per-slab inclusive running product (float64), source-shaped.
350
350
  # @return [CArray]
351
351
  # @!method cummax
352
- # Per-slab inclusive running maximum (reference data type), reference-shaped.
352
+ # Per-slab inclusive running maximum (source data type), source-shaped.
353
353
  # @return [CArray]
354
354
  # @!method cummin
355
- # Per-slab inclusive running minimum (reference data type), reference-shaped.
355
+ # Per-slab inclusive running minimum (source data type), source-shaped.
356
356
  # @return [CArray]
357
357
  # @!method cumcount
358
- # Per-slab running count of present cells (int64), reference-shaped.
358
+ # Per-slab running count of present cells (int64), source-shaped.
359
359
  # @return [CArray]
360
360
  [:cumsum, :cumprod, :cummax, :cummin, :cumcount].each do |op|
361
361
  class_eval <<~RUBY, __FILE__, __LINE__ + 1
362
362
  def #{op}
363
- @reference.#{op}(axis: single_scan_axis(:#{op}))
363
+ @source.#{op}(axis: single_scan_axis(:#{op}))
364
364
  end
365
365
  RUBY
366
366
  end
367
367
 
368
368
  # @overload lag(n = 1)
369
369
  # Per-slab value `n` steps earlier along the slab axis (UNDEF where the
370
- # slab has none), as `reference.lag(n, axis: slab_axis)`: a view of the
371
- # reference. A multi-axis slab has no single direction to step in, so it
370
+ # slab has none), as `source.lag(n, axis: slab_axis)`: a view of the
371
+ # source. A multi-axis slab has no single direction to step in, so it
372
372
  # raises, as the scans do.
373
- # @return [CArray] reference-shaped
374
- def lag (n = 1)
375
- @reference.lag(n, axis: single_scan_axis(:lag))
373
+ # @return [CArray] source-shaped
374
+ def lag(n = 1)
375
+ @source.lag(n, axis: single_scan_axis(:lag))
376
376
  end
377
377
 
378
378
  # @overload strip_mask(method:)
379
379
  # Per-slab fill of the masked cells along the slab axis, as
380
- # `reference.strip_mask(method:, axis: slab_axis)`: `:forward` / `:ffill`
381
- # or `:backward` / `:bfill`. A multi-axis slab raises, as the scans do.
382
- # @return [CArray] reference-shaped
383
- def strip_mask (method:)
384
- CAIterator.hold_backward?(method)
385
- @reference.strip_mask(method: method, axis: single_scan_axis(:strip_mask))
380
+ # `source.strip_mask(method:, axis: slab_axis)`: `:forward`
381
+ # or `:backward`. A multi-axis slab raises, as the scans do.
382
+ # @return [CArray] source-shaped
383
+ def strip_mask(method:)
384
+ CAIterator.send(:hold_backward?, method)
385
+ @source.strip_mask(method: method, axis: single_scan_axis(:strip_mask))
386
386
  end
387
387
 
388
- # @overload order(descending: false, method: :ordinal, kind: :quick)
388
+ # @overload rank_index(descending: false, method: :ordinal, kind: :quick)
389
389
  # Per-slab rank of each cell along the slab axis (int64), as
390
- # `reference.order(axis: slab_axis, ...)`. A multi-axis slab has no
390
+ # `source.rank_index(axis: slab_axis, ...)`. A multi-axis slab has no
391
391
  # single sort axis, so it raises, as sort_addr does.
392
- # @return [CArray] reference-shaped
393
- def order (**kw)
394
- @reference.order(axis: single_sort_axis(:order), **CAIterator.reduce_keywords(:order, kw))
392
+ # @return [CArray] source-shaped
393
+ def rank_index(**kw)
394
+ @source.rank_index(axis: single_sort_axis(:rank_index), **CAIterator.send(:reduce_keywords, :rank_index, kw))
395
395
  end
396
396
 
397
397
  private
@@ -399,14 +399,14 @@ class CASlabIterator < CAIterator
399
399
  # The single slab axis for the order surface (core sort takes one integer
400
400
  # axis). A multi-axis slab has no single sort axis, so raise.
401
401
  # The reduction keywords that were given, for the core call.
402
- def reduce_options (min_count, fill_value)
402
+ def reduce_options(min_count, fill_value)
403
403
  opts = {}
404
404
  opts[:min_count] = min_count unless min_count.nil?
405
405
  opts[:fill_value] = fill_value unless fill_value.nil?
406
406
  opts
407
407
  end
408
408
 
409
- def single_sort_axis (op)
409
+ def single_sort_axis(op)
410
410
  return @slab_axes[0] if @slab_axes.size == 1
411
411
  raise ArgumentError,
412
412
  "#{op}: a multi-axis slab (axes #{@slab_axes.inspect}) has no single " \
@@ -415,7 +415,7 @@ class CASlabIterator < CAIterator
415
415
 
416
416
  # The single slab axis for a segment scan (core scan takes one integer axis).
417
417
  # A multi-axis slab has no single scan axis, so raise.
418
- def single_scan_axis (op)
418
+ def single_scan_axis(op)
419
419
  return @slab_axes[0] if @slab_axes.size == 1
420
420
  raise ArgumentError,
421
421
  "#{op}: a multi-axis slab (axes #{@slab_axes.inspect}) has no single " \
data/lib/carray/stack.rb CHANGED
@@ -41,8 +41,7 @@ class CArray
41
41
  # / Module targets are rejected (= `data_type: CATime` is invalid;
42
42
  # use auto-detect for Face round-trip).
43
43
  #
44
- # 3.0 (post-K_AXIS, F.S1-stack landed): replaces `CArray.merge`. The
45
- # low-level raw constructor is `CAStack.new(list, axis:)`; this method
44
+ # The low-level raw constructor is `CAStack.new(list, axis:)`; this method
46
45
  # is the high-level surface that performs promote_list + CAStack.new +
47
46
  # (face_lift when homogeneous Face).
48
47
  # @overload stack(list, axis: 0, data_type: nil)
@@ -57,7 +56,7 @@ class CArray
57
56
  # inferred when `nil`.
58
57
  # @return [CArray] CAStack view.
59
58
  # @raise [ArgumentError] when `list` is empty.
60
- def self.stack (list, axis: 0, data_type: nil)
59
+ def self.stack(list, axis: 0, data_type: nil)
61
60
  raise ArgumentError, "stack: list must not be empty" if list.empty?
62
61
  axis = 0 if axis.nil?
63
62
  list = promote_list_for("stack", list, data_type: data_type)
@@ -90,7 +89,7 @@ class CArray
90
89
  # @return [CAMeld] view over the welded pieces.
91
90
  # @raise [ArgumentError] when the list is empty, ndim mismatch,
92
91
  # or non-axis dim mismatch across pieces (surfaced by CAMeld.new).
93
- def self.meld (*arrays, axis: 0, data_type: nil)
92
+ def self.meld(*arrays, axis: 0, data_type: nil)
94
93
  if arrays.length == 1 && arrays[0].is_a?(Array)
95
94
  arrays = arrays[0]
96
95
  end
@@ -98,7 +97,7 @@ class CArray
98
97
  axis = 0 if axis.nil?
99
98
  first = arrays[0]
100
99
  unless first.is_a?(CArray)
101
- raise ArgumentError, "meld: entries must be CArray (got #{first.class})"
100
+ raise TypeError, "meld: entries must be CArray (got #{first.class})"
102
101
  end
103
102
  axis_norm = CArray.normalize_axis(axis, first.ndim, "meld")
104
103
  arrays = promote_list_for("meld", arrays, data_type: data_type)
@@ -130,7 +129,7 @@ class CArray
130
129
  # @param data_type [Symbol, Integer, nil] result `data_type`.
131
130
  # @return [CAMeld]
132
131
  # @raise [ArgumentError] when no `others` are given.
133
- def meld (*others, axis: 0, data_type: nil)
132
+ def meld(*others, axis: 0, data_type: nil)
134
133
  raise ArgumentError, "meld: at least one other array required" if others.empty?
135
134
  CArray.meld(self, *others, axis: axis, data_type: data_type)
136
135
  end
@@ -172,7 +171,7 @@ class CArray
172
171
  # @return [CArray] tiled view.
173
172
  # @raise [ArgumentError] when `list` is empty or `tdim.product !=
174
173
  # list.size`.
175
- def self.montage (list, tdim, axis: 0, data_type: nil)
174
+ def self.montage(list, tdim, axis: 0, data_type: nil)
176
175
  raise ArgumentError, "montage: list must not be empty" if list.empty?
177
176
  unless tdim.is_a?(Array) && tdim.size > 0
178
177
  raise ArgumentError, "montage: tdim must be a non-empty Array of Integer"
@@ -228,7 +227,7 @@ class CArray
228
227
  # @param data_type [Symbol, Integer, nil] result `data_type`.
229
228
  # @return [CArray] CAStack view.
230
229
  # @raise [ArgumentError] when no `others` are given.
231
- def stack (*others, axis: 0, data_type: nil)
230
+ def stack(*others, axis: 0, data_type: nil)
232
231
  raise ArgumentError, "stack: at least one other parent required" if others.empty?
233
232
  CArray.stack([self] + others, axis: axis, data_type: data_type)
234
233
  end
@@ -239,7 +238,7 @@ class CArray
239
238
  #
240
239
  # CArray.stack(a.split(axis: k), axis: k) == a
241
240
  #
242
- # a = CA_INT([[1,2,3], [4,5,6]])
241
+ # a = CA_INT32([[1,2,3], [4,5,6]])
243
242
  # a.split(axis: 0) #=> [ <[1,2,3]>, <[4,5,6]> ] (row views)
244
243
  # a.split(axis: 1) #=> [ <[1,4]>, <[2,5]>, <[3,6]> ] (column views)
245
244
  #
@@ -249,7 +248,7 @@ class CArray
249
248
  # - +axis:+ takes a single Integer (the multi-axis Array form, which
250
249
  # returned an N-D object grid, is no longer accepted)
251
250
  # - pieces are CABlock views, NOT copies; writing through a piece
252
- # mutates +self+. Chain +.copy+ / +.to_ca+ for independent entities.
251
+ # mutates +self+. Chain +.copy+ for independent entities.
253
252
  # @overload split(axis:)
254
253
  # Returns an Array of `(ndim-1)`-D writable CABlock views obtained
255
254
  # by splitting `self` along `axis`. Inverse of `CArray.stack`.
@@ -259,7 +258,7 @@ class CArray
259
258
  # @return [Array<CArray>] one slice per index along `axis`.
260
259
  # @raise [ArgumentError] when `axis` is not a single Integer
261
260
  # (including `nil`).
262
- def split (axis:)
261
+ def split(axis:)
263
262
  raise ArgumentError, "split: axis: is required" if axis.nil?
264
263
  if axis.is_a?(Array)
265
264
  raise ArgumentError, "split: axis must be a single Integer"
@@ -298,7 +297,7 @@ class CAStack
298
297
  # writes into its cells stay refused.
299
298
  # @return [CAStack]
300
299
  # @raise [ArgumentError] when no `others` are given.
301
- def append (*others)
300
+ def append(*others)
302
301
  raise ArgumentError, "append: at least one parent required" if others.empty?
303
302
  if mask_array?
304
303
  raise ArgumentError, "append: a mask array can have no mask and can not be a part"
data/lib/carray/string.rb CHANGED
@@ -46,7 +46,7 @@ class CArray
46
46
  # @yieldparam i [Integer] cell index.
47
47
  # @yieldreturn [String, nil] value for cell `i`.
48
48
  # @return [CAString]
49
- def self.string (arg, &block)
49
+ def self.string(arg, &block)
50
50
  return string_face_of(arg).to_string if arg.is_a?(CArray)
51
51
 
52
52
  if block
@@ -97,40 +97,34 @@ class CAString
97
97
 
98
98
  # Per-cell `String#+`.
99
99
  # @return [CAString] shape and mask carried.
100
- def + (other) ; as_text(super) ; end
100
+ def +(other) ; as_text(super) ; end
101
101
  # Per-cell `String#+` (the word form of {#+}).
102
102
  # @return [CAString]
103
- def add (other) ; as_text(super) ; end
103
+ def add(other) ; as_text(super) ; end
104
104
  # Per-cell `String#*`.
105
105
  # @return [CAString] shape and mask carried.
106
- def * (other) ; as_text(super) ; end
106
+ def *(other) ; as_text(super) ; end
107
107
  # Per-cell `String#*` (the word form of {#*}).
108
108
  # @return [CAString]
109
- def mul (other) ; as_text(super) ; end
109
+ def mul(other) ; as_text(super) ; end
110
110
  # Per-cell `String#%` (format).
111
111
  # @return [CAString] shape and mask carried.
112
- def % (other) ; as_text(super) ; end
112
+ def %(other) ; as_text(super) ; end
113
113
  # Per-cell `String#%` (the word form of {#%}).
114
114
  # @return [CAString]
115
- def mod (other) ; as_text(super) ; end
115
+ def mod(other) ; as_text(super) ; end
116
116
  # The later String of each cell and `other`, cell by cell.
117
117
  # @return [CAString]
118
- def pmax (other) ; refuse_unordered_operands("pmax", other) ; as_text(super) ; end
118
+ def pmax(other) ; refuse_unordered_operands("pmax", other) ; as_text(super) ; end
119
119
  # The earlier String of each cell and `other`, cell by cell.
120
120
  # @return [CAString]
121
- def pmin (other) ; refuse_unordered_operands("pmin", other) ; as_text(super) ; end
121
+ def pmin(other) ; refuse_unordered_operands("pmin", other) ; as_text(super) ; end
122
122
  # Another name of {#pmax} (a String has no NaN to let win).
123
123
  # @return [CAString]
124
- def maximum (other) ; refuse_unordered_operands("maximum", other) ; as_text(super) ; end
124
+ def maximum(other) ; refuse_unordered_operands("maximum", other) ; as_text(super) ; end
125
125
  # Another name of {#pmin}.
126
126
  # @return [CAString]
127
- def minimum (other) ; refuse_unordered_operands("minimum", other) ; as_text(super) ; end
128
- # Another name of {#pmax}.
129
- # @return [CAString]
130
- def fmax (other) ; refuse_unordered_operands("fmax", other) ; as_text(super) ; end
131
- # Another name of {#pmin}.
132
- # @return [CAString]
133
- def fmin (other) ; refuse_unordered_operands("fmin", other) ; as_text(super) ; end
127
+ def minimum(other) ; refuse_unordered_operands("minimum", other) ; as_text(super) ; end
134
128
 
135
129
  # The String a blank cell holds: the cell a fresh {#template} gives and
136
130
  # the one {#shift} fills by default. Frozen, because every blank cell
@@ -142,7 +136,7 @@ class CAString
142
136
  # UNDEF. Given a data type, the result is a plain array of that type.
143
137
  # @overload template(type = nil, **opts)
144
138
  # @return [CAString, CArray]
145
- def template (*args, **opts, &block)
139
+ def template(*args, **opts, &block)
146
140
  return super if block || ! args.empty? || ! opts.empty?
147
141
  out = super
148
142
  out[] = BLANK
@@ -152,25 +146,25 @@ class CAString
152
146
  # Shifts the cells as {CArray#shift} does. The cells shifted in hold
153
147
  # {BLANK} unless `fill_value:` names a String or UNDEF.
154
148
  # @return [CAString] a view over the shifted cells.
155
- def shift (*shifts, fill_value: BLANK, **opts)
149
+ def shift(*shifts, fill_value: BLANK, **opts)
156
150
  super(*shifts, fill_value: fill_value, **opts)
157
151
  end
158
152
 
159
153
  # A window as {CArray#window} gives. The cells outside the array hold
160
154
  # {BLANK} unless `fill_value:` names a String or UNDEF.
161
155
  # @return [CAString] a view over the window.
162
- def window (*ranges, fill_value: BLANK, **opts)
156
+ def window(*ranges, fill_value: BLANK, **opts)
163
157
  super(*ranges, fill_value: fill_value, **opts)
164
158
  end
165
159
 
166
160
  # A resized copy as {CArray#resize} gives. The new cells hold {BLANK}
167
161
  # unless `fill_value:` names a String or UNDEF.
168
162
  # @return [CAString]
169
- def resize (*newdim, fill_value: BLANK)
163
+ def resize(*newdim, fill_value: BLANK)
170
164
  super(*newdim, fill_value: fill_value)
171
165
  end
172
166
 
173
- private def as_text (result)
167
+ private def as_text(result)
174
168
  result = result.copy if result.lazy_view?
175
169
  CAString.wrap(result)
176
170
  end