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
@@ -20,10 +20,18 @@ class CArray
20
20
  # refused with `IndexError`, as `self[addrs]` refuses it.
21
21
  # - `vals` is a CArray of length matching `addrs` (coerced to
22
22
  # `self.data_type`), or a scalar broadcast to all addresses: any
23
- # Numeric, `true` / `false`, or `UNDEF`. The scalar is converted as
23
+ # value that is not a CArray or a Ruby Array, such as a Numeric,
24
+ # `true` / `false`, or `UNDEF`. The scalar is converted as
24
25
  # `self[i] = v` converts it, so a value that does not fit the type
25
26
  # raises (`RangeError`, `FloatDomainError` for NaN into an integer
26
- # type). A scalar `UNDEF` is a masked value.
27
+ # type), and so does `nil` or a String a numeric array can not read. An Integer is the exception for `scatter_add!`,
28
+ # `scatter_sub!` and `scatter_mul!` on an integer array: they keep
29
+ # the answer modulo 2 ** bits, as `add!` does, so
30
+ # `CA_INT8([0]).scatter_add!([0], 300)` gives `[44]`.
31
+ # `scatter_min!` and `scatter_max!` take it as `pmin` and `pmax` do:
32
+ # one that can never win leaves the cells as they are, one that would
33
+ # win in every cell raises. `scatter_replace!` refuses it.
34
+ # A scalar `UNDEF` is a masked value.
27
35
  # - A negative `addrs[i]` counts from the end. One out of range
28
36
  # raises `IndexError`; the pairs before it stay applied, through a
29
37
  # view as well.
@@ -45,7 +53,8 @@ class CArray
45
53
  # @param addrs [CArray, Array<Integer>]
46
54
  # @param vals [CArray, Numeric]
47
55
  # @return [self]
48
- # @raise [IndexError] for out-of-range addresses.
56
+ # @raise [IndexError] for out-of-range addresses, or when `addrs` is
57
+ # float, complex, object or boolean.
49
58
  # @raise [CArray::DataTypeError] for non-numeric `data_type`.
50
59
  def scatter_add!(addrs, vals); end
51
60
 
@@ -34,7 +34,7 @@ class CArray
34
34
  # slab is that Face, and the output is too unless `data_type:` is
35
35
  # given; a read-only Face answers in `:object` cells.
36
36
  # @param axis [Integer, Array<Integer>, nil] the slab axis or axes.
37
- # @param data_type [Symbol, Integer, Class, nil] output data type
37
+ # @param data_type [Symbol, nil] output data type
38
38
  # (defaults to `self`'s data type).
39
39
  # @return [CArray]
40
40
  # @raise [ArgumentError] when the block result's shape does not match
@@ -49,8 +49,11 @@ class CArray
49
49
  # `slab[0]`, `slab.sum`, etc. to extract a scalar).
50
50
  # @overload reduce_slab(axis:, init:, data_type: nil)
51
51
  # Per-element form (`init:` given): the block receives `(acc, x)` for
52
- # each element of the slab and returns the new accumulator; the final
53
- # accumulator per slab fills the output.
52
+ # each element of the slab that is not masked and returns the new
53
+ # accumulator; the final accumulator per slab fills the output. A slab
54
+ # whose elements are all masked gives `init`. Each slab starts from its
55
+ # own copy of `init` (`init.dup`), so changing `acc` in place (`acc << x`)
56
+ # does not carry into the next slab.
54
57
  #
55
58
  # `UNDEF` from the block masks that output cell. Over a Face the slab
56
59
  # (and each element) is that Face's, and the output is that Face unless
@@ -58,7 +61,7 @@ class CArray
58
61
  # @param axis [Integer, Array<Integer>, nil] the slab axis or axes.
59
62
  # @param init [Object] the initial accumulator (selects the
60
63
  # per-element form).
61
- # @param data_type [Symbol, Integer, Class, nil] output data type.
64
+ # @param data_type [Symbol, nil] output data type.
62
65
  # @return [CArray] the reduced array (slab axes collapsed).
63
66
  # @see file:docs/topics/SlabIterator.md SlabIterator
64
67
  def reduce_slab(axis:, init: nil, data_type: nil); end
@@ -63,8 +63,8 @@ class CArray
63
63
 
64
64
  # @overload sort_copy(axis: nil, kind: :quick, masked_position: :last)
65
65
  # Eager-copy counterpart of {#sort}: returns a fresh entity
66
- # CArray with the same shape and `data_type` as `self`, sorted
67
- # along `axis`. Use this when you want an independent array
66
+ # CArray of `self`'s `data_type`, sorted along `axis` in `self`'s
67
+ # shape, or flat (1-D) without `axis`, as {#sort} answers. Use this when you want an independent array
68
68
  # rather than a view.
69
69
  #
70
70
  # It takes whatever {#sort} takes: numeric (`i8`..`f64`),
@@ -83,10 +83,11 @@ class CArray
83
83
  # @overload sort_addr(axis: nil, kind: :quick, masked_position: :last)
84
84
  # Returns view-flat addresses that index a sort.
85
85
  #
86
- # - With no kwarg (`a.sort_addr`): returns a CArray of `:int64`
87
- # flat addresses shaped like `self` (NOT flattened -- the
88
- # legacy 1-key case of `CArray.sort_addr`'s multi-key lex
89
- # sort). `kind:` has no effect on this form.
86
+ # - With no kwarg (`a.sort_addr`): returns a 1-D CArray of `:int64`
87
+ # flat addresses of the whole array in sorted order, the same as
88
+ # {#sort_index} without an axis, so `a[a.sort_addr]` is `a.sort`
89
+ # (the 1-key case of `CArray.sort_addr`). `kind:` has no effect on
90
+ # this form.
90
91
  # - With `axis:` (e.g. `a.sort_addr(axis: 0)`): returns
91
92
  # per-fiber view-flat addresses along the given axis, output
92
93
  # shape == `self.shape`.
@@ -13,6 +13,7 @@ class CArray
13
13
  # @return [Boolean]
14
14
  # @raise [ArgumentError] if the number of indices does not match
15
15
  # `ndim`.
16
+ # @raise [TypeError] if an index is not an Integer.
16
17
  def valid_index?(*idx); end
17
18
 
18
19
  # @overload valid_addr?(addr)
@@ -21,11 +22,16 @@ class CArray
21
22
  # @param addr [Integer] flat address into the contiguous element
22
23
  # sequence.
23
24
  # @return [Boolean]
25
+ # @raise [TypeError] if `addr` is not an Integer.
24
26
  def valid_addr?(addr); end
25
27
 
26
28
  # @overload same_shape?(other)
27
- # Returns `true` if `other` has the same shape as `self`.
28
- # @param other [CArray]
29
+ # Returns `true` if `other` has the same shape as `self`. Only the
30
+ # shape is compared, whatever the data types of the two. A scalar has
31
+ # the same shape as any array. An `other` that is not a CArray is read
32
+ # as an object array: a nested Array by its nesting, anything else as
33
+ # a scalar.
34
+ # @param other [CArray, Object]
29
35
  # @return [Boolean]
30
36
  def same_shape?(other); end
31
37
 
@@ -55,9 +61,10 @@ class CArray
55
61
  # @overload eql?(other)
56
62
  # Returns `true` under Hash-invariant semantics: `data_class`,
57
63
  # `data_type`, shape, and mask state must all match, and elements
58
- # are compared bitwise (for numeric types) or via `Object#eql?`
59
- # (for `:object` arrays), so -0.0 and 0.0 differ and two NaNs are
60
- # `eql?` only with the same bits.
64
+ # are compared bitwise (for numeric types) or, for `:object` arrays, via
65
+ # `Object#eql?` with an object equal to itself first, as in
66
+ # `Array#eql?`. In a numeric array -0.0 and 0.0 differ and two NaNs
67
+ # are `eql?` only with the same bits.
61
68
  # Two Faces are `eql?` only when they are of the same class, share
62
69
  # their state (a time array's unit, a categorical's labels) and hold
63
70
  # the same storage.
@@ -72,7 +79,13 @@ class CArray
72
79
  # `ndim`, `bytes`, `elements`, shape, scalar-ness, and mask
73
80
  # presence; for unmasked arrays, samples the leading 64 bytes of
74
81
  # data. Masked arrays skip the data sample.
82
+ #
83
+ # An `:object` array samples the `#hash` of its cells, so an array in
84
+ # a cell is hashed in turn. {#==}, {#eql?} and `Marshal.dump` walk into
85
+ # cells the same way, and all of them refuse arrays nested more than
86
+ # 256 levels deep.
75
87
  # @return [Integer]
88
+ # @raise [ArgumentError] when object cells nest more than 256 levels.
76
89
  def hash; end
77
90
 
78
91
  # @!endgroup
@@ -1,15 +1,15 @@
1
1
  # DOCUMENTATION ONLY — DO NOT REQUIRE.
2
- # Stubs for the UNDEF sentinel and UndefClass defined in
2
+ # Stubs for the UNDEF sentinel and CArray::UndefClass defined in
3
3
  # ext/carray_undef.c. See yard-stubs/README.md and yard-stubs/STYLE.md.
4
4
 
5
5
  # Singleton class of the {UNDEF} sentinel value. Not instantiable
6
- # (`UndefClass.new` is undef'd after the single instance is created
6
+ # (`CArray::UndefClass.new` is undef'd after the single instance is created
7
7
  # in `Init_carray_undef`).
8
8
  #
9
9
  # The class is private API in practice: read and write the sentinel
10
10
  # through the top-level `UNDEF` constant rather than touching the
11
11
  # class directly.
12
- class UndefClass
12
+ class CArray::UndefClass
13
13
  # @overload inspect
14
14
  # Returns the literal string `"UNDEF"`.
15
15
  # @return [String]
@@ -45,6 +45,45 @@ class UndefClass
45
45
  # @param other [Object]
46
46
  # @return [Boolean]
47
47
  def ==(other); end
48
+
49
+ # @overload dup
50
+ # Returns `UNDEF` itself, as `nil.dup` returns `nil`: there is one
51
+ # `UNDEF`, and a copy of it would not be taken for a masked cell.
52
+ # `Marshal.load(Marshal.dump(UNDEF))` gives `UNDEF` itself as well,
53
+ # also inside an Array or a Hash. A YAML document cannot bring the
54
+ # object back, so `YAML.dump` of `UNDEF` raises `TypeError`.
55
+ # @return [CArray::UndefClass] `UNDEF`.
56
+ def dup; end
57
+
58
+ # @overload clone(freeze: nil)
59
+ # Returns `UNDEF` itself, as {#dup} does.
60
+ # @return [CArray::UndefClass] `UNDEF`.
61
+ def clone(freeze: nil); end
62
+
63
+ # @!group Serialization hooks
64
+
65
+ # @overload _dump(limit)
66
+ # Returns the empty String Marshal stores for `UNDEF`. Marshal calls
67
+ # this; `Marshal.load` returns `UNDEF` itself.
68
+ # @param limit [Integer] unused.
69
+ # @return [String]
70
+ def _dump(limit); end
71
+
72
+ # @overload _load(string)
73
+ # Returns `UNDEF`. Marshal calls this when it reads what {#_dump}
74
+ # wrote.
75
+ # @param string [String] unused.
76
+ # @return [CArray::UndefClass] `UNDEF`.
77
+ def self._load(string); end
78
+
79
+ # @overload encode_with(coder)
80
+ # Refuses to write `UNDEF` as YAML, which could not bring `UNDEF`
81
+ # itself back. Psych calls this.
82
+ # @param coder [Psych::Coder]
83
+ # @raise [TypeError] always.
84
+ def encode_with(coder); end
85
+
86
+ # @!endgroup
48
87
  end
49
88
 
50
89
  # Top-level sentinel used by mask-bearing CArray APIs to mean
@@ -57,8 +96,8 @@ end
57
96
  #
58
97
  # @example mask a cell during construction
59
98
  # a = CArray.int32(3) { |i| (i == 1) ? UNDEF : i * 10 }
60
- # a.to_a # => [0, nil, 20] # UNDEF surfaces as nil after to_a
99
+ # a.to_a # => [0, UNDEF, 20]
61
100
  #
62
101
  # @example check whether an element is masked
63
102
  # a[1] == UNDEF # => true
64
- UNDEF = UndefClass.new
103
+ UNDEF = CArray::UndefClass.new
@@ -10,11 +10,28 @@ class CArray < Object
10
10
  # Library semantic version, e.g. `"3.0.0.dev"`.
11
11
  VERSION = ""
12
12
 
13
- # Sentinel marking "the caller did not give this argument", used by
14
- # C entry points whose fill value may legitimately be `nil` (so `nil`
15
- # itself cannot mark absence). Never pass it in.
16
- # @api private
17
- UNSPECIFIED = nil
13
+ # The version as one Integer, `major * 10000 + minor * 100 + teeny`
14
+ # (`30011` for 3.0.11), for a comparison in an `extconf.rb`.
15
+ VERSION_CODE = 0
16
+
17
+ # The first number of {VERSION}.
18
+ VERSION_MAJOR = 0
19
+
20
+ # The second number of {VERSION}.
21
+ VERSION_MINOR = 0
22
+
23
+ # The third number of {VERSION}.
24
+ VERSION_TEENY = 0
25
+
26
+ # The date of the version, as `"YYYY/MM/DD"`.
27
+ VERSION_DATE = ""
28
+
29
+ # The compiler flags the arithmetic of this build was compiled with,
30
+ # as one String.
31
+ BUILD_FLAGS = ""
32
+
33
+ # The largest `ndim` an array can have.
34
+ RANK_MAX = nil
18
35
 
19
36
  # `true` when the build links `<complex.h>`; `false` otherwise.
20
37
  # Complex array types (`:cmplx64`, `:cmplx128`) require this to be
@@ -34,8 +51,10 @@ end
34
51
  class CAWrap < CArray
35
52
  end
36
53
 
37
- # Zero-dimensional CArray. One element, broadcasts like a scalar in
38
- # elementwise ops.
54
+ # A scalar: one value with a CArray data type. It operates with an array
55
+ # of any shape, and can be assigned to any selection, as a single value.
56
+ # It is not an array of one element: `CA_INT32(3) + a` works for any `a`,
57
+ # while `CA_INT32([3]) + a` follows the shape rules of two arrays.
39
58
  class CScalar < CArray
40
59
  end
41
60
 
@@ -110,20 +129,64 @@ class CAMeld < CAView
110
129
  def seg_offsets; end
111
130
  end
112
131
 
132
+ # View of the cells picked on each axis by a list of positions or a
133
+ # Range (`a.grid(...)`, and `a[positions, nil]`). A masked position
134
+ # selects nothing and reads as masked.
135
+ class CAGrid < CAView
136
+ end
137
+
138
+ # View of the cells picked on each axis by a boolean array or a Range
139
+ # (`a[mask, nil]`).
140
+ class CASelectAxis < CAView
141
+ end
142
+
143
+ # View of the cells of its parent in another order, given by a list of
144
+ # addresses. The sorting methods return it (`a.sort`).
145
+ class CARemap < CAView
146
+ end
147
+
148
+ # View that reads a block of parent elements as one element. The
149
+ # library builds it for the mask of a reinterpreting view; no method
150
+ # returns it to a caller.
151
+ class CAReduce < CAView
152
+ end
153
+
154
+ # Base class of the views that give an array a meaning besides its
155
+ # storage type, the Faces: {CATime}, {CATimedelta}, {CARecord} and
156
+ # the string arrays.
157
+ class CAFace < CAView
158
+ end
159
+
160
+ # Base class of an array whose memory another library owns, written in
161
+ # a C extension. It defines no method of its own.
162
+ class CASource < CArray
163
+ end
164
+
165
+ # Lazy node of an operation on three arrays (`a.lazy.fma(b, c)`,
166
+ # `a.lazy.clip(lo, hi)`), computed when it is read.
167
+ class CATriOp < CAView
168
+ end
169
+
170
+ # Lazy node of a comparison of two arrays (`a.lazy < b`), boolean,
171
+ # computed when it is read.
172
+ class CABinCmp < CAView
173
+ end
174
+
175
+ # Lazy node of a test on one array (`a.lazy.is_nan`), boolean, computed
176
+ # when it is read.
177
+ class CAMonCmp < CAView
178
+ end
179
+
113
180
  # Namespace for CArray utility module functions.
114
181
  module CA
115
182
  end
116
183
 
117
184
  # --- Top-level constants (defined on Object in ext/ruby_carray.c) ---
118
185
 
119
- # Maximum supported `ndim`.
120
- CA_RANK_MAX = nil
121
-
122
186
  # @!group Data type symbols
123
187
  #
124
188
  # Each constant is a `Symbol` matching the canonical `data_type`
125
- # name. Aliases share Symbol identity with their canonical form
126
- # (e.g. `CA_DOUBLE == CA_FLOAT64` via Symbol equality).
189
+ # name.
127
190
 
128
191
  # `:fixlen` — fixed-length opaque byte blob; element byte size set
129
192
  # per array.
@@ -157,37 +220,9 @@ CA_CMPLX128 = :cmplx128
157
220
  # `:object` — boxed Ruby object slot.
158
221
  CA_OBJECT = :object
159
222
 
160
- # Alias of {CA_UINT8}.
161
- CA_BYTE = :uint8
162
- # Alias of {CA_INT16}.
163
- CA_SHORT = :int16
164
- # Alias of {CA_INT32}.
165
- CA_INT = :int32
166
- # Alias of {CA_FLOAT32}.
167
- CA_FLOAT = :float32
168
- # Alias of {CA_FLOAT64}.
169
- CA_DOUBLE = :float64
170
- # Alias of {CA_CMPLX64}.
171
- CA_COMPLEX = :cmplx64
172
- # Alias of {CA_DCOMPLEX}.
173
- CA_DCOMPLEX = :cmplx128
174
223
  # Platform-native size type alias; resolves to `:int64` on 64-bit
175
224
  # builds and `:int32` on 32-bit builds.
176
225
  CA_SIZE = :int64
177
226
 
178
227
  # @!endgroup
179
228
 
180
- # Byte alignment of each element type, used by `CArray.wrap` and
181
- # MemoryView interop helpers. Internal, not part of the user surface.
182
- CA_ALIGN_VOIDP = nil # :nodoc:
183
- CA_ALIGN_FIXLEN = nil # :nodoc:
184
- CA_ALIGN_BOOLEAN = nil # :nodoc:
185
- CA_ALIGN_INT8 = nil # :nodoc:
186
- CA_ALIGN_INT16 = nil # :nodoc:
187
- CA_ALIGN_INT32 = nil # :nodoc:
188
- CA_ALIGN_INT64 = nil # :nodoc:
189
- CA_ALIGN_FLOAT32 = nil # :nodoc:
190
- CA_ALIGN_FLOAT64 = nil # :nodoc:
191
- CA_ALIGN_CMPLX64 = nil # :nodoc:
192
- CA_ALIGN_CMPLX128 = nil # :nodoc:
193
- CA_ALIGN_OBJECT = nil # :nodoc:
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carray
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.6
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - himotoyoshi
@@ -37,14 +37,62 @@ email:
37
37
  executables: []
38
38
  extensions:
39
39
  - ext/extconf.rb
40
- extra_rdoc_files: []
40
+ extra_rdoc_files:
41
+ - yard-stubs/ca_obj_array.rb
42
+ - yard-stubs/ca_obj_bitarray.rb
43
+ - yard-stubs/ca_obj_bitfield.rb
44
+ - yard-stubs/ca_obj_block.rb
45
+ - yard-stubs/ca_obj_byte_swap.rb
46
+ - yard-stubs/ca_obj_fake.rb
47
+ - yard-stubs/ca_obj_farray.rb
48
+ - yard-stubs/ca_obj_field.rb
49
+ - yard-stubs/ca_obj_grid.rb
50
+ - yard-stubs/ca_obj_refer.rb
51
+ - yard-stubs/ca_obj_roll.rb
52
+ - yard-stubs/ca_obj_shift.rb
53
+ - yard-stubs/ca_obj_stride.rb
54
+ - yard-stubs/ca_obj_tile.rb
55
+ - yard-stubs/ca_obj_time.rb
56
+ - yard-stubs/ca_obj_transpose.rb
57
+ - yard-stubs/ca_obj_window.rb
58
+ - yard-stubs/carray_access.rb
59
+ - yard-stubs/carray_attribute.rb
60
+ - yard-stubs/carray_broadcast.rb
61
+ - yard-stubs/carray_cast.rb
62
+ - yard-stubs/carray_class.rb
63
+ - yard-stubs/carray_conversion.rb
64
+ - yard-stubs/carray_copy.rb
65
+ - yard-stubs/carray_core.rb
66
+ - yard-stubs/carray_count.rb
67
+ - yard-stubs/carray_element.rb
68
+ - yard-stubs/carray_generate.rb
69
+ - yard-stubs/carray_lazy.rb
70
+ - yard-stubs/carray_limits.rb
71
+ - yard-stubs/carray_loop.rb
72
+ - yard-stubs/carray_mask.rb
73
+ - yard-stubs/carray_math.rb
74
+ - yard-stubs/carray_mathfunc.rb
75
+ - yard-stubs/carray_median_percentile.rb
76
+ - yard-stubs/carray_memory_view.rb
77
+ - yard-stubs/carray_order.rb
78
+ - yard-stubs/carray_random.rb
79
+ - yard-stubs/carray_reduce.rb
80
+ - yard-stubs/carray_rng.rb
81
+ - yard-stubs/carray_scatter.rb
82
+ - yard-stubs/carray_segment.rb
83
+ - yard-stubs/carray_slab.rb
84
+ - yard-stubs/carray_sort.rb
85
+ - yard-stubs/carray_test.rb
86
+ - yard-stubs/carray_undef.rb
87
+ - yard-stubs/carray_utils.rb
88
+ - yard-stubs/ruby_carray.rb
41
89
  files:
42
90
  - ".yardopts"
43
91
  - CHANGELOG.md
44
- - CHANGELOG.v1.md
45
92
  - LICENSE
46
93
  - README.md
47
94
  - carray.gemspec
95
+ - docs/changelogs/CHANGELOG-3.0.md
48
96
  - ext/ca_array_pool.c
49
97
  - ext/ca_axis_descriptor.h
50
98
  - ext/ca_axis_dispatch.c
@@ -60,9 +108,11 @@ files:
60
108
  - ext/ca_composite_dispatch.h
61
109
  - ext/ca_for_buffer.h
62
110
  - ext/ca_group_iter.c
111
+ - ext/ca_iter_state_fields.h
63
112
  - ext/ca_iter_substrate.h
64
113
  - ext/ca_kernel_iterator.c
65
114
  - ext/ca_kernel_iterator.h
115
+ - ext/ca_kernel_iterator_internal.h
66
116
  - ext/ca_moncmp_dispatch.c
67
117
  - ext/ca_moncmp_dispatch.h
68
118
  - ext/ca_monop_dispatch.c
@@ -125,18 +175,15 @@ files:
125
175
  - ext/carray_attribute.c
126
176
  - ext/carray_bincount.c
127
177
  - ext/carray_broadcast.c
128
- - ext/carray_build_flags.h
129
178
  - ext/carray_call_cfunc.c
130
179
  - ext/carray_call_cfunc.h
131
180
  - ext/carray_cast.c
132
181
  - ext/carray_cast_func.rb
133
182
  - ext/carray_class.c
134
- - ext/carray_config.h
135
183
  - ext/carray_conversion.c
136
184
  - ext/carray_copy.c
137
185
  - ext/carray_core.c
138
186
  - ext/carray_count.c
139
- - ext/carray_data_type.c
140
187
  - ext/carray_element.c
141
188
  - ext/carray_factorize.c
142
189
  - ext/carray_generate.c
@@ -144,21 +191,8 @@ files:
144
191
  - ext/carray_hold.c
145
192
  - ext/carray_index_classifier.c
146
193
  - ext/carray_index_classifier.h
194
+ - ext/carray_integer_total.c
147
195
  - ext/carray_internal.h
148
- - ext/carray_kernels_bincmp.c
149
- - ext/carray_kernels_binop.c
150
- - ext/carray_kernels_init.c
151
- - ext/carray_kernels_moncmp.c
152
- - ext/carray_kernels_monop.c
153
- - ext/carray_kernels_reduce_aggregate.c
154
- - ext/carray_kernels_reduce_boolean.c
155
- - ext/carray_kernels_reduce_cumulative.c
156
- - ext/carray_kernels_reduce_extreme.c
157
- - ext/carray_kernels_reduce_variance.c
158
- - ext/carray_kernels_scan.c
159
- - ext/carray_kernels_search.c
160
- - ext/carray_kernels_sort.c
161
- - ext/carray_kernels_triop.c
162
196
  - ext/carray_key_windows.c
163
197
  - ext/carray_lazy.c
164
198
  - ext/carray_loop.c
@@ -204,11 +238,9 @@ files:
204
238
  - lib/carray/complex.rb
205
239
  - lib/carray/conditional.rb
206
240
  - lib/carray/const_string.rb
207
- - lib/carray/construct.rb
208
241
  - lib/carray/core_extensions.rb
209
- - lib/carray/data_type_extension.rb
210
- - lib/carray/data_type_limits.rb
211
242
  - lib/carray/distance_limit.rb
243
+ - lib/carray/factories.rb
212
244
  - lib/carray/fixlen_string.rb
213
245
  - lib/carray/frame.rb
214
246
  - lib/carray/frame/column_verbs.rb
@@ -232,6 +264,7 @@ files:
232
264
  - lib/carray/iterator.rb
233
265
  - lib/carray/key_windows.rb
234
266
  - lib/carray/lazy.rb
267
+ - lib/carray/limits.rb
235
268
  - lib/carray/mask_gap_fill.rb
236
269
  - lib/carray/math.rb
237
270
  - lib/carray/meld_reduce.rb
@@ -242,10 +275,10 @@ files:
242
275
  - lib/carray/methods/broadcast.rb
243
276
  - lib/carray/methods/choose.rb
244
277
  - lib/carray/methods/composition.rb
278
+ - lib/carray/methods/coordinate.rb
245
279
  - lib/carray/methods/discovery_along.rb
246
280
  - lib/carray/methods/factorize.rb
247
281
  - lib/carray/methods/gather_nd.rb
248
- - lib/carray/methods/index.rb
249
282
  - lib/carray/methods/insert_block.rb
250
283
  - lib/carray/methods/is_between.rb
251
284
  - lib/carray/methods/is_in.rb
@@ -263,6 +296,7 @@ files:
263
296
  - lib/carray/methods/unique.rb
264
297
  - lib/carray/methods/value_counts.rb
265
298
  - lib/carray/mkmf.rb
299
+ - lib/carray/percentile_arguments.rb
266
300
  - lib/carray/record_order.rb
267
301
  - lib/carray/rng.rb
268
302
  - lib/carray/runtime.rb
@@ -290,6 +324,7 @@ files:
290
324
  - yard-stubs/ca_obj_shift.rb
291
325
  - yard-stubs/ca_obj_stride.rb
292
326
  - yard-stubs/ca_obj_tile.rb
327
+ - yard-stubs/ca_obj_time.rb
293
328
  - yard-stubs/ca_obj_transpose.rb
294
329
  - yard-stubs/ca_obj_window.rb
295
330
  - yard-stubs/carray_access.rb
@@ -304,6 +339,7 @@ files:
304
339
  - yard-stubs/carray_element.rb
305
340
  - yard-stubs/carray_generate.rb
306
341
  - yard-stubs/carray_lazy.rb
342
+ - yard-stubs/carray_limits.rb
307
343
  - yard-stubs/carray_loop.rb
308
344
  - yard-stubs/carray_mask.rb
309
345
  - yard-stubs/carray_math.rb
@@ -312,6 +348,8 @@ files:
312
348
  - yard-stubs/carray_memory_view.rb
313
349
  - yard-stubs/carray_order.rb
314
350
  - yard-stubs/carray_random.rb
351
+ - yard-stubs/carray_reduce.rb
352
+ - yard-stubs/carray_rng.rb
315
353
  - yard-stubs/carray_scatter.rb
316
354
  - yard-stubs/carray_segment.rb
317
355
  - yard-stubs/carray_slab.rb
@@ -339,7 +377,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
339
377
  - !ruby/object:Gem::Version
340
378
  version: '0'
341
379
  requirements: []
342
- rubygems_version: 4.0.8
380
+ rubygems_version: 4.0.17
343
381
  specification_version: 4
344
382
  summary: Multi-dimensional numerical array class for Ruby
345
383
  test_files: []