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
@@ -0,0 +1,2464 @@
1
+ # Changelog: 3.0.0 to 3.1.0
2
+
3
+ The changes in each release from 3.0.0 to 3.1.0, newest first. Releases
4
+ after 3.1.0 are recorded in `CHANGELOG.md` at the top of the repository.
5
+
6
+ ## 3.1.0
7
+
8
+ The changes from 3.0.11 to 3.1.0.
9
+
10
+ - New: C extensions: `carray.h` declares `rb_ca_normalize_axis_arg`,
11
+ `rb_ca_obj2integer_fitting`, `ca_region_is_empty`, `ca_index_in_range`
12
+ and `ca_index_in_range_at`. An extension that calls them needs carray
13
+ 3.1.0 or later. The messages of the `CA_CHECK_*` macros open with the
14
+ name of the method that was called.
15
+
16
+ - New: `ri` finds the methods defined in C after a plain `gem install`.
17
+
18
+ - Change: removed `CArray#dim0`, `#dim1`, `#dim2` and `#dim3`. Use
19
+ `shape[k]`.
20
+
21
+ - Change: `CAMath.min` and `CAMath.max` answer in the type `pmin` and
22
+ `pmax` give, not in the type of the first CArray argument:
23
+ `CAMath.min(CA_INT64([3]), 2.5)` is a float64 array of `2.5`. With no
24
+ CArray among the arguments the answer is a Ruby number. An argument
25
+ that is neither a number nor a CArray is refused.
26
+
27
+ - Change: a one-argument `CAMath` function given a Ruby number answers as
28
+ for a one-cell array of it, with a Ruby number: `CAMath.abs(-2.5)` is
29
+ `2.5`, where it raised TypeError, and `CAMath.sqrt(-1.0)` is NaN, where
30
+ it raised `Math::DomainError`. An argument that is neither a number nor
31
+ a CArray is refused.
32
+
33
+ - Change: a method that reads its arguments by position refuses a keyword
34
+ it does not know with ArgumentError, where the keyword was read as an
35
+ index, a dimension, a count or an IO. `[]` still passes keywords on to
36
+ a method it calls by name (`a[:above, k: 4]`).
37
+
38
+ - Change: `&`, `|` and `^` between a boolean array and an object array
39
+ read each object cell as `true`, `false`, `1` or `0`, as a scalar
40
+ operand is read, in either order and lazily alike, and answer a boolean
41
+ array. A cell holding `0` was read as true. Any other cell is refused.
42
+
43
+ - Change: `CArray.load` raises ArgumentError for a trailer it cannot
44
+ read, as for any other corrupt data, where it raised an exception of
45
+ Psych.
46
+
47
+ - Fix: `linspace`, `span` and `scale` on a one-element array give the
48
+ start, where they raised ZeroDivisionError or gave NaN.
49
+
50
+ - Fix: `abs`, `abs2` and `arg` of a CScalar give a CScalar, where they
51
+ gave a one-cell CArray.
52
+
53
+ - Fix: an integer `sum`, `prod` or `wsum` along an axis of a `meld` view
54
+ or of a categorical iterator answers float64 when a total is out of the
55
+ integer range, as `sum` of an array does, where it wrapped.
56
+
57
+ - Fix: `convert(type, bytes: n)` passes `bytes:` on, where it raised
58
+ ArgumentError.
59
+
60
+ - Fix: a chain of views deeper than the machine stack raises
61
+ SystemStackError inside a Fiber too, where the process died with a Bus
62
+ Error.
63
+
64
+ - Fix: an operator refuses with TypeError an operand whose own `coerce`
65
+ does not return `[x, y]`, where it crashed, and `CArray#coerce` refuses
66
+ an operand whose `to_ca` does not return a CArray, where it recursed
67
+ without end.
68
+
69
+ - Fix: `pow!` with an Integer exponent, `random!`, `randomn!` and
70
+ `shuffle!` refuse a frozen or read-only array before writing to it.
71
+
72
+ - Fix: a lazy operation that has no kernel for an integer array is
73
+ refused before an Integer operand is read into it, as the eager
74
+ operation is.
75
+
76
+ - Fix: the error messages of many refusals name the method that was
77
+ called, and a refused weight, serializer input or Integer argument
78
+ says what was wrong instead of failing inside the library.
79
+
80
+ ## 3.0.11
81
+
82
+ This release continues the tidying of the public surface for 3.1: most
83
+ entries below refuse an input that was read in a way the caller may not
84
+ have meant, or make a method take the same keywords as its neighbours.
85
+ The C ABI is the one fixed in 3.0.10.
86
+
87
+ - New: `quantile` takes `min_count:` and `fill_value:` on arrays,
88
+ iterators and frames, as `percentile` and `median` do.
89
+
90
+ - New: `count(v)`, `search` and `search_addr` take a complex array. The
91
+ `tol:` of `search` is a distance in modulus.
92
+
93
+ - New: `wsum` and `wmean` take a boolean array and weigh its cells as 0
94
+ and 1.
95
+
96
+ - New: a boolean array reads text by its words: `1`, `0`, `true` and
97
+ `false` in any case, so `CA_BOOLEAN("1 0 1")` is `[true, false, true]`.
98
+ `to_type(:boolean)` reads a String cell the same way and makes any
99
+ other text UNDEF.
100
+
101
+ - Change: removed `CArray.wrap`. Ruby code wraps memory with
102
+ `CArray.wrap_memory_view`; a C extension calls `rb_carray_wrap_ptr`.
103
+
104
+ - Change: `CAFrame#unmask` takes its fill method as `method:`, as
105
+ `CArray#unmask` and `CAFrame#strip_mask` do. A Symbol given as the
106
+ second positional argument is now a value to fill with.
107
+
108
+ - Change: a time or a duration cell refuses an Integer. Write a raw tick
109
+ through `#ticks`. `CArray.time` refuses an Integer (with `format:`, an
110
+ Integer is still read as its digits), and a start or an origin of a
111
+ time refuses one. `CArray#time` still reads an integer array as ticks.
112
+
113
+ - Change: on a `:W` time array, `timesteps(unit: :W)` and week buckets
114
+ count from the ISO Monday, as `from_timesteps` and a day array do. The
115
+ array's own ticks are unchanged.
116
+
117
+ - Change: `min_index` and `max_index` of `blocks` index an edge tile as a
118
+ full tile, as `each` and `elements` see it.
119
+
120
+ - Change: `CArray.stack`, `meld`, `concatenate` and the other methods
121
+ that join arrays refuse to join an `int64` or `uint64` array with a
122
+ `float64` or `cmplx128` one when an integer in it is past 2\*\*53. Give
123
+ the type with `data_type:`.
124
+
125
+ - Change: `linspace`, `span!` and `scale!` take only real numbers as
126
+ their ends. `linspace` answers in float64 for Rational and BigDecimal
127
+ ends.
128
+
129
+ - Change: `then_else`, `conditional` and `CArray.select` answer an
130
+ object array when `true` or `false` stands beside numeric values.
131
+
132
+ - Change: these refuse an argument of the wrong kind instead of reading
133
+ it: `gather_nd`, `put_nd`, `meld` and `windows(on:)` with `TypeError`
134
+ (and float coordinates with `IndexError`); `raw:` that is not `true`
135
+ or `false`, with `ArgumentError`; a `clip` bound that is not a real
136
+ number on a numeric array; an `arange` argument that is not a number;
137
+ `real` and `imag` on a fixlen array and a Face; a second positional
138
+ argument to `wsum` and `wmean` of an object array; and a `percentile`
139
+ that is not a number in the segment-based iterators.
140
+
141
+ - Change: `CAFrame.from_csv` reads binary text as UTF-8 and refuses it
142
+ when it is not UTF-8. CSV reading and writing refuse a line end as
143
+ `quote:`.
144
+
145
+ - Change: `as_type` with a data class refuses a Face whose storage is not
146
+ its values, such as a const string. Use `#parent` to reach the
147
+ storage. A record and a fixlen string are unchanged.
148
+
149
+ - Change: C extensions only. `have_carray` from `carray/mkmf` configures
150
+ with the `carray.h` installed beside the loaded `carray_ext`.
151
+ `possible_includes` and `possible_libs` no longer search the home
152
+ directory, `~/usr`, `~/local`, `/sw`, `/usr/X11R6` or `/`; give such a
153
+ library with `--with-<name>-dir`. `POSSIBLE_PREFIX` is removed.
154
+
155
+ - Fix: `is_close` and `is_equiv` compare integers by value. An `int64`
156
+ array near 2\*\*62 matched a neighbouring integer, and a signed array
157
+ beside an unsigned one was compared in the unsigned type.
158
+
159
+ - Fix: `CAFrame#align` given a Ruby Array keeps the kind of a text or
160
+ categorical key, so a `CAConstString` key matches its values.
161
+
162
+ - Fix: in a Ractor other than the main one, the block methods, a
163
+ `CAObject`, the fields of a struct and its `Marshal`, and the error
164
+ from a refused time store work as in the main Ractor.
165
+
166
+ ## 3.0.10
167
+
168
+ This release fixes the C ABI for the rest of 3.x. Ruby code needs no
169
+ change. A C extension built against 3.0.10 or later loads against any
170
+ later 3.x release without being rebuilt.
171
+
172
+ - Change: C extensions only. An extension built against an earlier
173
+ release must be rebuilt: the array structs, `ca_iter_state` and the
174
+ type of `obj_type` changed layout. What the fixed ABI covers is listed
175
+ in `docs/authoring/WritingCExtensions.md` §18.3.
176
+
177
+ - Change: C extensions only. The installed headers declare only what an
178
+ extension may use. carray's own declarations moved to headers that are
179
+ not installed: the structs of its views other than `CArray`, `CAWrap`,
180
+ `CAView`, `CARefer` and `CAStride`, the C bodies of most Ruby methods,
181
+ `ca_func[]`, `ca_cast_func_table`, the index parser, and the iterator's
182
+ own fields. A name that no installed header declares belongs to carray.
183
+ An `extconf.rb` finds the installed headers with `have_carray` from
184
+ `carray/mkmf`.
185
+
186
+ - Change: C extensions only. An extension installs its operation table
187
+ with `ca_install_obj_type`, and copies an existing table with the new
188
+ `ca_operation_table_copy`, instead of writing `ca_func[]`.
189
+
190
+ - Change: C extensions only. `obj_type` is `int16_t` in every function
191
+ signature, and `CA_OBJ_TYPE_MAX` is 1024.
192
+
193
+ - Change: C extensions only. `ca_iter_state` has a fixed size,
194
+ `CA_ITER_STATE_SIZE` (6144 bytes). An extension sees only the fields a
195
+ kernel reads, and those keep their offsets.
196
+
197
+ - Change: C extensions only. Removed: the old type-name enum values
198
+ `CA_BYTE`, `CA_SHORT`, `CA_INT`, `CA_FLOAT`, `CA_DOUBLE`, `CA_COMPLEX`
199
+ and `CA_DCOMPLEX` (use `CA_UINT8`, `CA_INT16`, `CA_INT32`,
200
+ `CA_FLOAT32`, `CA_FLOAT64`, `CA_CMPLX64` and `CA_CMPLX128`), and the
201
+ macro `CA_SLAB_REDUCE_T_VAR_EX`.
202
+
203
+ ## 3.0.9
204
+
205
+ This release continues the tidying of the public surface for 3.1: most
206
+ entries below rename a method or a keyword, remove a second name, or
207
+ refuse an input that was read in a way the caller may not have meant.
208
+ Each says what to write instead.
209
+
210
+ - New: `CArray.new(type, shape, raw: true)` leaves out the zero fill.
211
+
212
+ - New: the lazy comparisons and three-operand expressions have `inspect`,
213
+ `dump_tree` and `parents`, as the other lazy expressions do. A lazy
214
+ `inspect` shows an operand that is not lazy by its class, data type and
215
+ shape instead of its values.
216
+
217
+ - New: `CArray::Histogram` and `CArray::BincountND` have an `inspect`
218
+ that shows the data type and shape of the counts, with the total or the
219
+ fiber shape.
220
+
221
+ - New: the documentation of `CArray::Rng` says what a seed repeats: for a
222
+ given seed, `bits`, `random`, `random!` and `shuffle!` give the same
223
+ values in every version and on every machine. `randomn` may differ in
224
+ the last place.
225
+
226
+ - Change: removed second names. `reverse` (use `flip` with no argument),
227
+ `cmp` (use `<=>`), `virtual?` (use `view?`), `bits` (use `bitarray`),
228
+ `invert_mask` (use `mask = is_not_masked`), and
229
+ `CAConstString#byte_length` (use `bytesize`).
230
+
231
+ - Change: renamed methods. `index(axis:)` and `indices` are
232
+ `coordinate(axis:)` and `coordinates`. On `CAFrame`, `fill` is
233
+ `unmask` and `mask_eq` is `mask` (`CArray#mask_eq` is unchanged);
234
+ `CAGroupedFrame#fill` is `unmask` and `CAGroupedFrame#size` is
235
+ `group_sizes`. `BincountND#overflow` and `#overflow_total` are `over`
236
+ and `outlier_total`, the names `Histogram` uses.
237
+
238
+ - Change: renamed keywords and choices. `CAFrame#resample(fill:)` is
239
+ `keep_empty:`. The distance of a match in `search` is `tol:`. The fill
240
+ of `clip`, `lookup` and `project` is `fill_value:` (`clip` also takes
241
+ `lfill:` and `ufill:`). The hold fill is `:forward` / `:backward` only.
242
+ The filled margin of `windows` and `window` is `bounds: :fill`.
243
+ `windows` needs `fill_value:` with it; `window` fills with 0 unless
244
+ `fill_value:` is given, and takes `bounds:` as a Symbol only.
245
+ `meshgrid(indexing:)` takes `:xy` or `:ij`, not a String.
246
+
247
+ - Change: changed argument forms. `CArray.full(*shape, fill_value:,
248
+ data_type: nil)` takes its shape as `zeros` does. `CArray.empty` reads
249
+ its arguments as `zeros` does (shape first, `data_type:` as a keyword).
250
+ `CArray.from_bit_string` takes `data_type:` and `shape:` as keywords,
251
+ and the instance form is removed. A `CATime::Grid` is given as
252
+ `unit:` only, in `floor`, `ceil`, `round`, `snap`, `end_of`,
253
+ `timesteps`, `is_righttime`, `from_timesteps` and `CAFrame#to_time`.
254
+ `unmask` needs a fill value or `method:`; `mask = false` clears the
255
+ mask without one.
256
+
257
+ - Change: renamed and moved classes and modules. The mask classes are
258
+ `CArray::Mask`, `CABlock::Mask` and so on (a mask Marshal-dumped on
259
+ its own by an earlier version no longer loads). `CAMaskOfOperands` is
260
+ `CArray::MaskOfOperands`, `UndefClass` is `CArray::UndefClass`,
261
+ `AxisGroup` is `CAAxisGroup`, `GroupLabels` is `CArray::GroupLabels`,
262
+ `GroupedFrame` and `WindowedFrame` are `CAGroupedFrame` and
263
+ `CAWindowedFrame`, the result of `CArray.scan_index` is
264
+ `CArray::IndexInfo`, and the `CATime` helper modules are under `CATime`
265
+ (`CATimeGrid` is `CATime::Timestep`).
266
+
267
+ - Change: removed constants. `CA_OBJ_*`, `CA_REG_*` (`CArray.scan_index`
268
+ names the region type with a Symbol), `CA_ALIGN_*`, `CA_BIG_ENDIAN` and
269
+ `CA_LITTLE_ENDIAN` (`CArray.endian` answers `:big` or `:little`, and
270
+ `endian:` takes a Symbol only). `CA_RANK_MAX` is `CArray::RANK_MAX`.
271
+ The C type names `byte`, `short`, `int`, `float`, `double`, `complex`
272
+ and `dcomplex` are no longer data type names, and `char_p` is no longer
273
+ a struct member type (a fixed-length member is `fixlen`). For C
274
+ extensions, the C macros and enums of the same names stay.
275
+
276
+ - Change: methods and constants used only inside CArray are private:
277
+ the internal kernel names, the Face hooks, the helpers of the iterators,
278
+ the axis group and the struct builder, `marshal_dump`, `marshal_load`
279
+ and `_dump`, and the internal constants of `CArray`, `CAFrame`,
280
+ `CACategorical`, `CAIterator` and `CATime`. `Histogram#m` and `#n_list`
281
+ and `BincountND#m` and `#lengths` are no longer public; `counts.shape`
282
+ gives the same lengths.
283
+
284
+ - Change: a Ruby type number is no longer a data type: `to_type(8)`,
285
+ `CArray.new(8, ...)` and the other methods that read a data type from
286
+ Ruby raise `ArgumentError`. Name the type (`:int64`). For C extensions,
287
+ `rb_ca_wrap_readonly`, `rb_ca_to_type` and `rb_ca_guess_type` still
288
+ take the number.
289
+
290
+ - Change: a number cell takes only a Numeric. `a[0] = "12"`,
291
+ `fill("3")`, `CA_INT32(["12"])` and storing a `Time` raise
292
+ `TypeError`. An object array converted by `to_type` or `as_type` still
293
+ reads its text, and so does `CA_INT32("1 2 3")`.
294
+
295
+ - Change: a bare `UNDEF` is refused as the operand of an operator, a bang
296
+ method, a lazy expression, a weight or a pick by order, as `nil` is.
297
+ Compute with a masked `CScalar` instead. `UNDEF.dup`, `clone` and a
298
+ Marshal round trip give `UNDEF` itself.
299
+
300
+ - Change: `#time` and `#timedelta` read an integer array as seconds, as
301
+ `CArray.time` reads an Integer. Pass `unit: :ns` for the old reading.
302
+
303
+ - Change: a `CATime::Grid` of weeks with no origin counts from the ISO
304
+ Monday in `at`, `series` and `range`, as `timesteps` does.
305
+
306
+ - Change: the integer `cumsum` and `cumprod` answer int64 (uint64 for an
307
+ unsigned array), as `sum` and `prod` do. `wsum` of an integer array
308
+ with integer weights answers an integer total, as `sum` does, in the
309
+ core and in the iterators.
310
+
311
+ - Change: the `mean`, `variance` and `wmean` of an object array of
312
+ Integers are exact Rationals, as `median` is.
313
+
314
+ - Change: `index(axis:)` (now `coordinate`), `indices` and `address`
315
+ answer int64 instead of int32.
316
+
317
+ - Change: `sort_addr` and `sort_by_key` without an axis order the whole
318
+ array and answer a flat result, as `sort` and `sort_index` do.
319
+
320
+ - Change: a float64 array with a cmplx64 array gives cmplx128, and a
321
+ Complex scalar beside a float32 array gives cmplx64. `arange`,
322
+ `linspace` and `full` give float64 when Integer and Float arguments
323
+ are mixed. Joining arrays whose common type would change some of their
324
+ values is refused.
325
+
326
+ - Change: a data class (a struct class from `CArray.struct`) given as a
327
+ data type answers with a record array or a refusal. `as_type`, `fake`,
328
+ `wrap_readonly` and `wrap_writable` read fixlen cells of the class's
329
+ size as records and refuse other arrays; `to_type` of an object array
330
+ of its instances gives records; `template`, `CArray.wrap`,
331
+ `CAObject.new`, the `data_type:` of `map_slab` and `convert` refuse
332
+ it. Make a record array with `CARecord.new`.
333
+
334
+ - Change: an iterator's `reduce(init)` leaves out masked cells and cells
335
+ outside a window, and starts each piece from its own copy of `init`.
336
+ The slab iterator's `each` returns the iterator, and its `reduce`
337
+ answers an object array, as the other iterators do.
338
+
339
+ - Change: more inputs are refused where they were read loosely: a
340
+ keyword that takes true or false and is given another value; a
341
+ `skip_masked:` that is not true or false in the iterators' `all` /
342
+ `any`; a non-String in `CArray.fixlen_string`, `const_string` and the
343
+ string Faces' `in?`; `nil` as the data of `CA_INT32`, `wrap_readonly`
344
+ and `wrap_writable`; a String that is not a whole number of cells; a
345
+ `scatter_add!` (and the other `scatter_*!`) value the receiver's type
346
+ cannot hold; a `bytes:` for a type other than fixlen; a second argument
347
+ to an iterator's `reduce`; `windows(fill_value:)` with a `bounds:`
348
+ other than `:fill`; a decreasing list in `snap_to`; a negative or NaN
349
+ tolerance in `is_close` and `is_equiv`; a Complex bound in `arange` and
350
+ `linspace`; a `categorize(labels:)` that is not a list; a struct
351
+ `pack:` other than nil or 1; `CAFrame#to_table(precision:, rows:)`
352
+ that is not a non-negative Integer; a block given to `CAFrame#select`
353
+ or `drop`, and `drop` with no column name; `is_real` and `real?` on an
354
+ array that is not numeric.
355
+
356
+ - Change: `dim0` to `dim3` are deprecated, to be removed in 3.1.0. Use
357
+ `shape[k]`.
358
+
359
+ - Change: `real` and `imag` return a new view on each call.
360
+ `nunique(keep_axis: true)` without `axis:` keeps every axis as length
361
+ 1, as `sum` does. The `median` of an empty 1-D array along its only
362
+ axis is `UNDEF`.
363
+
364
+ - Fix: `to_bit_string` returned the inspect text instead of the packed
365
+ bytes.
366
+
367
+ - Fix: `real` of an object array returned the cells unchanged.
368
+
369
+ - Fix: a refused `CArray.save` truncated the file before checking the
370
+ options.
371
+
372
+ - Fix: `linspace` floored float32 and complex results.
373
+
374
+ - Fix: a group iterator's plain scan (`cumsum(axis:)` and the others)
375
+ dropped `axis:`.
376
+
377
+ - Fix: `sort` and the other methods that build a result array ran a
378
+ block given to them.
379
+
380
+ - Fix: the segment and categorical iterators' `map` widened the value
381
+ to float64. The axis group's `wmean` of integer values divided as
382
+ integers.
383
+
384
+ - Fix: a `CASource` of another gem dumped with Marshal but did not load.
385
+ It loads as a plain array, as a wrap does.
386
+
387
+ - Fix: a cell of a `CACategorical` read as the label object itself, so
388
+ changing it in place changed every cell with that code.
389
+
390
+ - Fix: Faces written in Ruby. A whole store of another data type and
391
+ `seq!` did not reach the storage, the parent was handed out writable,
392
+ and storing a plain object array into a Face with integer storage was
393
+ refused.
394
+
395
+ - Fix: the `inspect` of an object array that holds a lazy expression of
396
+ itself was refused as cyclic.
397
+
398
+ ## 3.0.8
399
+
400
+ This release tidies the public surface before 3.1. Most entries below
401
+ remove a second way to write something or refuse an input that was read
402
+ in a way the caller may not have meant; each says what to write instead.
403
+
404
+ - New: `CArray::Limits` holds the range of each numeric type:
405
+ `CArray::Limits::INT32_MAX`, `UINT8_MIN`, `FLOAT64_EPSILON`,
406
+ `FLOAT32_TINY` and the rest. A complex type uses the constants of its
407
+ float type.
408
+
409
+ - New: `CArray#view?`, the opposite of `entity?`. `virtual?` remains as
410
+ the old name.
411
+
412
+ - New: `zeros`, `ones`, `eye`, `identity`, `linspace`, `arange` and
413
+ `full` take the element type as `data_type:`, e.g.
414
+ `CArray.zeros(3, 4, data_type: :int32)`.
415
+
416
+ - Change: the classes `CArray::Int32`, `CArray::Float64` and the others
417
+ for each data type are removed, with the Numo names `SFloat`, `DFloat`,
418
+ `SComplex`, `DComplex` and `RObject`. Name the type with `data_type:`:
419
+ `CArray.from_memory_view(obj, data_type: :float64)`,
420
+ `CArray.wrap_memory_view(obj, data_type: :int16)`,
421
+ `CArray.linspace(0, 10, 5, data_type: :int32)`. The limits that were
422
+ constants on the classes (`CArray::Int32::MAX`) are in
423
+ `CArray::Limits`. `CArray.int32` and the other type methods without a
424
+ shape raise `ArgumentError` instead of returning a class. For C
425
+ extensions: `rb_cCArrayInt32` and the others, and
426
+ `ca_data_type_class`, are removed from `carray.h`.
427
+
428
+ - Change: a Ruby Array is no longer an index. `a[[start, count, step]]`
429
+ raises `TypeError`; write a Range (`a[start...start + count]`,
430
+ `a[(start..) % step]`) or, for a list of positions, a CArray
431
+ (`a[CA_INT64(ary)]`).
432
+
433
+ - Change: a Ruby Array is no longer an operand of a numeric or boolean
434
+ array (`a + [1, 2, 3]`), nor a value of `then_else`, `select` or
435
+ `conditional` beside numeric values, nor weights of `histogram`,
436
+ `bincount` and `bincount_nd`. Make it a CArray of the type you mean
437
+ first, e.g. `CA_FLOAT64(ary)`.
438
+
439
+ - Change: `CArray#order` is folded into `rank_index`, and `order` is
440
+ renamed `rank_index` on the iterators and on `CAFrame`.
441
+
442
+ - Change: removed second names. `fmax` / `fmin` (use `pmax` / `pmin`),
443
+ `power` / `power!` (use `**` / `pow` / `pow!`), `as_float128` and
444
+ `as_cmplx256`, `CAWindow#fill_value=`, `CACategorical#bincount`,
445
+ `CAIterator#dim` (use `shape`). `GroupedFrame#ngroup` is `ngroups`.
446
+
447
+ - Change: the array an iterator walks is `source` on every iterator
448
+ (it was `reference` on the slab iterator and `value` on the group
449
+ iterators).
450
+
451
+ - Change: `CAFrame#parse_to_time` is `parse_time`, and the `epoch:`
452
+ keyword of `CAFrame#to_time` is `origin:`.
453
+
454
+ - Change: `percentile` answers in the form `p` is written in, on arrays
455
+ and iterators: one `p` (a Numeric or a CScalar) gives one answer, an
456
+ Array of `p` an Array, and several `p` or a CArray of `p` one CArray
457
+ with the `p` axes in front. An Array of one `p` used to give a bare
458
+ answer. A frame takes one `p` only (a Numeric or a CScalar).
459
+
460
+ - Change: `roll` needs one shift per axis, as `shift` does. `a.roll(1)`
461
+ on a 2-D array used to roll axis 0 alone; write `a.roll(1, 0)`.
462
+
463
+ - Change: `window` takes `bounds:` `:fill`, `:nearest`, `:ruby` or
464
+ `:strict`; `:mask`, `:periodic` and `:reflect` raise. For masked cells
465
+ outside, give `fill_value: UNDEF`. `CAWindow#bounds` returns a Symbol.
466
+
467
+ - Change: `windows` no longer reads the window geometry from a
468
+ `CAWindow` view (`CAWindowIterator.new(a.window(...))`); a CAWindow is
469
+ rolled over like any other array. `blocks` takes only Integer tile
470
+ sizes; the `lo..hi` offset form is gone.
471
+
472
+ - Change: a Symbol in an index that names a method (`a[:gt, 0]`) must
473
+ return a boolean array of the array's shape, and keywords after the
474
+ Symbol are passed to the method. Any other one-character Symbol than
475
+ the index markers raises `IndexError`, and a struct member is named by
476
+ a String. A single `:%` on an array of more than one axis raises
477
+ instead of flattening it.
478
+
479
+ - Change: the sum and product of an integer array are `int64` (or
480
+ `uint64` for an unsigned array) while they fit, and `float64` past that
481
+ range; a wrapped total is never returned. Along an axis the answer is
482
+ `float64` as a whole if any cell is. Use `accumulate` for a sum that
483
+ wraps in the array's type.
484
+
485
+ - Change: a Ruby Integer that an integer array's type can not hold is
486
+ taken by what the operation does with it: `+ - * & | ^` give the answer
487
+ modulo 2 ** bits, `pmax` and the like take it at the type's bound when
488
+ it can never be picked, and `/ % divmod fmod` raise `RangeError`.
489
+ Comparisons, `count` and `search` answer by value.
490
+
491
+ - Change: beside a boolean array, `& | ^` (and `and!`, `or!`, `xor!`)
492
+ read `1` and `0` as `true` and `false` and refuse other numbers. Beside
493
+ a numeric array, `is_in` and the other value-set methods read `true`
494
+ and `false` as `1` and `0`.
495
+
496
+ - Change: storing `nil` into a numeric or boolean cell raises the same
497
+ `TypeError` for every type (it was `CArray::DataTypeError` for a
498
+ boolean cell); write `UNDEF` to mask a cell. `scatter_*!` takes nil
499
+ and text with no number as a store does.
500
+
501
+ - Change: `eq`, `ne`, `count` and `search` on a `CATime` or
502
+ `CATimedelta` array find no cell for a value no time can be, as a
503
+ numeric array finds none for `nil`.
504
+
505
+ - Change: a `fill_value:` with a fraction for an integer answer raises
506
+ `ArgumentError`; a sum or product takes an out-of-range `fill_value:`
507
+ as `float64`.
508
+
509
+ - Change: `CArray#to_s` returns the `inspect` text, so interpolation and
510
+ `puts` show the array. `io.write(a)` writes that text; use
511
+ `dump_binary` for the bytes.
512
+
513
+ - Change: for C extensions, `CA_REG_MAPPING` is renamed
514
+ `CA_REG_ADDRESS_ARRAY`.
515
+
516
+ - Change: the C type names for data types (`:int`, `:float`, `:double`,
517
+ `CArray.byte` and the rest) are marked deprecated in the
518
+ documentation, which now writes the width names (`:int32`, `:float64`,
519
+ `CArray.uint8`). They keep working.
520
+
521
+ - Fix: autoloaded methods load from any Ractor on Ruby 4.0 and later.
522
+ Ruby 3.4 still refuses it, as Ruby 3.4 deadlocks there.
523
+
524
+ - Fix: the product of an integer array along an axis is 0, not NaN,
525
+ where a float64 overflow came before a zero factor.
526
+
527
+ ## 3.0.7
528
+
529
+ - New: `CATime` and `CATimedelta` take the word forms of their operators
530
+ (`add`, `sub`; on a duration also `mul`, `div`, `neg`). A duration array
531
+ divided by one duration gives the ratios as numbers, a number may stand
532
+ left of a duration (`2 * d`), a duration element has `-@` and `abs`, and
533
+ a duration array has `to_seconds`. A duration's comparisons and stores
534
+ take a String such as `"3 days"`.
535
+
536
+ - New: `pmax` and `pmin` (with `maximum`, `minimum`, `fmax`, `fmin`) on
537
+ `CATimedelta`, `CAFixlenString` and `CAConstString`. `CAConstString`
538
+ also has `match`, `bsearch`, `bsearch_addr`, `search_addr`, `min_addr`
539
+ and `max_addr`.
540
+
541
+ - New: a `CAFixlenString` carries the encoding of its text
542
+ (`a.encoding`), and its cells read in that encoding: UTF-8 when the
543
+ strings were ASCII, `BINARY` when they disagreed. `to_const_string`
544
+ keeps it, so non-ASCII text comes back from `to_fixlen_string`. Two
545
+ arrays of different text encodings no longer stack.
546
+
547
+ - New: `CAFrame#resample` takes a `CArray` as `by:`, and a windowed
548
+ reduction takes a Hash of column name to value as `fill_value:`.
549
+ `CACategorical#count` takes the keywords of `CArray#count`, and the
550
+ `all` and `any` of a categorical iterator take `axis:`.
551
+
552
+ - New: `CArray.from_memory_view` and `wrap_memory_view` take an item of
553
+ several members (a record) as raw bytes, a `fixlen` array of the item's
554
+ size.
555
+
556
+ - Change: a Float is refused as a shape, a size or a count
557
+ (`CArray.int32(2.5)`, `blocks(2.5)`, the counts of `repeat`), whole or
558
+ not; it was cut down to an Integer. A Float key of `[]` still reads as a
559
+ position.
560
+
561
+ - Change: a data type name must match whole. `:complex128`, `:float16` or
562
+ `:int128` raise `ArgumentError`; they were read as the type whose name
563
+ they begin with (`:complex128` gave `cmplx64`). Write `:cmplx128`.
564
+ `CArray::Complex64::TypeSymbol` and `CArray::Complex128::TypeSymbol` are
565
+ `:cmplx64` and `:cmplx128`.
566
+
567
+ - Change: a keyword given with a String key (`a.sum("axis" => 0)`) raises
568
+ `ArgumentError`; it was ignored. Write `axis: 0`.
569
+
570
+ - Change: storing complex cells into a real array raises; the imaginary
571
+ parts were dropped. Convert with `to_type` first.
572
+
573
+ - Change: an object or boolean array given where addresses are expected
574
+ (`project`, `scatter_add!` and the other `scatter_*!`, `addr2index`)
575
+ raises `IndexError`. A boolean array still selects in `[]`.
576
+
577
+ - Change: a value a numeric or boolean array cannot hold (`nil`, a String,
578
+ a Symbol, another object) is answered alike for every data type: an
579
+ operator raises `TypeError`, an ordering (`<`, `pmax` and its kin)
580
+ raises `ArgumentError`, and `eq`, `ne`, `count`, `search` and `is_in`
581
+ find no cell. `search("2")` on a numeric array used to read the text.
582
+ `true` and `false` are 1 and 0, so `count(true)` counts the cells
583
+ holding 1. An object array still looks such values up as values.
584
+
585
+ - Change: `UNDEF` beside an array in an operation is a masked scalar of the
586
+ array's own type, so `CA_INT32([1, 2]) + UNDEF` is an all-masked `int32`
587
+ array; integer, boolean and fixlen arrays gave an object array.
588
+
589
+ - Change: `to_type` to an integer type gives `UNDEF` for an object Float,
590
+ Rational, BigDecimal or Complex the type cannot hold, and keeps the low
591
+ bytes of an object Integer wider than 64 bits, as `int64` to `int8` does.
592
+ A store and a view still refuse such values.
593
+
594
+ - Change: `x ** k` with an Integer `k` from -2 to 4 is computed by at most
595
+ two multiplications or divisions (`x ** 2` is `x * x`), and other Integer
596
+ exponents through `pow`, for a scalar and an array exponent alike,
597
+ eagerly and lazily. Float and complex results can differ from 3.0.6 in
598
+ the last bit.
599
+
600
+ - Change: a time or a date with a year past four digits is written with
601
+ its sign (`"+12345-01-01"`), in `to_s` and in CSV, so it reads back.
602
+
603
+ - Change: `join`, `join_asof`, `align`, `CAFrame.concatenate`, `stack` and
604
+ `stack_columns` refuse integers that the float type they meet would
605
+ round (past 2**53 beside `float64`), in a key or in the pieces of a
606
+ column; such integers matched or merged with neighbouring values. Cast
607
+ one side to the other's type first.
608
+
609
+ - Change: the frames that `GroupedFrame`, the windows and a frame's own
610
+ verbs return hold a copy of the index, so a write to the result's index
611
+ does not reach the source frame.
612
+
613
+ - Change: `CAFrame` refuses, with an `ArgumentError` that names the verb,
614
+ a `GroupedFrame#table` or `#filter` without a block, a `lag` step that is
615
+ not an Integer, a `columns:` Range that selects no column, a
616
+ `fill_value:` Hash naming no column, a row-wise group verb with no column
617
+ left to compute, and a splice of a frame without an index into one with
618
+ an index.
619
+
620
+ - Change: CSV type inference reads a column as text when a float would
621
+ round one of its integers, and an object column of Integers past 2**53
622
+ beside a Float is not inferred as `float64`.
623
+
624
+ - Change: a walk into object cells (`unique`, `hash`, `Marshal.dump`,
625
+ computations over the cells) raises past 256 levels of nesting. A cell
626
+ holding a lazy expression over the array that holds the cell made these
627
+ run without end.
628
+
629
+ - Change: a String Face (`CAString`, `CAFixlenString`, `CAConstString`)
630
+ refuses an ordering with a value that is not a String, and a Face
631
+ refuses a single Ruby object as the operand of an operator the Face does
632
+ not define.
633
+
634
+ - Change (C extensions and carray-jit): `CArray::AddressBasis.sweep` and
635
+ the sweep bridge refuse a `CScalar` output beside an array operand.
636
+
637
+ ## 3.0.6
638
+
639
+ - New: `CAFrame` answers the column reductions itself, as a frame of one
640
+ row (`df.mean`, `df.sum("rain", "temp")`), and the running values down
641
+ all its rows (`df.cumsum("rain")`, `order`), as a grouped frame does
642
+ down each group. `percentile(p, *names)` and `quantile` (a column per
643
+ quartile, `"rain_p0"` ... `"rain_p100"`) are added to the frame, groups
644
+ and windows.
645
+
646
+ - New: `CAFrame` row picks: `nlargest` / `nsmallest` (also on
647
+ `GroupedFrame`), `drop_masked` for the rows with no masked cell,
648
+ `GroupedFrame#head` / `#tail` for the first and last rows of each group,
649
+ and `filter` given a boolean selector directly (`df.filter(df["n"] > 3)`).
650
+
651
+ - New: `CAFrame#transform` computes columns with a block, keeping their
652
+ names and the index. `select`, `drop`, `transform` and `describe` pick
653
+ columns by a Range of names, a Regexp, a kind (`:float`, `:integer`,
654
+ `:complex`, `:timedelta`, ...) or a data type.
655
+
656
+ - New: `CAFrame#value_counts` (how many rows hold each value, as a
657
+ frame), `#strip_mask` (the masked cells filled, in a new frame), `#to_a`
658
+ (the rows as Arrays, masked cells `UNDEF`), `#shape`, `#empty?`, and
659
+ `GroupedFrame#each` and `#size`. `CAFrame#==` compares two frames by
660
+ their table: names, columns, index and row axis name.
661
+
662
+ - New: `CAFrame#lag` and `GroupedFrame#lag` take a distance of the key,
663
+ `before: "1 hour"` or `after:`, giving each row the value of the row at
664
+ exactly that distance (`UNDEF` where there is none). The key is the
665
+ index or the column `on:` names: a time, a duration or a number.
666
+
667
+ - New: `join` and `join_asof` take a key named differently on the two
668
+ sides, and `view: :full`, which gives every column of the result as a
669
+ view, with holes for the unmatched rows, so a write reaches either
670
+ frame.
671
+
672
+ - New: `df[name] = value` with a single value repeats it on every row.
673
+ `fill` takes several columns, an Array of names or a Hash of column =>
674
+ value; `rename` takes a block, can exchange two names, and renames the
675
+ index under its name. `sort_by_key` and `sort_by` take `descending:`.
676
+
677
+ - New: `CAFrame#set_column_attrs` gives columns their names and common
678
+ attributes; `CArray#attrs_symkey` and `CAFrame#attrs_symkey` return the
679
+ attributes with Symbol keys. `CAFrame#to_csv` takes `precision:`.
680
+
681
+ - New: `GroupedFrame#fill(name, :linear)` interpolates within each group.
682
+ On a frame, `:linear` reads an index that is not in order as one series
683
+ in index order.
684
+
685
+ - New: `melt` brings number columns of different types (an `int64` and a
686
+ `float64` column) to their common type, still as a view. A mixture no
687
+ type holds without changing a value (`int64` beside `uint64`), or one
688
+ with text or time, is refused; cast the columns first.
689
+
690
+ - New: `wsum` and `wmean` take weights shaped as the reduced axes, matched
691
+ in ascending axis order, besides a scalar and weights of the receiver's
692
+ shape.
693
+
694
+ - New (C extensions and carray-jit): `CArray::AddressBasis.sweep(function,
695
+ fsync, arrays, *parts)` runs a chunked element-wise sweep
696
+ (`ca_call_cslab_N_r`, arities 1 to 7) from Ruby, handing the slab
697
+ pointers to the parts' own String bytes. An `fsync` character other than
698
+ `0` or `1` is refused.
699
+
700
+ - Change: CArray requires Ruby 3.2 or later, up from 3.0. On an older
701
+ Ruby, `gem install carray` does not offer this release; install a
702
+ newer Ruby with a version manager such as rbenv or mise, or stay on
703
+ 3.0.5.
704
+
705
+ - Change: CSV reading and writing are split by what they take.
706
+ `CAFrame.read_csv` and `#write_csv` take a path or an IO;
707
+ `CAFrame.from_csv` takes CSV text as a String and `#to_csv` returns it.
708
+ Code that gave `from_csv` a path or an IO calls `read_csv`, and
709
+ `to_csv(path)` becomes `write_csv(path)`. No aliases are kept.
710
+
711
+ - Change: `read_csv` and `from_csv` infer the column types by default
712
+ (`int64`, `float64`, `boolean`, `time`, otherwise text); `types:` names
713
+ some columns and the rest are still inferred. Pass `types: :string` to
714
+ read every column as text, as before. A column with a blank but present
715
+ value (a quoted `""`) stays text.
716
+
717
+ - Change: `CAFrame#set_index`, `#reset_index`, `#cast`, `#promote`,
718
+ `#parse_to_time` and `#to_time` return a new frame and leave the
719
+ receiver as it is (the two share their columns). Assign the result:
720
+ `df = df.set_index("time")`.
721
+
722
+ - Change: a `GroupedFrame` reduction given column names returns a frame of
723
+ those columns, one row per group, labelled as without names; it
724
+ returned the `CArray` (one name) or an `Array` of them. Take the column
725
+ (`grp.mean("temp")["temp"]`) or reduce the group iterator
726
+ (`grp["temp"].mean`) for the values alone.
727
+
728
+ - Change: a `GroupedFrame` or window value on the frame's rows given
729
+ several column names (`keep_rows: true`, the running values, `lag`,
730
+ `w.mean("a", "b")`) returns a frame of them on the frame's rows and
731
+ index, instead of an `Array`. One name still gives the `CArray`.
732
+
733
+ - Change: `CAFrame#filter` no longer takes `keep_masked:`, so every row
734
+ selection is a view. To keep the rows whose condition is undetermined,
735
+ say so in the selector: `df.filter(cond.is_masked)` or
736
+ `df.filter(cond.strip_mask(true))`.
737
+
738
+ - Change: `df[sel] = ...` refuses a Ruby Array as the row selector, as
739
+ `df[]` does; the column indexer would read `[0, 2]` as two rows from
740
+ row 0. Write `df[CA_INT64([0, 2])]` for rows 0 and 2.
741
+
742
+ - Change: a group key named in a `GroupedFrame` reduction, and the index's
743
+ name given to a verb that reads or changes columns (`df[...]`,
744
+ `select`, `fill`, `cast`, the reductions), raise and point at `size`
745
+ or `df.index`. A key argument (`group_by`, `sort_by_key`, `join(on:)`)
746
+ still names the index.
747
+
748
+ - Change: an `:inner` or `:right` `join` gives the other frame's columns
749
+ as views picked by row, not copies, so a write to them reaches that
750
+ frame. Call `copy` on the result to keep it apart.
751
+
752
+ - Change: a `CScalar` takes only `s[]` and `s[0]`, reading or writing its
753
+ one cell; any other index (`s[3]`, a range, `nil`, an index array)
754
+ raises. A view such as `s.refer(s.data_type, [1])` takes the usual
755
+ indexes.
756
+
757
+ - Change: `CArray.stack` and `CArray.meld` refuse a value array
758
+ (`a.value`) or a mask array (`a.mask`) as a part. Pass a copy
759
+ (`a.value.copy`), or `a.is_masked` for the mask's values.
760
+
761
+ - Change: `CArray#==` finds a NaN equal to a NaN, so an array holding NaN
762
+ equals its copy and the array read back from a file. The cell-by-cell
763
+ IEEE comparison is `eq`; `eql?` still compares bits.
764
+
765
+ - Change: `CARemap#mapper` returns a read-only array; writing it raises.
766
+ The index array given to `a[idx]` is not affected.
767
+
768
+ - Change: `Marshal.dump` of a `CAWrap` (from `CArray.wrap_memory_view`)
769
+ writes its values, and the load gives a plain array owning a copy of
770
+ them, as for a view of the wrap; it raised `TypeError`.
771
+
772
+ - Change: `as_type` returns a view also when the data type is the
773
+ receiver's own, and `CATime#to_unit` / `CATimedelta#to_unit` return a
774
+ new array when the unit does not change, so an attribute set on, or a
775
+ freeze of, the result does not reach the receiver.
776
+
777
+ - Change: `wmean` gives `UNDEF` where the weights sum to zero, on every
778
+ path; numeric arrays gave NaN or an infinity. A weight array with one
779
+ element is no longer read as a scalar: give a Ruby number or a
780
+ `CScalar`.
781
+
782
+ - Change: a computation over an object array that comes back into the
783
+ array (a cell holding the array, or a view of it) raises, as reading
784
+ such a cell does; it recursed until the process died. A lazy
785
+ expression over such an array (a cell holding `x + 1` for the array `x`)
786
+ raises the same way instead of overflowing the stack or not ending, and
787
+ so does `Marshal.dump` of an object view whose cells lead back to its
788
+ root.
789
+
790
+ - Change (CAObject authors): a `CAObject` without `create_mask` raises
791
+ `TypeError` when its `copy_data` writes `UNDEF`, as it does when a
792
+ fetcher answers `UNDEF`; the `UNDEF` was dropped and read as a value.
793
+
794
+ - Change (C extensions): `ca_install_obj_type` refuses an operation table
795
+ without `allocate`, `attach`, `sync` and `detach` slots;
796
+ `ca_iter_register_source_kind` refuses carray's own types; and the
797
+ kernel iterator's `FIBER_PAIR` forms refuse `CA_KERNEL_WRITE`.
798
+
799
+ - Fix: `require "carray"` works on Ruby 4.0; it raised
800
+ `Ractor::IsolationError` since 3.0.4.
801
+
802
+ - Fix: `CArray.fuse` works on Ruby 3.2 and 3.3. The gem now depends on
803
+ prism 1.0 or later, which `gem install` and Bundler bring in on Ruby
804
+ 3.2, which ships none, and 3.3, whose own prism is too old; Ruby 3.4
805
+ and later already ship it.
806
+
807
+ - Fix: a block of a reshape over a strided view
808
+ (`a[1..2, 1..3].reshape(3, 2)[0..1, nil]`) read and wrote past the end
809
+ of a row, outside the buffer at the edges.
810
+
811
+ - Fix: a frozen object array shared between Ractors can be computed over
812
+ in several at once; it was refused as cyclic. A cell holding a view of
813
+ other cells of the same array is no longer refused.
814
+
815
+ - Fix: a record array (`CARecord`) exports through MemoryView from a
816
+ Ractor other than the main one; it raised `Ractor::IsolationError`.
817
+
818
+ - Fix: `Marshal.dump` of a view no longer writes its whole parent (a
819
+ one-cell view of a 100,000-cell array dumped about 400 KB), and an
820
+ array's mask marshals as a plain boolean array.
821
+
822
+ - Fix: an `each_slab` Enumerator stopped part way with `next` leaves no
823
+ array attached once its Fiber is collected.
824
+
825
+ - Fix: a window or block iterator reads its source afresh on each call;
826
+ after the source changed, a later reduction mixed new sums with old
827
+ counts.
828
+
829
+ - Fix: a frozen or read-only `CArray.meld` refuses writes through a meld
830
+ of it (`CArray.meld(m, m)` wrote into the frozen root).
831
+
832
+ - Fix: a write to a `CArray.stack` or `CArray.meld` whose parts share
833
+ cells (`CArray.meld(a, a)`) gives those cells the value, or the mask, of
834
+ the last part; `add!` could leave an earlier part's result, and a mask
835
+ write masked the cells of every part.
836
+
837
+ - Fix: a write to a `CArray.stack` or `CArray.meld` that one part refuses
838
+ (a value outside a part's data type) writes nothing; the parts before
839
+ it were written.
840
+
841
+ - Fix: `blocks(...).sort_addr` works when the source holds more than one
842
+ tile; it failed with `IndexError`.
843
+
844
+ - Fix: `elem_fetch` answers a boolean cell with `true` or `false` when given
845
+ an index array over a view, as `[]` does; it answered `0` or `1`.
846
+
847
+ - Fix: `CAFrame#fill(:linear)` leaves a row with no coordinate out of the
848
+ interpolation; it was filled with 0.
849
+
850
+ - Fix: `bin_to` and `histogram1d` put a value next to an edge in the bin
851
+ that edge bounds when the edges are nearly but not exactly equally
852
+ spaced.
853
+
854
+ - Fix: `float ** Integer` takes any exponent that fits 64 bits, eagerly
855
+ as lazily, and `x.lazy.pow(k)` answers as `x.pow(k)`. A lazy array
856
+ compared with `UNDEF` (`eq`, `ne`) answers as the eager one does.
857
+
858
+ - Fix: writing `UNDEF` through a widening `refer` (`r.refer(:float64,
859
+ ...)`) no longer masks parent cells outside the written cells, and a
860
+ mask written onto a `CAObject` without mask hooks survives the next
861
+ read of its values.
862
+
863
+ - Fix: a masked cell that is not a String reads as `""` when a `CAString`
864
+ wraps a view, as it does over an entity.
865
+
866
+ - Fix (CASource authors): a source that leaves its `ptr` NULL at rest no
867
+ longer crashes `elem_*`, `dump_binary` to a File or `nlargest` over a
868
+ whole axis.
869
+
870
+ ## 3.0.5
871
+
872
+ - New: `GroupedFrame#aggregate` takes a block instead of a spec. The block
873
+ is given the grouping once and returns a Hash of output name => a
874
+ CArray with one value per group, built from `g["col"]` iterators and
875
+ CArray arithmetic (`g["temp"].max - g["temp"].min`). `grp[array]`
876
+ groups any CArray with one entry per row, such as a value computed
877
+ from columns or a column with cells masked.
878
+
879
+ - New: a `CAFrame` grouped reduction takes a Hash of column name => value
880
+ as `fill_value:`, filling only the named columns. A single
881
+ `fill_value:` still goes to every column and has to suit each.
882
+
883
+ - New: `CArray.meld` brings pieces of different data types to a common
884
+ one, as `CArray.stack` does, and takes `data_type:`. `CAFrame.meld` and
885
+ a frame splice still refuse a column whose pieces differ in data type;
886
+ cast the column first, or use `concatenate`.
887
+
888
+ - New: `scatter_replace!` takes an object or fixed-length array, as
889
+ `put_nd` and `put_along_axis` do. The accumulating members
890
+ (`scatter_add!` and the others) still take numeric arrays only.
891
+
892
+ - New: `CAConstString#count` and `CACategorical#count` with no argument
893
+ count the cells that are not masked, as `CArray#count` does.
894
+
895
+ - New: `CAFixlenString` answers `minmax`, `cummax` and `cummin`, as
896
+ `CAString` does.
897
+
898
+ - New (C extensions): `carray.h` defines `ca_u_<type>` cell types and
899
+ `CA_U(type)`, of the same size and value as the plain types but with no
900
+ alignment requirement, for reading cells that need not be aligned (a
901
+ refer with a byte offset, a struct member, a wrapped buffer). The slab
902
+ macros in `ca_kernel_iterator.h` use them for their pointers.
903
+
904
+ - Change: `CACategorical#sort_addr` is renamed `group_addr`, the order of
905
+ the cells by category. `sort_addr` on a categorical now raises, as
906
+ `sort_index` does, since a categorical has no order of values.
907
+
908
+ - Change: a Face's `parent` (of a `CATime`, `CARecord`, ...) is a
909
+ read-only view of its storage. Write the storage of a time through
910
+ `CATime#ticks`.
911
+
912
+ - Change: an operator that cannot bring two data types together raises
913
+ `CArray::DataTypeError` instead of `TypeError`. `DataTypeError` is a
914
+ `TypeError`, so `rescue TypeError` still catches it.
915
+
916
+ - Change: a float cell with no integer of the target type -- an infinity,
917
+ or a value out of the type's range -- is now treated the way NaN
918
+ already was. `to_type` (`int32`, `as_int64`, ...) masks it to `UNDEF`;
919
+ storing it into an integer array raises `RangeError`
920
+ (`FloatDomainError` for an infinity). Before, it became whatever the
921
+ machine's C conversion gave, which differed between x86 and ARM.
922
+ `clip_int64` and the other `clip_<type>` methods saturate a float
923
+ source to the type's limits on every machine; integer `linspace` raises
924
+ `RangeError` for a span the type cannot hold.
925
+
926
+ - Change: a Ruby Array operand of a numeric or boolean array is read as
927
+ its cells: `a.eq([1, 5, 3])` compares cell by cell (it compared every
928
+ cell with the whole Array), and `a + [1, 2, 3]` adds (it raised).
929
+ Nested Arrays give the axes. An object array still takes an Array as
930
+ one value.
931
+
932
+ - Change: `window`'s `bounds:` is a policy named by a Symbol or String,
933
+ matched whole; an Integer and an abbreviation raise. A `fill_value:`
934
+ given with a policy that does not use it (`:nearest`, `:strict`, ...)
935
+ raises instead of being dropped.
936
+
937
+ - Change: a length, count, offset or shift given to a view
938
+ (`sliding_windows`, `block_view`, `tile`, `roll`, `shift`, `field`,
939
+ `diagonal`) must be an Integer; a Float raises `TypeError` instead of
940
+ being truncated. `transpose` reads its axes as the other axis arguments
941
+ are read: negative from the end, an Integer only.
942
+
943
+ - Change: `drop_axis` on an array whose every axis has size 1 keeps one
944
+ axis of size 1, and `reshape` with no axes raises.
945
+
946
+ - Change: in an index of one key per axis, an index array of more than
947
+ one axis on one axis raises `ArgumentError`; it was read flat. Pass
948
+ `idx.flatten` for the old reading.
949
+
950
+ - Change: `elem_fetch`, `elem_store` and the other `elem_*` methods read
951
+ an index as `[]` reads a key: a Float with no fraction is an index, a
952
+ Float with a fraction raises `IndexError`.
953
+
954
+ - Change: two string arrays of different kinds (`CAString`,
955
+ `CAFixlenString`, `CAConstString`) or of different widths compare by
956
+ their strings. A String query longer than a fixed-width cell matches
957
+ no cell in `eq`, `count`, `search`, `bsearch` and `is_in`; it was cut
958
+ to the cell's width.
959
+
960
+ - Change: `str_index` and `rindex` give `UNDEF` for a cell that does not
961
+ hold the substring; they raised for the whole array.
962
+
963
+ - Change: `bsearch` and `bsearch_addr` answer the first of several equal
964
+ cells.
965
+
966
+ - Change: `search` and `search_addr` raise `ArgumentError` for a negative
967
+ or NaN `eps`, which acted as an exact match.
968
+
969
+ - Change: `inherit_mask` and `inherit_mask_replace` raise `ArgumentError`
970
+ for a source whose number of cells differs from the receiver's (a
971
+ scalar source still applies to every cell).
972
+
973
+ - Change: a reduction's `fill_value:` that its result cannot hold raises
974
+ even when no cell needs it, and `fill` on an empty array checks its
975
+ value as an assignment does.
976
+
977
+ - Change: rounding a `:M` or `:Y` `CATime` to a calendar bucket
978
+ (`round(unit: :Y)`, `"3 months"`) measures the distance by the instant,
979
+ so it agrees with the same dates on `:D`.
980
+
981
+ - Change: a `CATime` reduction (`mean`, `median`, ...) sends a tie to the
982
+ later tick on both sides of 1970; before 1970 it went to the earlier
983
+ one.
984
+
985
+ - Change: a duration String added to or subtracted from a `CATime` is
986
+ one step of its own resolution, so `"15 minutes"` on a `"10 minutes"`
987
+ grid raises, as the same duration as a `CATimedelta` does. It was read
988
+ as fifteen one-minute steps and cut to the grid.
989
+
990
+ - Change: of `-0.0` and `0.0`, `pmax` gives `0.0` and `pmin` gives
991
+ `-0.0`, in either order and on every platform, as `maximum` and
992
+ `minimum` do. Which zero `min` and `max` answer is not specified.
993
+
994
+ - Change: a one-sided `clip` passes a NaN cell through, as a two-sided
995
+ `clip` does.
996
+
997
+ - Change: a categorical's `fill_value:` (of `shift`, `window`, `project`)
998
+ is a label; a `CAConstString` takes only `UNDEF` as a fill value.
999
+
1000
+ - Change: a lazy operator with a Face operand (a categorical, a time, a
1001
+ string array) answers as the eager operator does; it read the Face's
1002
+ storage. `CAConstString#eq` with another array compares cell by cell.
1003
+
1004
+ - Change: a boolean member of a record (or `field(offset, :boolean)` of a
1005
+ fixed-length array) raises `RangeError` when read as a byte that is not
1006
+ 0 or 1, instead of answering differently in each method.
1007
+
1008
+ - Change: unmasking a cell of a `CAString` that holds no String gives an
1009
+ empty String.
1010
+
1011
+ - Change: `swap_bytes` keeps the attributes, as `refer` and `bitfield`
1012
+ do. An array with no cells has no say in the attributes a `meld`,
1013
+ `stack` or `concatenate` keeps.
1014
+
1015
+ - Change: `dim_view` keeps a Face, as `transpose` does.
1016
+
1017
+ - Change: `CArray.string(n)` without a block, and `CArray.string("ab")`,
1018
+ raise; `fixlen_string` and `to_fixlen_string` raise for `bytes:` below 1.
1019
+ `project` raises for a keyword argument, `paste` into a frozen array
1020
+ raises `FrozenError`, and `CArray.result_type` refuses a MemoryView
1021
+ operand whose format carray cannot read, as the operators do.
1022
+
1023
+ - Change: `CArray.sort_addr` with numeric keys is two to three times as fast, and
1024
+ `nlargest` / `nsmallest` read each fiber once with a work area of a
1025
+ few times n.
1026
+
1027
+ - Fix: x86-64 Linux. Inputs that reached an integer division by zero
1028
+ inside the library stopped the process with SIGFPE there (on ARM they
1029
+ were refused later or gave a wrong answer): a sum over a view with a
1030
+ zero-length axis, `wsum` / `wmean` with 1-D weights over a zero-length
1031
+ axis, a view of a stack of empty arrays, `window` with a step of 0, and
1032
+ `wrap_readonly(String, CA_FIXLEN)`. Each now answers or raises
1033
+ `ArgumentError`. The extension builds with GCC 14 without warnings.
1034
+
1035
+ - Fix: big-endian hosts. `bitfield` read 0 and lost writes, a struct's
1036
+ bit members overwrote each other, and an element-wise operation applied
1037
+ in place could give a wrong cell.
1038
+
1039
+ - Fix: `save` and `dump` with `endian: :little` or `:big` wrote the other
1040
+ byte order. `load` reads the marker, so files written so far still load
1041
+ correctly.
1042
+
1043
+ - Fix: running out of memory inside a kernel left a view attached, lost
1044
+ the keywords of the call (`a.sum(axis: 1)` returned the total), or
1045
+ leaked the array being built.
1046
+
1047
+ - Fix: an array with 16 axes (the maximum) given to `bitarray`, `field`,
1048
+ a narrowing `refer` or a `:_` index wrote past an internal array.
1049
+
1050
+ - Fix: a lazy chain whose step narrows the cells (`a.lazy.abs` of a
1051
+ complex array) overran the heap; `seq` on an empty object array wrote
1052
+ past its end.
1053
+
1054
+ - Fix: a CAObject's copy and sync hooks: a view the hook kept of the
1055
+ array it was lent, or the lent array's mask, pointed at freed memory
1056
+ after the hook returned.
1057
+
1058
+ - Fix: `CArray.fuse` crashed when several Ractors ran a fuse block for the
1059
+ first time at once.
1060
+
1061
+ - Fix: a grouped `variancep` / `stddevp` matches `CArray#variancep` to the
1062
+ last bit.
1063
+
1064
+ - Fix: `count` with an array of values honours `keep_axis:`.
1065
+
1066
+ - Fix: `CARecord.wrap` of a record array wraps its storage, not the
1067
+ record array.
1068
+
1069
+ - Fix: an unnamed struct's `order_by` survives `save` / `load` and
1070
+ Marshal.
1071
+
1072
+ - Fix: `CAFrame.from_csv` and `cast(name => :time)` read a leap second
1073
+ (`23:59:60`) as `CArray.time` does, into the next minute.
1074
+
1075
+ ## 3.0.4
1076
+
1077
+ - New: `CAFrame#verify(rules)` judges every row against named rules (each
1078
+ a callable that returns a boolean CArray) and returns the verdicts as a
1079
+ frame, one column per rule; a row whose rule read a masked value is
1080
+ `UNDEF`, so `count(false)` counts the rows that break it.
1081
+
1082
+ - New: `CAFrame#join` takes `how: :semi` and `:anti` (the left rows that
1083
+ have, or have no, match), several key columns (`on: ["station",
1084
+ "date"]`), and the index as a key by the row axis name.
1085
+ `CAFrame#join_asof` takes the index too, and `by:` columns that must
1086
+ match exactly before the nearest key is taken.
1087
+
1088
+ - New: a `CAFrame` grouping has more verbs. The short form of `prod`,
1089
+ `accumulate`, `median`, `variance`, `stddev`, `variancep`, `stddevp`,
1090
+ `first`, `last`, `nunique`, `count`, `all` and `any`, beside `sum` /
1091
+ `mean` / `min` / `max`; `filter` (keep the groups a block chooses);
1092
+ `lag`, `order`, `cumsum` and the other running values, and
1093
+ `fill(name, :ffill)` / `:bfill`, all kept on the frame's rows; and
1094
+ `to_frame`. The reductions take column names (`grp.mean("temp")` is a
1095
+ CArray) and `keep_rows: true`, which gives each row its own group's
1096
+ result.
1097
+
1098
+ - New: `CAFrame#resample` takes `by:`, columns whose groups are binned
1099
+ apart: `df.resample("time", "1 day", by: "station").max("temp")`.
1100
+
1101
+ - New: `CArray#windows(on:, before:, after:)` bounds each window by a
1102
+ width of a key (a time, a duration or a number) instead of a count of
1103
+ cells, with `by:`, `exclude:`, `interval:` and `at:` (windows placed at
1104
+ given points, which may overlap). The key need not be sorted, and the
1105
+ value may have several columns (shape `(N, ...)`). `CAFrame#windows(on:
1106
+ "time", ...)` does the same for a frame's columns.
1107
+
1108
+ - New: `CArray#lag(n = 1, axis:)` is the value `n` steps earlier along an
1109
+ axis, `UNDEF` where there is none, so `x - x.lag` starts with `UNDEF`.
1110
+
1111
+ - New: the slab, block, segment, categorical and axis-group iterators
1112
+ have `lag`, `order` (each cell's rank within its piece) and
1113
+ `strip_mask(method: :ffill / :bfill)`; each of them works within one
1114
+ piece and never takes a value from another. Every iterator has `first`,
1115
+ `last` and `nunique`.
1116
+
1117
+ - New: `CArray#is_between(lo, hi, exclude:)` (or a Range) is true where a
1118
+ value lies between two bounds; `exclude: :lower`, `:upper` or `:both`
1119
+ leaves bounds out, and `nil` or an open end leaves a side unbounded.
1120
+
1121
+ - New: `CArray#round(ndigits)` rounds each element to `ndigits` decimal
1122
+ places (negative for tens, hundreds, ...), as `Float#round` and
1123
+ `Integer#round` do.
1124
+
1125
+ - New: `CArray#to_frame(*names, axis: -1)` shows an array as a CAFrame
1126
+ whose columns are views of it, one per position along `axis`.
1127
+
1128
+ - New: `CACategorical#contrast(base:, full:)` gives one int8 column per
1129
+ category (1 in the cell's category, the base left out unless `full:
1130
+ true`), and `CAFrame#contrast_columns(name, ...)` puts those columns in
1131
+ the frame in place of the categorical.
1132
+
1133
+ - New: `CAFrame#is_duplicate(*names, except:)` is true for the rows that
1134
+ repeat an earlier row in the named columns; `except: :last` or `:none`
1135
+ chooses which occurrence stays unmarked.
1136
+
1137
+ - New: `CAFrame#append(name, col, before:, after:)` puts the column next
1138
+ to another one.
1139
+
1140
+ - New: a `CAFrame` carries attributes of the frame as a whole (`attr`,
1141
+ `set_attr`, `attrs`, ..., and `CAFrame.new(..., attrs:)`), separate from
1142
+ each column's. A row selection or a change of columns keeps them; a
1143
+ summary, a join or a reshape does not.
1144
+
1145
+ - New: `CAFrame#to_csv(attrs: [:units, ...])` writes one line per
1146
+ attribute key below the names, and `CAFrame.from_csv(attrs: [...])`
1147
+ reads them back as column attributes; in a reading block,
1148
+ `r.header(:units)` does the same for a line anywhere in the header.
1149
+
1150
+ - New: `CAFrame.from_csv` `columns:` takes a Hash that selects and names
1151
+ columns, and the names `c0`, `c1`, ... of a file without a header;
1152
+ `cast` and `from_csv` `types:` take `:categorical`. `CAFrame.new` takes
1153
+ `types:` and `on_error:`, as `from_records` does.
1154
+
1155
+ - New: `CArray#delete_attr(key)` removes an attribute and returns its
1156
+ value.
1157
+
1158
+ - New: `CATime#end_of(unit:, origin:)` (the last tick of each time's
1159
+ bucket), `days_in_month`, `quarter`, and the ISO 8601 week `iso_week`
1160
+ with its year `iso_year`.
1161
+
1162
+ - New: a time or duration array takes a single value in `+` and `-`
1163
+ (`t + "3 days"`, `t - t.min`, `t - Time.utc(2024, 1, 1)`), and a month
1164
+ or year duration moves a time on a day or finer grid as `Date#>>` does
1165
+ (`2024-01-31 + 1 month` is `2024-02-29`). A bare number is still
1166
+ refused.
1167
+
1168
+ - New: a time array compares with a value off its grid (`days.eq(
1169
+ "2024-01-03T05:00")`, `<`, `search_nearest`, `is_in`, ...) in the finer
1170
+ unit the two share, where it raised `ArgumentError`. An assignment
1171
+ still raises.
1172
+
1173
+ - New: `CATime#pmax` / `pmin` (and `maximum` / `minimum` / `fmax` /
1174
+ `fmin`) give the later / earlier time cell by cell.
1175
+
1176
+ - New: CArray can be used in a Ractor other than the main one, `fuse`
1177
+ included, and a frozen array is shared between Ractors without
1178
+ copying. See `docs/topics/Ractor.md`.
1179
+
1180
+ - New: C extensions: `CA_FOR_EACH_WHOLE` and `CA_FOR_EACH_WHOLE_MASKED`
1181
+ hand a kernel the whole array as one contiguous run.
1182
+
1183
+ - Change: `CArray#rank` is removed; use `#ndim`.
1184
+
1185
+ - Change: `CArray::TableMethods` (`column_names=`, `column`, `row`, `rows`
1186
+ and `select` on a 2-D array) is removed; use `a.to_frame("x", "y")`,
1187
+ then `df["x"]` for a column or `df.to_records[i]` for a row.
1188
+
1189
+ - Change: `CArray.load_arrow_tensor`, `CArray#save_arrow_tensor` and
1190
+ `CArray::ArrowTensor`, the experimental Arrow tensor IPC reader and
1191
+ writer, are removed.
1192
+
1193
+ - Change: methods whose names start and end with `__` that were public
1194
+ internals are now private, renamed or removed. Call the public method
1195
+ they served instead.
1196
+
1197
+ - Change: CAFrame takes column names as Strings only. A Symbol name
1198
+ (`df.drop(:a)`, `join(on: :a)`, `CAFrame.new(axis_name: :row)`) raises
1199
+ `TypeError`; write `"a"`. Record keys given to `from_records` may still
1200
+ be Symbols, and `df[:x]` stays the predicate syntax.
1201
+
1202
+ - Change: a masked cell of an integer index array keeps its place:
1203
+ `x[i]`, the grid forms and `CAFrame` row selection `df[i]` give a
1204
+ result shaped like `i`, `UNDEF` where `i` is masked, where they dropped
1205
+ those positions. To drop them as before, index by
1206
+ `i[i.is_not_masked]`.
1207
+
1208
+ - Change: an index beside a CArray key is read as it is without one: a
1209
+ range ending before its start reads backwards (`a[i, -1..1]`), and an
1210
+ Integer key drops its axis (`a[i, 1]` has the shape of `i`; add `:_`
1211
+ or use `1..1` to keep it).
1212
+
1213
+ - Change: an index with a Float that has a fraction (`a[1.5..3]`, a step
1214
+ of `0.5`) raises `IndexError`; it was cut to an integer. Convert with
1215
+ `to_i` or `round` first. A Float that holds an integer, such as a count
1216
+ from `sum`, is still that position.
1217
+
1218
+ - Change: an index step says the direction, as in Ruby: a step pointing
1219
+ away from the end reads nothing (`a[(0..4).step(-1)]` read `a[0]`).
1220
+
1221
+ - Change: a boolean selector of more than one axis must have the array's
1222
+ shape; it picked cells by flat position. Flatten both sides to keep the
1223
+ old reading.
1224
+
1225
+ - Change: storing an integer a cell cannot hold raises `RangeError`
1226
+ (`CA_INT8([300])`, `a[0] = 300`, `fill`, `scatter_add!`, a record
1227
+ member); it wrapped (`300` into int8 was `44`). Storing or reading a
1228
+ NaN into an integer cell (`ints[] = floats`, `as_type`, `fake`) raises
1229
+ `FloatDomainError`. To keep C's conversion, use `to_type`, which is
1230
+ unchanged.
1231
+
1232
+ - Change: `CArray.time` reads an Integer as a count of ticks of `unit:`
1233
+ (`CArray.time(CA_INT64([0, 10]), unit: :m)` is 00:00 and 00:10); it
1234
+ read Unix seconds. To read Unix seconds onto another unit, write
1235
+ `CArray.time(secs).to_unit(:m)`.
1236
+
1237
+ - Change: `CArray.time` without `unit:`, and `CAFrame#parse_to_time` with
1238
+ a format or `:mixed`, read the values in the finest unit they show
1239
+ (dates alone `:D`, fractions of a second `:ms` / `:us` / `:ns`); it was
1240
+ always `:s`. Pass `unit: :s` to keep the old unit.
1241
+
1242
+ - Change: adding a duration that is coarser than a time's unit and not a
1243
+ whole number of its ticks (`"1 day"` on a `"7 hours"` time) raises, and
1244
+ so does `CArray#time(origin:)` between two ticks of `unit:`; both were
1245
+ cut to the grid. Convert the time to a unit both share first.
1246
+
1247
+ - Change: `order(descending: true)` puts NaN last and keeps tied cells in
1248
+ their original order (`[5, 3, 5, 1, 5]` gives `[0, 3, 1, 4, 2]`, was
1249
+ `[2, 3, 1, 4, 0]`); with `method: :dense` the largest value is 0 and
1250
+ the ranks have no gaps. Code that used `(n - 1) - order` for the
1251
+ descending rank needs that formula written out. `nlargest` no longer
1252
+ returns NaN or masked cells first, and `nsmallest` / `nlargest` and
1253
+ their `_index` forms break ties by position.
1254
+
1255
+ - Change: a CAFrame column built from Ruby values is typed by them:
1256
+ Integers `int64`, numbers `float64`, Strings a text column (`CAString`),
1257
+ arrays of one shape an N-D column, anything else `:object`; it was
1258
+ `:object`. This holds for `CAFrame.new("x" => [...])`, `df["x"] = [...]`,
1259
+ a group's `table` block and a Proc in `aggregate`. Wrap the values in
1260
+ `CA_OBJECT(...)` to keep an object column. A returned array is read
1261
+ from the N-D column as `col[i, nil]`.
1262
+
1263
+ - Change: `CAFrame#melt` names each row's source in a text column
1264
+ (`CAString`); it was an object column.
1265
+
1266
+ - Change: `CAFrame#group_by` on several keys gives a result with no
1267
+ index: each key is a column, before the reduced columns. Read the keys
1268
+ with `result["station"]` and so on, where the index held tuples.
1269
+
1270
+ - Change: `CAFrame#data_types`, `describe` and `p df` name a Face column
1271
+ by its class (`CATime[D]`, `CAString`) where they gave its storage
1272
+ `data_type` (`:fixlen` for most). Read the storage through the Face's
1273
+ accessor (`ticks`, `codes`, ...).
1274
+
1275
+ - Change: a CAFrame verb that takes a list of columns refuses a name
1276
+ given twice (`select("a", "a")`, `group_by("a", "a")`) with
1277
+ `ArgumentError`. `df["a", "a"]` still gives the column twice.
1278
+
1279
+ - Change: a CAFrame group or window reduction over a column whose type
1280
+ lacks it raises `CArray::DataTypeError`; it raised `ArgumentError`.
1281
+
1282
+ - Change: a `CAString` holds only Strings: storing `nil`, a number or an
1283
+ Array into it raises (use `UNDEF` to mask a cell). A selection among
1284
+ Strings (`then_else`, `choose`, `select`, `conditional`) and a
1285
+ `CAString`'s String operators give a `CAString`, where they gave an
1286
+ object array.
1287
+
1288
+ - Change: attributes follow conversions, views and copies but not
1289
+ reductions: `categorize`, `cast`, `parse_to_time`, `dup`, Marshal and a
1290
+ Face's views keep them, and `first` / `last` of a grouping no longer
1291
+ carry them. A joined or concatenated array shows the keys every piece
1292
+ shows with the same value. An attribute value is stored frozen; change
1293
+ it by setting it again.
1294
+
1295
+ - Change: an error names the method you called, and the common refusals
1296
+ open with it ("+: shape mismatch between operands ...", "fill: can not
1297
+ modify read-only array"). The exception classes are unchanged; code
1298
+ that matches a message needs the new text.
1299
+
1300
+ - Change: `clip` refuses `UNDEF` or a masked cell as a bound with
1301
+ `ArgumentError`. To mask the cells out of range, pass `UNDEF` as the
1302
+ fill (`clip(0, 10, UNDEF)`).
1303
+
1304
+ - Change: `is_in`, `intersection`, `difference` and `union` refuse a
1305
+ Range; pass an Array (`(1..3).to_a`), or use `is_between` for an
1306
+ interval.
1307
+
1308
+ - Change: `median`, `percentile` and `quantile` along the only axis of a
1309
+ 1-D array give a bare value, as `sum` does. `nunique(axis:)` naming
1310
+ every axis gives an Integer; pass `keep_axis: true` to keep an array.
1311
+
1312
+ - Change: `valid_index?` and `valid_addr?` count a negative index from
1313
+ the end, as `[]` does. `elem_fetch` on an empty array raises
1314
+ `IndexError`; it returned `nil`.
1315
+
1316
+ - Change: `seq` / `seq!` on an integer array take a Float or Rational
1317
+ start or step as `init_val + step*i` cut toward zero
1318
+ (`int32.seq(0.5, 0.5)` is `[0, 1, 1, 2]`, was `[0, 0, 1, 1]`), and
1319
+ raise `RangeError` for a start or Integer step the type cannot hold.
1320
+
1321
+ - Change: `random!` on an integer array raises for bounds the type
1322
+ cannot hold or a Float bound, and clears the mask. `bin`, `bincount`,
1323
+ `bincount_nd` and the histograms raise for a non-Integer count and for
1324
+ edges that decrease.
1325
+
1326
+ - Change: MemoryView: `wrap_memory_view` refuses a boolean buffer (any
1327
+ byte other than 0 or 1 cannot be told apart; use `from_memory_view`,
1328
+ which reads it as true), and a wrap with a read-only `mask:` is
1329
+ read-only. `CArray.memory_view_reject_reason` returns `nil` for an
1330
+ object that is not a CArray.
1331
+
1332
+ - Change: C extensions: fifteen kernel iterator shorthand macros
1333
+ (`CA_SLAB_REDUCE_F64`, `CA_SLAB_REDUCE_T_PLUS`,
1334
+ `CA_L2_FOR_EACH_UNMASKED` and others) are removed; write the macro they
1335
+ stood for (`CA_SLAB_REDUCE_T` with `double`, ...).
1336
+ `ca_iter_state_next_slab_strided` is removed, and
1337
+ `ca_iter_state_init_l2` takes `CA_SLAB_AXES` only.
1338
+
1339
+ ## 3.0.3
1340
+
1341
+ - New: `CAFrame.from_csv` reads messy tables: `types: :infer` (numbers,
1342
+ booleans, year-first dates and times), `types: { default: ... }`,
1343
+ `missing:` tokens, `on_error:` (`:mask`, `:warn`, `:raise`), `columns:` to
1344
+ read only some columns, and `header:` / `data:` / `column_names:` by line.
1345
+ `CAFrame#cast` takes the same map; `parse_to_time(name, :infer)` finds a
1346
+ column's date format; `describe` and `split_column` are new; `to_csv`
1347
+ takes `encoding:` and `missing:`.
1348
+
1349
+ - New: `CAFrame` reshapes and resamples: `pivot` / `pivot_grid` / `melt`,
1350
+ `stack_rows(by:)` / `unstack_rows`, `stack_columns` / `unstack_column`,
1351
+ `CAFrame.stack` / `unstack` (frames as layers), and `resample(name, unit)`
1352
+ for time bins. The stacked forms are views. `protect` makes a frame
1353
+ read-only.
1354
+
1355
+ - New: `CAFrame` group reductions and `aggregate` reduce N-D columns along
1356
+ the rows (a column `(N, L)` gives `(groups, L)`), take `min_count:` and
1357
+ `fill_value:`, and pass a reduction its arguments
1358
+ (`"p90" => ["temp", :percentile, 90.0]`).
1359
+
1360
+ - New: `value.segments(offsets:)` / `segments(lengths:)` iterate over
1361
+ consecutive runs of cells, with `CArray.segment_offsets` /
1362
+ `segment_index` to convert between lengths, boundaries and segment
1363
+ numbers. The scans, `map`, `median` and `percentile` of
1364
+ `group_by_category` take `axis:`, and a window's `median`, `percentile`
1365
+ and `quantile` answer under the default `bounds: :skip`.
1366
+
1367
+ - New: `bitfield(range, type)` reads a field as a signed or wider integer;
1368
+ `set_attrs(hash)`; `order(kind:)`; `tolerance: "10 minutes"` for time keys
1369
+ in `locate_nearest_addr` and `CAFrame#join_asof`. A `CARecord` answers
1370
+ `unique`, `value_counts`, `mode`, `is_in`, the set operations,
1371
+ `categorize`, `count(v)` and `locate_addr`.
1372
+
1373
+ - New: for whoever registers a `CArray.expression_evaluator` (carray-jit):
1374
+ mixed data types, integer powers, comparisons, `then_else`, `shift`, and
1375
+ reductions, scans and sorts of an expression now reach the evaluator. An
1376
+ evaluator that does not know a node declines, and CArray computes the
1377
+ expression as before.
1378
+
1379
+ - New: for C extensions: `ca_iter_ensure`, `ca_sync_detach`,
1380
+ `ca_attach_n` / `ca_allocate_n`, `ca_iter_state_init_l2_paired`,
1381
+ `ca_stride_setup(NULL, ...)` and `ca_check_uninitialized` let an
1382
+ extension clean up when its code raises.
1383
+
1384
+ - Change: `CAFrame` names its columns "columns": `variable_names` is now
1385
+ `column_names`, `variables` is `columns` and `nvar` is `ncol`. The old
1386
+ names are gone.
1387
+
1388
+ - Change: `sort_index`, `rank_index`, `partition_index`, `partition` and
1389
+ `partition_copy` without `axis:` work on the whole array, as `sort` does;
1390
+ they worked along axis 0. On an N-D array pass `axis: 0` to keep the old
1391
+ result.
1392
+
1393
+ - Change: errors a caller can cause no longer raise `RuntimeError`: a bad
1394
+ shape, step, axis, option or data type raises `ArgumentError`,
1395
+ `TypeError`, `RangeError` or `CArray::DataTypeError`, and every index out
1396
+ of range raises `IndexError` (`take_along_axis`, `axis2addr` and
1397
+ `addr2index` raised others). `CArray::DataTypeError` is now a
1398
+ `TypeError`. A write to a read-only array still raises `RuntimeError`.
1399
+ Messages name the method you called and the value you gave. Update a
1400
+ `rescue` that matched the old class or wording.
1401
+
1402
+ - Change: arguments that were truncated or ignored now raise: an axis,
1403
+ `min_count:`, `kth` or `n` that is not an Integer; a misspelt keyword; a
1404
+ keyword a method does not take (`min_count:` to `all` / `any` of an
1405
+ iterator, as to the core); a Symbol column name in `cast` and `types:`;
1406
+ `windows` given anything but Ranges (an exclusive range now leaves out
1407
+ its end); `CA_INT32(0, 2)`; a fixlen array without `bytes:`. A negative
1408
+ axis counts from the end everywhere. The indexer's method form
1409
+ (`a[:eq, 0]`) calls public methods only.
1410
+
1411
+ - Change: a Hash passed as a positional argument is an argument, as in
1412
+ Ruby 3, not keywords: `a.sum({axis: 0})` raises (write `a.sum(axis: 0)`
1413
+ or `a.sum(**opts)`). An object array of Hashes can now be searched and
1414
+ counted.
1415
+
1416
+ - Change: values that cannot be held raise instead of being bent: storing
1417
+ `nil` into a numeric or boolean array, an Integer operand the array's type
1418
+ cannot hold (`RangeError`; the comparisons answer by value instead), and a
1419
+ String that is not a decimal number (`"010"` is now 10, and `to_type` gives
1420
+ `UNDEF`). `CAFrame#cast` to an integer makes `2.5` `UNDEF` instead of 2.
1421
+ Store `Float::NAN` or `UNDEF` for a missing value.
1422
+
1423
+ - Change: reductions with too few values: `variance` / `stddev` of fewer
1424
+ than two values is `UNDEF` (pass `fill_value: 0.0` for the old answer),
1425
+ and `minmax` of nothing is `[UNDEF, UNDEF]`. `fill_value:` is stored into
1426
+ the result's type with or without `axis:`; `fill_value: UNDEF`,
1427
+ `strip_mask(UNDEF)` and `unmask(UNDEF)` leave the cells masked.
1428
+
1429
+ - Change: arrays of mixed types meet in a type that holds both: signed with
1430
+ unsigned integers (`uint8` with `int8` is `int16`, `uint64` with `int64` is
1431
+ `:object`) and 32-bit or wider integers with `float32` (in `float64`) when
1432
+ joined or matched. `CArray.result_type` lets a scalar take the arrays'
1433
+ type, as an operator does (`result_type(float32_array, 0.1)` is
1434
+ `:float32`). Arithmetic is unchanged.
1435
+
1436
+ - Change: integer and float edge cases no longer depend on the machine or
1437
+ the argument order: a shift count means what it does to `Integer#<<`,
1438
+ signed `rcp` / `rcp_mul` round down as `/` does, `to_type` to an integer
1439
+ makes NaN `UNDEF`, `maximum` / `minimum` of two zeros are `0.0` / `-0.0`,
1440
+ and `clip` raises when `min` exceeds `max` (a one-sided fill clamps the
1441
+ other side).
1442
+
1443
+ - Change: `CAFrame#join` matches as SQL joins do: a key on 2 left and 3
1444
+ right rows gives 6 rows, and a masked key matches nothing and stays as an
1445
+ unmatched row. When the other frame's key is unique, `:left` gives the
1446
+ same rows as before.
1447
+
1448
+ - Change: `CAFrame.from_csv`'s reading block takes the reader as its
1449
+ parameter and its `body` verb is `data`
1450
+ (`from_csv(path) { |r| r.skip 2; r.header; r.data }`). Text columns come
1451
+ back as `CAString`. Contents that cannot be read raise
1452
+ `CAFrame::UnreadableColumn` or `CAFrame::AmbiguousTimeFormat`, which are
1453
+ not `ArgumentError`.
1454
+
1455
+ - Change: reading time from text is stricter: `parse_to_time` without a
1456
+ format reads year-first text only (pass a format, or `:mixed` for the old
1457
+ guess) in the finest unit the text shows; `CArray.time` and strptime
1458
+ formats refuse trailing text and a time of day they cannot read; a date
1459
+ the column's unit cannot hold raises `RangeError`. Before, these cells
1460
+ were guessed, floored or masked.
1461
+
1462
+ - Change: `CAFrame#to_csv` writes a boolean as `1` / `0` and a float32 as
1463
+ its shortest decimal, refuses a record column, and raises naming the row
1464
+ and column of a cell it cannot encode. `extract` masks a cell its pattern
1465
+ does not match, where it gave `""`.
1466
+
1467
+ - Change: `CAFrame`: a frozen frame refuses `[]=`, `set_index`, `cast` and
1468
+ the other in-place verbs; `at` on a numeric index takes numbers only; the
1469
+ index of a `group_by` result keeps the key's type (a `CATime` key gives a
1470
+ `CATime` index); group `sum` / `mean` / `min` / `max` include every column
1471
+ whose type has the reduction (times and strings among them).
1472
+
1473
+ - Change: `CAStruct` / `CARecord`: records are ordered only by the members
1474
+ named in `CArray.struct(order_by:)`; without it sorting, `min` / `max` and
1475
+ comparison raise. An element's `[]` takes a String or a position (a
1476
+ Symbol raises), a member named like a method (`hash`, `size`) gets no
1477
+ accessor, a nested member reads as a view (`dup` it for a copy), boolean
1478
+ and 1-bit members read as `true` / `false`, and `UNDEF` cannot be stored
1479
+ in a member. Records of another struct are refused.
1480
+
1481
+ - Change: a `CARecord` exported through MemoryView uses Ruby's own format
1482
+ (`ruby/memory_view.h`) instead of PEP 3118 `T{...}`; the member names are
1483
+ `CARecord#memory_view_field_names`. A union is no longer exported.
1484
+
1485
+ - Change: a time array compares with, searches for and stores a `String` or
1486
+ `Date` as well as a `Time`, at the precision the value carries: a value
1487
+ off the array's grid (09:00 against a day array) raises, where a `Time`
1488
+ was floored. `union` of two units gives the finer unit. `inspect` shows
1489
+ the tick and each cell as `to_s` does.
1490
+
1491
+ - Change: `==` on a Face (a time, string or categorical array) compares the
1492
+ values it holds, and only with a Face of its own class: time arrays of
1493
+ different units holding the same instants are `==`, and a `CAString` is
1494
+ no longer `==` to an object array of the same strings (compare
1495
+ `to_type(:object)` for that).
1496
+
1497
+ - Change: Faces (`CATime`, `CATimedelta`, `CACategorical`, string arrays):
1498
+ `.lazy` returns the Face and computes eagerly; storing one into a
1499
+ non-object plain array raises (convert with `to_type(:object)` or
1500
+ `ticks`); `CArray.save`, `dump` and `Marshal.dump` refuse one, and a
1501
+ `CAWrap` (save `.parent` or `.copy`); `CArray.stack([face])` returns the
1502
+ Face, and mixing Faces raises.
1503
+
1504
+ - Change: for whoever writes a Face: the hooks are renamed
1505
+ `storage_to_element` / `element_to_storage`, and a stored value goes
1506
+ through `element_to_storage` once (it went through twice). A Face written
1507
+ in Ruby on `CAObject` over a numeric storage refuses arithmetic, math and
1508
+ reductions unless it passes `numeric: true`.
1509
+
1510
+ - Change: views: a view of a frozen array is read-only rather than frozen
1511
+ (`RuntimeError`, `frozen?` false), so `sort`, selections and lazy
1512
+ expressions work on a frozen array. `then_else` and `sort` on a lazy
1513
+ expression return a read-only lazy view (call `copy` for a snapshot), and
1514
+ `then_else` branches broadcast as operands do. `dup` of a `CAWrap` is a
1515
+ plain `CArray`. Attributes survive `copy` and `to_type`.
1516
+
1517
+ - Change: a `bitarray` view has no mask and refuses a masked array (use
1518
+ `value.bitarray`); `pack_bits` raises on masked cells (pack the mask with
1519
+ `validity_bits`). `bitfield` refuses a complex array.
1520
+
1521
+ - Change: on an object array, `min`, `max`, `cummin`, `pmin` and the rest
1522
+ compare with `<=>`, as `sort` does; a pair that cannot be ordered raises
1523
+ `ArgumentError`. `median`, `percentile` and `quantile` answer in the
1524
+ elements' own arithmetic (`CA_OBJECT([1, 2]).median` is `3/2`; convert
1525
+ with `to_type(:float64)` for a Float). `&`, `|` and `^` with a boolean
1526
+ array read its cells as `true` / `false`, eager and lazy.
1527
+
1528
+ - Change: smaller behaviour changes: `locate_nearest_addr` (and `join_asof`,
1529
+ `snap_to`) with `direction:` matches beyond the reference's ends (limit it
1530
+ with `tolerance:`); `map_slab` carries the mask of the block's result; a
1531
+ masked cell of a one-axis boolean selector selects nothing; `shift`,
1532
+ `roll`, `tile` and `window` on a zero-length axis return an empty view;
1533
+ boolean sums in `axis_group` and categorical scans are uint64, as in the
1534
+ core; `group_by_category` raises `TypeError` for a non-categorical.
1535
+
1536
+ - Change: an operand that exports MemoryView and defines `to_ca` (an Arrow
1537
+ array, with a bridge) is taken through `to_ca`, so Arrow nulls arrive as
1538
+ masked cells and time columns as `CATime`.
1539
+
1540
+ - Change: for C extensions: `CArray::VERSION_CODE` is
1541
+ `major*10000 + minor*100 + teeny` (`30003`); the `CA_FOR_EACH_ELEMENT`
1542
+ macros, `CA_WITH_BUFFER` and `CA_CHECK_BOUND` are removed (use
1543
+ `ca_call_cslab_N_r`, `ca_call_cfunc_N_r` or `rb_ca_call_with_buffer`);
1544
+ the `_INOUT` and `_PAIR` fiber macros raise on a shape mismatch; kernels
1545
+ are built with `-fwrapv`. Rebuild the extension.
1546
+
1547
+ - Change: faster, with the same results: `from_csv` with `types:` (two to
1548
+ five times), text to float (eight times), `CAConstString#to_string`,
1549
+ reductions over gathered, `shift` and `window` views, a repeated
1550
+ `CArray.fuse` block, and selecting from a lazy expression.
1551
+
1552
+ - Fix: wrong answers that came without an error. An in-place operation
1553
+ reading an argument that shares its memory read cells it had already
1554
+ written (`a[1..5].add!(a[0..4])` gave a running sum; `scatter_*!`,
1555
+ `inherit_mask` and `mask=` too); `refer` to a wider type on a transposed
1556
+ or stepped parent read neighbouring values; views of a stack or meld,
1557
+ and a slice of a lazy expression, returned other cells; a Float operand
1558
+ of an integer array was truncated (`count(1.5)` found `1`); `mask=` with
1559
+ another shape copied cells by count; a masked index read cell 0 in
1560
+ `gather_nd`; `stddev` of NaN data was 0.0.
1561
+
1562
+ - Fix: wrong answers that came without an error, time and strings: time
1563
+ keys of different units matched or not depending on the side in `is_in`,
1564
+ `join` and `align`; `locate_nearest_addr` picked a wrong row for a NaN,
1565
+ an infinite or a nanosecond key; `unmask(time)`, `resize(fill_value:)`
1566
+ and `insert_block` read a `Time` as a count; `CAConstString` comparisons
1567
+ compared buffer positions; a `CAString` compared against a time,
1568
+ categorical or const string compared their encodings.
1569
+
1570
+ - Fix: writes that were lost now reach the array: through a grid, selection
1571
+ or `select_axis` over a reshaped transpose, through a stack or meld of
1572
+ views, into a nested struct member, into the mask copy of a stack or meld,
1573
+ and the masked cells of `c[] = c.flip(0)`.
1574
+
1575
+ - Fix: crashes and reads outside an array: a garbage collection during an
1576
+ operation on a converted or computed array (`CAObject`, lazy, object
1577
+ data); a slab kept after `each_slab`; a `CARecord` after `Marshal.load`;
1578
+ shapes and indices whose arithmetic overflows; `refer(:object)` and
1579
+ `bitfield` on object data; `scatter_*!` on complex; `MIN / -1` on Linux
1580
+ x86; struct members outside the record; fixlen stores of another width;
1581
+ reductions in several Ractors.
1582
+
1583
+ - Fix: an operation that raises part way (a block, a conversion, a
1584
+ division by zero) leaves its arrays usable and frees its memory. Before,
1585
+ an array could stay attached, and after 32 such errors every lazy
1586
+ expression failed with "all 32 slots in use".
1587
+
1588
+ - Fix: iterator reductions answer as the same reduction on an array: every
1589
+ one takes `min_count:` and `fill_value:` (`blocks(n).percentile(p,
1590
+ min_count: k)` read them as a second percentile), a group's counts apply
1591
+ `min_count:` to the right cells, a group's `wmean` no longer takes
1592
+ `fill_value:` as a weight, a window of only NaN gives NaN, and object
1593
+ weights in `segments` stay exact.
1594
+
1595
+ - Fix: `CAFrame` round trips through CSV and records: quotes, separators of
1596
+ several characters or spaces, lines of spaces, a duplicated header name,
1597
+ complex `Infinity` / `NaN`, months and years, hour 24, a one-column file
1598
+ with a blank name; nested arrays, `Complex` and `Rational` in
1599
+ `from_records`. `fill`, `to_table` and `filter(keep_masked:)` work with
1600
+ N-D and categorical columns; `meld` and `concatenate` take empty frames;
1601
+ `group_by` takes a categorical key and treats NaN in a composite key as
1602
+ one value.
1603
+
1604
+ - Fix: Faces stay Faces: the reductions of `windows` and `blocks`,
1605
+ `partition_copy`, `then_else`, `clip`, `mask_eq` and `meld` return the
1606
+ Face, and a Face's own state survives `min(axis:)`, `cummax` and
1607
+ `partition_copy`. `axis_group` and categorical reductions take boolean,
1608
+ complex, object and Face values; a time array's `fill_value:` is a time
1609
+ on every path. `CAFrame#fill(:linear)` interpolates any Face that defines
1610
+ `linear_fetch`. A categorical refuses `clip` and `minmax` as it refuses
1611
+ `min`.
1612
+
1613
+ - Fix: types kept through operations: complex arrays work with `unique`,
1614
+ `is_in` and the rest of that family; `meld` reductions answer as on a
1615
+ copy; fixlen strings of different widths match; `atan2`, `hypot` and
1616
+ others keep float32 and integer types; a record member declared with
1617
+ `endian:` reads, sorts, saves and loads correctly.
1618
+
1619
+ - Fix: NaN and masked cells are treated the same everywhere: NaN is last in
1620
+ object sorts and `categorize`, loses `min` / `max`, and is found by
1621
+ `CAFrame#at(Float::NAN)`; `min_index` never points at a masked cell or a
1622
+ NaN; `min_count:` and `fill_value:` are honoured where they were ignored;
1623
+ a lazy expression's mask follows its operands; a selection or `shift`
1624
+ follows later mask changes; `invert_mask` works on a selection.
1625
+
1626
+ - Fix: MemoryView: a `CAFixlenString` exports as bytes and a frozen fixlen
1627
+ array can be exported; `CATime`, `CACategorical` and `CAConstString` are
1628
+ refused by `memory_view_available?` with the reason, instead of answering
1629
+ `true` and failing.
1630
+
1631
+ - Fix: with carray-jit: two expressions that differ only in which operand an
1632
+ operation reads no longer share a kernel, and a store whose destination
1633
+ overlaps an operand is computed by CArray.
1634
+
1635
+ - Fix: for C extensions: a `CA_KERNEL_WRITE` walk over a view that holds a
1636
+ cell more than once keeps the cells the kernel wrote; a walk left with
1637
+ `break` writes back its slab; writes through a `CAGrid`, `CAWindow` or
1638
+ `CAShift` over a view reach the array; the sweep engine and paired walks
1639
+ read an argument sharing the output's memory as it was; a view class
1640
+ that is not registered with `ca_iter_register_source_kind` is still
1641
+ accepted. Rebuild the extension.
1642
+
1643
+ ## 3.0.2
1644
+
1645
+ - New: `CArray::AddressBasis`, for a C extension whose code addresses cells
1646
+ itself rather than being handed them — a kernel generated from an
1647
+ expression, which writes its own loop. `open` lends a pointer and one byte
1648
+ stride per axis for the length of a block, and closes what it opened even
1649
+ when the block raises; `classify` reports how an array would be opened
1650
+ without opening it. It is a runtime facility at the `ca_attach` layer, not
1651
+ a user API: what it lends is a raw machine address, so it is described in
1652
+ the developer's guide rather than in the user documentation.
1653
+
1654
+ - New: a `CAString` column can be searched, not only sorted: `bsearch`,
1655
+ `bsearch_addr`, `search` and `count(v)` answer where they used to raise
1656
+ `ArgumentError`. A cell of one is the Ruby String it shows, so a String query
1657
+ compares against it directly, with nothing to reconcile. Sorting, which
1658
+ already worked, is unchanged, and so is `CAConstString`, which answers
1659
+ `search` / `count(v)` natively and still has no `bsearch`.
1660
+
1661
+ - New: `count(v)` counts an object or fixlen array, which used to raise
1662
+ `CArray::DataTypeError`. An object array compares by Ruby `==`, so
1663
+ `count(1)` and `count(1.0)` agree, and `true` / `false` / `nil` are values to
1664
+ count rather than the boolean array's `true` / `false`. A fixlen array
1665
+ compares the whole cell by `memcmp`, with a short String query padded out to
1666
+ the cell width -- so a 4-byte cell holding `"a\0\0\0"` is counted by
1667
+ `count("a")`.
1668
+
1669
+ - New: `CArray.empty(data_type, dim, bytes: nil)` allocates without the zero
1670
+ fill, for an array whose every cell is written before anything reads it. One
1671
+ existing call changes: `CArray.empty(3, [4])` raised `TypeError` in 3.0.1
1672
+ and now matches `CArray.new(3, [4])`.
1673
+
1674
+ - New: `CAFrame.from_csv` reads an open IO as well as a path, so CSV already
1675
+ in memory need not go through a temporary file first. A String argument is
1676
+ still always a path, never CSV text.
1677
+
1678
+ - New: `inspect_full` renders an array the way `inspect` does but without the
1679
+ `...` abbreviation.
1680
+
1681
+ - New: `repeat` lays each element of an array down several times --
1682
+ `v.repeat(2)`, or `v.repeat([3, 1, 2])` for a count each. It is not `tile`,
1683
+ which lays the whole array down again. The result is a view.
1684
+
1685
+ - New: `unique`, `nunique` and `mask_duplicates` take `along: k`, comparing
1686
+ whole sub-arrays instead of cells -- `z.unique(along: 0)` gives the distinct
1687
+ rows of a 2-D array. Giving both `along:` and `axis:` raises.
1688
+
1689
+ - New: each numeric data type names its own limits on its class --
1690
+ `CArray::Int32::MIN` / `MAX`, and `TINY` / `EPSILON` for float and complex
1691
+ types. `MIN` is the bottom of the range, where Ruby's `Float::MIN` is what
1692
+ is called `TINY` here.
1693
+
1694
+ - New: `CArray::Rng` is a random number generator with its own state, which
1695
+ `random!`, `randomn!` and `shuffle!` accept as `rng:` alongside a Ruby
1696
+ `Random`. Without `rng:`, or with a Ruby `Random`, nothing changes.
1697
+
1698
+ - New: `CArray#factorize` answers `[codes, levels]` in one pass, for a caller
1699
+ who wants the codes as storage rather than the `CACategorical` that
1700
+ `categorize` builds from the same two.
1701
+
1702
+ - New: C extensions only. `CA_FOR_EACH_FIBER_PAIR` and
1703
+ `CA_FOR_EACH_FIBER_PAIR_MASKED` yield one contiguous fiber from each of two
1704
+ sources at the same position.
1705
+
1706
+ - Change: `CArray.meld` (and `CAMeld.new`, and so `CAFrame.meld`) now treats a
1707
+ homogeneous list of Faces the way `CArray.stack` does: a Face whose state is
1708
+ per-parent is refused, and one that can be carried is kept on the result.
1709
+ `CAConstString` and `CAString` now raise `ArgumentError` — weld the storage
1710
+ instead, with `.parent`, or use `CArray.concatenate`. `CAFixlenString`,
1711
+ `CATime` and `CATimedelta` come back as themselves rather than as the raw
1712
+ storage; melding pieces whose Face state differs, such as two `CATime`
1713
+ columns in different units, now raises rather than welding the ticks. Lists
1714
+ of plain arrays, and a list of one, are unaffected.
1715
+
1716
+ - Change: `CAConstString.wrap` now checks the `(start, end)` pairs it is given
1717
+ against the buffer, and takes ownership of the offsets entity by marking it
1718
+ read-only. A pair outside the buffer raises `ArgumentError` naming the
1719
+ element; masked cells are exempt, since their bytes may be anything. Code
1720
+ that built a column with well-formed offsets is unaffected, except that the
1721
+ entity it passed can no longer be written afterwards — pass `.copy` to keep
1722
+ a mutable one. This also means the storage behind an existing column
1723
+ (`column.parent[i] = ...`) now raises rather than silently rewriting a column
1724
+ that reports itself read-only.
1725
+
1726
+ - Change: `all` and `any` on an `axis_group` reduction now require a boolean
1727
+ payload, as `CArray#all` / `#any` and the other iterators do. They folded any
1728
+ numeric payload, counting a non-zero cell as true, so `data.all` refused and
1729
+ `data[g].all(axis: :group)` answered for the same float array. Convert first
1730
+ if you meant the old reading: `data.ne(0)[g].all(axis: :group)`.
1731
+
1732
+ - Change: the `axis:` reductions on `group_by_category` now read the source
1733
+ array when asked, rather than some of them answering from a result kept
1734
+ from an earlier call. `sum`, `mean`, `min`, `max` and the counts shared a
1735
+ kept result per axis while `prod`, the variance family and `wsum` / `wmean`
1736
+ did not, so after a write through the source one iterator could report a
1737
+ mean and a variance that no data can produce together. Reading several
1738
+ members off one iterator now costs one kernel run each instead of one
1739
+ shared run; keep the result if you want the old sharing. The no-axis
1740
+ reductions are unchanged: they still work from the copy taken when the
1741
+ iterator was built.
1742
+
1743
+ - Change: `CAFrame#at(UNDEF)` now raises `ArgumentError` instead of returning a
1744
+ row. An index can hold a masked cell -- an `:outer` / `:right` join and
1745
+ `align` both produce one -- but a row with no label cannot be identified by
1746
+ one, and two undefined labels are not the same label; the key matching behind
1747
+ `join` and `align` already treats a masked key as matching nothing. Use
1748
+ `df.filter { |f| f.index.is_masked }` for the rows with no label, which also
1749
+ handles more than one of them. Asking for a real label whose cell is masked
1750
+ still raises `KeyError`, unchanged.
1751
+
1752
+ - Change: functions built on the C-extension bridge (`ca_call_cfunc_*`,
1753
+ `ca_call_cslab_*`, and `CAMath.spherical_to_xyz` / `xyz_to_spherical`)
1754
+ pair two array operands only when their shapes agree, and otherwise
1755
+ raise `ArgumentError` naming both shapes. Arrays of the same size but
1756
+ different shape, such as (2,3) and (3,2), used to be accepted and read
1757
+ in flat order; reshape one of them first. Arrays of different sizes
1758
+ raised `RuntimeError` before, so a `rescue` of that class needs
1759
+ updating. A scalar still pairs with any array.
1760
+
1761
+ - Change: `min`, `max`, `minmax`, `cummin` and `cummax` answer `NaN`, and
1762
+ `min_index`, `max_index`, `min_addr` and `max_addr` answer `UNDEF`, when every
1763
+ cell a float array contributes is `NaN`. They used to answer `Infinity`,
1764
+ `-Infinity`, the interval `[Infinity, -Infinity]` and position `0`. A `NaN`
1765
+ still loses to any number, so an array holding at least one number answers as
1766
+ before, as does one holding only real infinities. Empty and all-masked still
1767
+ answer `UNDEF`, and integer, boolean, fixlen and object arrays are unchanged
1768
+ -- an object array already answered `NaN`. To have `NaN` counted as missing
1769
+ rather than skipped, call `mask_invalid` first; `min_count:` and `fill_value:`
1770
+ act on masked cells and do not reach `NaN` ones.
1771
+
1772
+ - Change: the `CAConstString` ordering family takes `axis:` -- and `kind:` /
1773
+ `masked_position:` / `keep_axis:` where CArray does -- across `min`, `max`,
1774
+ `minmax`, `min_index`, `max_index`, `sort`, `sort_copy`, `sort_addr`,
1775
+ `sort_index`, `rank_index`, `order`, `partition_copy` and `partition_index`.
1776
+ Three answers move to CArray's: `sort_index` gives per-fiber indices where it
1777
+ gave view-flat addresses (ask `sort_addr` for those); `sort` with no `axis:`
1778
+ flattens first, where it kept the shape (a 1-D column is unaffected); and
1779
+ `min` / `max` on an empty or wholly masked column give UNDEF, not nil.
1780
+
1781
+ - Change: `CABlock#count` and `CAWindow#count` are gone. They gave back the
1782
+ per-axis number of cells the view exposes -- which is what `shape` answers
1783
+ -- and in doing so hid `CArray#count` on the two classes an indexing
1784
+ expression lands on most: `a[2...8].count(true)` raised `ArgumentError`,
1785
+ and `a[2...8].count` gave a shape rather than a population. Read the
1786
+ geometry with `shape`. `size0` / `start` / `step` / `offset`, which say
1787
+ where the view sits in its parent, are unchanged.
1788
+
1789
+ - Change: `CArray.jit_for`, `CArray.jit_each` and `CArray.jit_map` are no
1790
+ longer defined here; they arrive with `require "carray/jit"`. Without it a
1791
+ call raises `NoMethodError` where 3.0.1 raised `NotImplementedError`, so
1792
+ code that rescued that to fall back asks `CArray.respond_to?(:jit_each)`.
1793
+
1794
+ - Change: the Ruby attach surface is gone from released builds:
1795
+ `CArray.attach` / `.attach!`, `CArray#attach` / `#attach!`, and
1796
+ `#__attach__` / `#__sync__` / `#__detach__`. Write through the array
1797
+ directly instead. `CArray#attached?` and the C lifecycle are unchanged.
1798
+
1799
+ - Change: `a[1, :_]` returns a view of the axes `:_` asked for instead of
1800
+ raising `IndexError`. To keep an axis rather than drop it, index it with
1801
+ something that is not a scalar -- `a[[1], :_]`.
1802
+
1803
+ - Change: C extensions only. A kernel iterator init the engine refuses now
1804
+ raises instead of returning a code the block macros discarded. To handle a
1805
+ refusal rather than propagate it, call `ca_iter_state_init_l1` / `_l2`
1806
+ directly and read the code.
1807
+
1808
+ - Change: `CACategorical.from_codes` now materialises `codes` when it is a
1809
+ view rather than an array of its own, so writing through the array the view
1810
+ was taken from no longer changes the categorical underneath it. A wrapped
1811
+ memory view is an array of its own and is still adopted without a copy, so a
1812
+ zero-copy import stays zero-copy. The array you pass is never marked
1813
+ read-only beyond what you handed over.
1814
+
1815
+ - Change: `CACategorical.from_codes` now checks what it is handed and
1816
+ normalises it. It raises `ArgumentError` for duplicate labels, for more
1817
+ labels than the codes data type can carry once its top value is reserved as
1818
+ the exclusion sentinel, and for an unmasked code outside `0...labels.size`
1819
+ that is not the sentinel. A cell that arrives masked also gets the sentinel
1820
+ written into its code byte, so the mask and the byte now agree for every
1821
+ reader, a byte-reinterpret export included. Codes built by `categorize`
1822
+ already satisfy all of this, so nothing changes for a categorical made that
1823
+ way.
1824
+
1825
+ - Change: `search_nearest` and `search_nearest_addr` work on an object array of
1826
+ numbers, and say why when they cannot. They measured only with `#distance`,
1827
+ and since `Numeric#distance` became an opt-in refinement -- which a C-level
1828
+ call does not see -- that raised `NoMethodError` for an Integer as readily as
1829
+ for a String. A number is now measured as `(query - cell).abs`, exactly for
1830
+ Rational and BigDecimal; an object defining a real `#distance` still uses it;
1831
+ anything else raises `CArray::DataTypeError` naming the query's class, and
1832
+ points at `search` / `bsearch` for an exact match. Numeric arrays are
1833
+ unaffected.
1834
+
1835
+ - Change: `CAFrame.from_csv` reads a missing field as UNDEF in every column,
1836
+ not only in one named by `types:`. An unquoted empty field, and a cell a
1837
+ short row never reached, used to arrive as a Ruby `nil` sitting in an
1838
+ uncast column, so a mask written by `to_csv` did not survive the trip back.
1839
+ A quoted empty field (`""`) is still the empty string, which is a value.
1840
+ Code that worked around this with `col[:eq, nil] = UNDEF` can drop the line.
1841
+
1842
+ - Change: `CArray.time` reads a string array about eight times faster with an
1843
+ explicit `format:`, and about three times faster letting it auto-detect --
1844
+ so `CAFrame#parse_to_time`, which calls it, speeds up by the same amount.
1845
+ Parsed values are unchanged.
1846
+
1847
+ - Change: `window` accepts `bounds:` as a Symbol as well as a String, which is
1848
+ the spelling `windows` already took. Strings keep working.
1849
+
1850
+ - Change: C extensions only. A partial fill of an array backed by a CAObject
1851
+ or CASource subclass takes the `fill_block` / `fill_addrs` slots where the
1852
+ subclass defines them, instead of one `store_addr` per cell. Which cells are
1853
+ written is unchanged, and a subclass defining no fill slot keeps the
1854
+ per-cell path.
1855
+
1856
+ - Fix: `is_in`, `count(v)`, the set operations, `locate_addr`, `search`,
1857
+ `bsearch` and `linear_section` no longer compare a Face operand by its
1858
+ storage when that storage is not the value it shows. Passing a
1859
+ `CAConstString` (whose cells are byte ranges) to one of these on another
1860
+ Face used to answer from the byte ranges: where the two cell widths
1861
+ coincided — a `CAConstString` cell is 16 bytes, and so is a
1862
+ `CAFixlenString` cell whose column is 16 bytes wide — you got a wrong
1863
+ answer with no error, and a set operation could return raw offset bytes as
1864
+ its values. Such an operand now raises `ArgumentError`; convert it first,
1865
+ with `#to_string` for a string Face, or pass `.parent` on both sides to work
1866
+ in storage space. Plain operands, and Faces whose cells are their values
1867
+ (`CAString`, `CAFixlenString`), are unaffected, as is the cross-unit
1868
+ reconciliation `CATime` does through `to_comparable`.
1869
+
1870
+ - Fix: the reductions without `axis:` on `group_by_category` now agree with one
1871
+ another about which values they are reducing. `cumsum` and the other scans
1872
+ read the array when called while every other member worked from the copy
1873
+ taken when the iterator was built, so a write through the source between two
1874
+ calls was visible to one and not the other. All of them now answer about the
1875
+ values as they were when the iterator was built; build a new iterator to pick
1876
+ up a write. The `axis:` reductions read the array when called, unchanged.
1877
+
1878
+ - Fix: `CArray.load_from_file` no longer exhausts the stack. It was
1879
+ registered for autoload but defined nowhere, so calling it recursed until
1880
+ Ruby gave up; it now raises `NoMethodError` like any other method that does
1881
+ not exist. Use `CArray.load`, which is unchanged. An autoload registration
1882
+ whose library defines no such method now says which method and which
1883
+ library, rather than recursing.
1884
+
1885
+ - Fix: a `group_by_category` reduction over a read-only Face — a
1886
+ `CAConstString` column — no longer fails with an `IndexError` about a buffer
1887
+ range. Such a Face cannot be built by writing into it, so `min`, `max` and
1888
+ the other value members hand back the surface values (the strings) rather
1889
+ than the Face. A writable Face such as `CATime` still answers in its Face.
1890
+
1891
+ - Fix: a group iterator from `axis_group` now answers `shape`, `ndim` and
1892
+ `dim`, which every other iterator answers and which it returned `nil` for,
1893
+ and its `count` takes the two forms the family declares: `count(UNDEF)` for
1894
+ masked cells and `count(v)` for cells equal to `v`. Both previously raised
1895
+ `ArgumentError` about the number of arguments.
1896
+
1897
+ - Fix: a `group_by_category` reduction over values that carry a Face (a
1898
+ `CATime` column, say) now answers in that Face, as `CArray`'s own reduction
1899
+ does: `min`, `max` and `median` come back as a `CATime` of elements rather
1900
+ than failing with an internal message about a zero width. A member the core
1901
+ does not define for that Face still refuses, in the core's own words.
1902
+
1903
+ - Fix: the band-only classifier shape for a `group_by_category(axis:)`
1904
+ reduction is now reachable on a two-dimensional source, where it was
1905
+ refused and the refusal listed it among the accepted forms. Where both the
1906
+ case A shape and the band-only shape fit, which a square source allows,
1907
+ case A is taken, as before. The refusal no longer names `sum` when another
1908
+ reduction was the one called.
1909
+
1910
+ - Fix: `count(axis:)` and `count_not_masked(axis:)` on `group_by_category`
1911
+ now work for a complex, boolean or object payload. They counted cells
1912
+ through a numeric-only kernel, which refused those payloads for an answer
1913
+ that never depended on the payload. The no-axis form already worked.
1914
+
1915
+ - Fix: a `group_by_category` iterator whose classifier does not line up
1916
+ cell-for-cell with the value now says so. A no-axis reduction on one raises
1917
+ `ArgumentError` naming the mismatch and pointing at the `axis:` form, rather
1918
+ than a `NoMethodError` about `nil`; `elements` raises the same instead of
1919
+ answering `nil`; and `inspect` says "per-fiber only" instead of printing an
1920
+ empty grouping. `accumulate(axis:)`, which failed outright on such an
1921
+ iterator, now works.
1922
+
1923
+ - Fix: a reduction from `group_by_category` now hands back an array of the
1924
+ caller's own. `min`, `max`, `minmax`, `count`, `count_not_masked`,
1925
+ `elements`, `min_index` and `max_index` returned the iterator's memo itself,
1926
+ so writing into a result changed what that iterator answered from then on,
1927
+ and changed it for the other members reading the same memo. `sum` already
1928
+ copied. Nothing to change in calling code unless you relied on writing
1929
+ through a result.
1930
+
1931
+ - Fix: an `axis_group` reduction or scan that raises part-way through no
1932
+ longer leaks the working memory it had taken. An object-valued scan
1933
+ (`cumsum`, `cummax` and the rest) calls back into Ruby for every cell, so a
1934
+ value that will not coerce or a `<=>` that answers `nil` raises from an
1935
+ ordinary call and used to leave roughly 36 bytes per source element behind
1936
+ each time. Nothing to change in calling code.
1937
+
1938
+ - Fix: `CAFrame#set_index` on a frame that already has an index no longer
1939
+ discards it. The index being replaced now goes back to being a column, the
1940
+ same demotion `reset_index` performs and in the same position, so re-indexing
1941
+ keeps every column and `set_index("b")` on a frame indexed by `"a"` is the
1942
+ same as `reset_index` followed by `set_index("b")`. Previously the column the
1943
+ old index had been made from was gone, with nothing said.
1944
+
1945
+ - Fix: `CAFrame#reset_index` now restores the row axis name the frame had
1946
+ before `set_index` promoted a column over it, so the two are each other's
1947
+ inverse as documented. It used to leave `"row"`, which is user-visible: the
1948
+ row axis name is the header of the index's column in `to_csv` and its key in
1949
+ a row `Hash`. A frame built with an index, or derived from one, never had an
1950
+ earlier name, so `reset_index` still leaves the default there.
1951
+
1952
+ - Fix: `min` and `max` on an `axis_group` reduction now answer in the source
1953
+ array's data type, as `CArray#min` / `#max` do, instead of float64 -- an
1954
+ int64 beyond the float mantissa came back rounded. A boolean array answers
1955
+ as its 0/1 numeric storage (`all` / `any` are the boolean-returning twins).
1956
+ A group holding nothing but `NaN` now answers `NaN` rather than the
1957
+ accumulator's infinity, and `min_addr` / `max_addr` answer UNDEF for it,
1958
+ since no cell won.
1959
+
1960
+ - Fix: an `axis_group` reduction over a grouping whose group axis has length
1961
+ zero now answers each output cell the way a group with no member is answered
1962
+ -- `sum` 0, `prod` 1, `count` 0, `all` true, `any` false, and UNDEF for
1963
+ `mean`, `min`, `max`, `min_addr`, `max_addr` and the variance family. It
1964
+ previously returned an unmasked 0 for all of them, so a mean and a variance
1965
+ both read as 0.0. A zero-length band axis, which reduces to no cells at all,
1966
+ is unchanged.
1967
+
1968
+ - Fix: a per-category `min`, `max`, `min_index`, `max_index`, `median`,
1969
+ `percentile` or `quantile` from `group_by_category` now treats `NaN` the way
1970
+ `CArray`'s own reduction does: a `NaN` loses every contest, a category
1971
+ holding nothing but `NaN` answers `NaN` for an extremum and UNDEF for a
1972
+ position, and an order statistic sorts `NaN` last. Before, the answer
1973
+ depended on where in the category the `NaN` sat, so the same values in a
1974
+ different row order gave different results. Nothing to change in calling
1975
+ code.
1976
+
1977
+ - Fix: `p` / `inspect` on a `CAFrame` whose only data is its index now shows the
1978
+ table. It printed the summary line alone, because it gated on the column set
1979
+ while the table itself counts the index as a column.
1980
+
1981
+ - Fix: `CAFrame` no longer reports a row count that nothing in the frame backs.
1982
+ Splicing a frame that has no columns into another that has neither columns nor
1983
+ an index left the target claiming the spliced frame's row count, while its own
1984
+ `copy`, `head` and `filter` all answered 0 and it would then accept only
1985
+ columns of that length. The count is now read off a column, or off the index
1986
+ when there are no columns. Nothing to change in calling code.
1987
+
1988
+ - Fix: `CAFrame`'s `df[rows] = UNDEF` now refuses a row outside the frame on a
1989
+ frame with no columns, as the read and delete forms already did. It used to
1990
+ return quietly, because the bound check came from the column indexer the
1991
+ selector was handed to and there was no column to hand it to. Masking a row
1992
+ that does exist on such a frame is still a no-op -- there are no data cells,
1993
+ and the index is left alone by design.
1994
+
1995
+ - Fix: `CAFrame`'s `to_table` (and so `p` / `puts` / `to_s`) now prints a masked
1996
+ element inside an N-D cell as `_`, the marker it already used for a masked
1997
+ scalar cell, instead of the literal `UNDEF`. Nothing to change in calling
1998
+ code.
1999
+
2000
+ - Fix: `CAFrame#group_by` with a composite key no longer makes a group of its
2001
+ own for rows whose key has a masked component. Such a row now forms no group,
2002
+ which is what a single masked key cell already did. Nothing to change in
2003
+ calling code unless you relied on the UNDEF-labelled group.
2004
+
2005
+ - Fix: two `CAFrame` verbs that change every column now decide before changing
2006
+ any, so a column that refuses no longer leaves the frame half-changed in an
2007
+ order that depends on how the columns were inserted. `df[sel] = UNDEF` on a
2008
+ frame holding a read-only column (a categorical) raises without masking
2009
+ anything, and `promote(type)` raises without casting anything when some
2010
+ column would narrow. Nothing to change in calling code.
2011
+
2012
+ - Fix: `CAFrame.from_records` now reads a `nil` cell back as UNDEF in every
2013
+ column, not only in one a numeric cast happens to convert. A string, boolean,
2014
+ object or N-D column used to keep the `nil` as a value, so a mask written by
2015
+ `to_records` did not survive the trip and a row with no index label came back
2016
+ labelled `nil`. Note that the data type is still rebuilt from the values, so
2017
+ an integer column returns as `int64` and a boolean column as an object
2018
+ column; `cast` afterwards if the exact type matters.
2019
+
2020
+ - Fix: a CSV written from a frame with a single column -- or with only an
2021
+ index -- now reads back with all of its rows. A masked cell is written as an
2022
+ empty field, which for a one-column row is a line with nothing on it, and the
2023
+ reader skipped it as a blank line. Blank lines in a file with more than one
2024
+ column are still skipped, as a row there always carries a separator. Nothing
2025
+ to change in calling code.
2026
+
2027
+ - Fix: linear gap-fill on an **integer** array no longer fills the cells
2028
+ outside the interpolable span with `0` and drops their mask. It now leaves
2029
+ them masked, as it already did for a float array and as the documentation
2030
+ says. This covers `unmask(method: :linear)` and `strip_mask(method: :linear)`
2031
+ as well as `CAFrame#fill(name, :linear)`, with or without a frame index.
2032
+ Nothing to change in calling code.
2033
+
2034
+ - Fix: on a frame grouped by a numeric column, `CAFrame`'s `mean`, `sum`, `min`
2035
+ and `max` shortcuts now work. They raised `axis_name "..." collides with a
2036
+ column of the same name`, because the key column was reduced into the result
2037
+ while also being its index; a key only stayed out of the way when its data
2038
+ type was one a reduction skips anyway -- a string, boolean, categorical or
2039
+ time column. A composite numeric key no longer returns its key columns as
2040
+ reduced columns either, so it gives the same column set a composite string
2041
+ key gives. `aggregate` and `table` were never affected. Nothing to change in
2042
+ calling code.
2043
+
2044
+ - Fix: `CAFrame#filter(keep_masked: true)` no longer hands back a frame whose
2045
+ index writes through to the original. Its columns were already independent,
2046
+ so writing the result's index changed the original while writing its columns
2047
+ did not. The result is now materialized throughout -- columns and index --
2048
+ whether or not the selector actually carries a masked cell, so the same call
2049
+ site no longer switches between sharing and copying depending on the data.
2050
+ Code that wants a frame sharing storage with the original should use plain
2051
+ `filter`, which is still a view-frame.
2052
+
2053
+ - Fix: reductions, scans and order statistics no longer leak memory when
2054
+ reading their source raises part way through -- for example
2055
+ `cumsum`, `sum` or `median` over a float64 view of an object array
2056
+ holding a cell that is not a number. Each call used to leave the
2057
+ slab the walk was gathering into behind. Nothing to change in calling
2058
+ code.
2059
+
2060
+ - Fix: `a[sel]` no longer leaks memory when reading the boolean selector
2061
+ raises -- for example `fake(CA_BOOLEAN)` over an int32 array holding a
2062
+ 2. Nothing to change in calling code.
2063
+
2064
+ - Fix: a view that converts on read -- for example `fake(CA_BOOLEAN)` over
2065
+ an int32 array holding a 2 -- now raises every time it is read, where
2066
+ the second read used to succeed silently and return values from a
2067
+ half-converted buffer. A view stacked or melded over such an array no
2068
+ longer leaves its other parents attached when the read raises, and a
2069
+ reshape of a lazy view no longer leaks its buffer. Nothing to change in
2070
+ calling code.
2071
+
2072
+ - Fix: for C extensions, a callback passed to `ca_call_cfunc_*` or
2073
+ `ca_call_cslab_*` may now `rb_raise` to refuse a value: the bridge
2074
+ detaches and frees what it holds before the exception propagates,
2075
+ where it used to leave an output view attached and its scratch memory
2076
+ behind. The outputs are left partly written. Nothing to change in
2077
+ calling code.
2078
+
2079
+ - Fix: when `to_type` on a view raises part way through the cast -- for
2080
+ example an int32 value other than 0 or 1 cast to boolean -- the view is
2081
+ no longer left holding a stale copy of its parent, which made later
2082
+ reads through it return the old values. Nothing to change in calling
2083
+ code.
2084
+
2085
+ - Fix: `copy` and `strip_mask(fill)` no longer leak the result's memory
2086
+ when reading the source raises part way through -- for example a
2087
+ float64 view of an object array holding a cell that is not a number.
2088
+ Nothing to change in calling code.
2089
+
2090
+ - Fix: functions built on the C-extension bridge (`ca_call_cfunc_*`,
2091
+ `ca_call_cslab_*`, the `CA_FOR_EACH_ELEMENT` macros, and
2092
+ `CAMath.lgamma` and its siblings) no longer leak memory, or leave an
2093
+ output view attached, when reading an operand raises part way through
2094
+ -- for example a float64 view of an object array holding a cell that is
2095
+ not a number. Nothing to change in calling code.
2096
+
2097
+ - Fix: `is_in`, `intersection`, `difference` and `union` take an Array or Range
2098
+ of Strings against a fixlen array, where every such call raised
2099
+ `CArray::DataTypeError` -- `CAFixlenString` included. The set is built at the
2100
+ array's cell width, so a short String matches a padded cell the way it does
2101
+ everywhere else. A set given as a CArray must still be of that width; when it
2102
+ is not, the refusal now says which width was wanted instead of reporting a
2103
+ data type mismatch between two fixlen arrays.
2104
+
2105
+ - Fix: comparing a fixlen array against a String compares it as a value of
2106
+ that array's cell width. The String became an object operand, so `eq` / `ne` /
2107
+ `lt` / `gt` / `ge` / `le` and the `[:eq, v]` indexer ran `String#==` per cell
2108
+ against the cell's NUL-padded text -- and an array pads a short String on
2109
+ write, so `a[i] = "be"` then `a.eq("be")` was false, `a.gt("be")` was true,
2110
+ and the scan took 30x longer than the same one in `search`. Two fixlen
2111
+ arrays of different widths compare as before, as does a Regexp for `match`.
2112
+ `CAFixlenString` was never affected.
2113
+
2114
+ - Fix: `percentile` and `median` no longer interpolate between objects that
2115
+ have no arithmetic. On a column of Strings `percentile(30)` quietly answered
2116
+ `""` and even-length `median` raised `NoMethodError` from inside a funcall;
2117
+ both now raise `CArray::DataTypeError` naming `method: :lower` / `:higher` /
2118
+ `:nearest`, which pick an element and work. A `p` that lands exactly on an
2119
+ element (`percentile(50)` of five) still answers, as does an odd-length
2120
+ `median`. Numbers stored as objects -- Integer, Rational, BigDecimal -- are
2121
+ unaffected.
2122
+
2123
+ - Fix: `sort_copy` takes whatever `sort` takes. It refused everything its own
2124
+ fast path could not handle, so an object or boolean array sorted through
2125
+ `sort` and raised `CArray::DataTypeError` through `sort_copy`; complex, which
2126
+ neither can order, refused differently depending on which one was asked, and
2127
+ now refuses alike. Numeric arrays keep the fast path and are unchanged.
2128
+
2129
+ - Fix: `CAConstString#sort_addr`, `#sort_index`, `#rank_index`, `#order`,
2130
+ `#min_index`, `#max_index`, `#partition_copy` and `#partition_index` read the
2131
+ strings. They read the `(start, end)` offsets that hold them, which order by
2132
+ how the column was packed, so they gave well-formed wrong answers rather than
2133
+ raising: `sort_addr` on an unsorted column gave the identity, and
2134
+ `partition_copy` gave NUL bytes. `#minmax` answers instead of raising, and
2135
+ sorting a column with masked cells no longer raises.
2136
+
2137
+ - Fix: `to_const_string` gives an N-D source back with its shape instead of
2138
+ flattened, and `CAConstString#unique` / `#mode` / `#mask_duplicates` /
2139
+ `#intersection` / `#difference` / `#union` keep the column's encoding --
2140
+ on a column that was not UTF-8 they raised out of the builder's check.
2141
+
2142
+ - Fix: `each_with_index` and `map_with_index!` no longer raise
2143
+ `SystemStackError` on a long array, and neither do `CArray#format` /
2144
+ `CArray.format`, which are built on them. The ceiling was the C stack, so
2145
+ where it fell depended on where the code ran: around a million cells on the
2146
+ main thread, under a hundred thousand inside a `Thread`.
2147
+
2148
+ - Fix: `CArray.concatenate` and `CArray.mosaic` take a zero-length piece --
2149
+ an empty slice such as `a[0...0]`, or `CArray.int32(0)` -- instead of
2150
+ raising `IndexError`. The piece contributes nothing and the remaining ones
2151
+ concatenate as before. `CArray#paste` likewise accepts a source covering no
2152
+ cell, and writes nothing.
2153
+
2154
+ - Fix: C extensions only. A kernel writing into a view the caller supplied now
2155
+ reaches the array; writes were lost, or crashed, for several view kinds
2156
+ iterated along an axis whose fiber is not contiguous. Kernels writing into
2157
+ an array they allocated themselves were never affected.
2158
+
2159
+ - Fix: `CArray#each_slab` yields a read-only slab, and writing through it
2160
+ raises rather than reaching the array on one axis and being dropped on
2161
+ another. Return values from the block instead, or assign through the array.
2162
+
2163
+ ## 3.0.1
2164
+
2165
+ - New: `CArray.jit_for`, `CArray.jit_each` and `CArray.jit_map` name a block
2166
+ that is compiled rather than run. Compiling needs the carray-jit gem;
2167
+ without it they raise `NotImplementedError`. An expression over whole
2168
+ arrays wants `CArray.fuse`, which needs no compiler.
2169
+
2170
+ - New: every iterator answers `accumulate` beside `sum`; some of them did not.
2171
+ It is the same fold kept in the source's own data type, where `sum` answers
2172
+ in the type the core promotes to -- a window or tile count over `uint8` cells
2173
+ stays one byte wide.
2174
+
2175
+ - New: `CArray::CoreExtensions` adds postfix math on `Complex`, so `a[0].tanh`
2176
+ reads the way `a.tanh` does. It covers the seventeen functions a complex
2177
+ array supports and agrees with the array form exactly, branch cuts and the
2178
+ sign of a zero included. Opt in with `using CArray::CoreExtensions`.
2179
+
2180
+ - New: `ca_is_stride_family(ca)` in `carray.h`, for a C extension that folds a
2181
+ view into `root->ptr + base + sum(idx[k] * strides[k])` itself. True for
2182
+ CAStride, CARefer, CABlock, CARepeat, CATranspose, CAFarray and CAField and
2183
+ the mask array of each, and for an externally installed view that shares
2184
+ their operation table.
2185
+
2186
+ - New: `divmod` returns `[quotient, remainder]` element-wise with the quotient
2187
+ floored, the pair Ruby's `Integer#divmod` and `Float#divmod` return. The
2188
+ quotient keeps the receiver's data type.
2189
+
2190
+ - New: two optional CAObject callbacks take a partial fill as a region instead
2191
+ of one `store_addr` per cell: `fill_block(starts, counts, steps, val)` for a
2192
+ forward per-axis sub-region, `fill_addrs(addrs, val)` otherwise. Defining
2193
+ neither keeps the old behaviour. Filling a 1000x1000 region of a 2000x2000
2194
+ CAObject: 116 ms to 0.6 ms.
2195
+
2196
+ - New: `CAFrame#to_table` renders the frame as an aligned text table, and
2197
+ `inspect` / `to_s` sit on it: `p df` summarises the first 8 and last 2 rows,
2198
+ `puts df` prints the whole frame. `rows:` caps the printed rows, `precision:`
2199
+ rounds float cells for display (default 6), masked cells show as `_`.
2200
+
2201
+ - New: `CAFrame#to_time` takes a `CATime::Grid`, positionally or as `unit:`, so
2202
+ a netCDF `units` attribute goes in whole. The grid also carries an epoch phase
2203
+ the `unit:` / `epoch:` pair cannot -- that pair reads the epoch on the coarse
2204
+ grid and loses the time of day. The keyword form is unchanged.
2205
+
2206
+ - New: `CATime::Grid` packages the `(unit:, origin:)` pair that `#timesteps`,
2207
+ `#snap` and `.from_timesteps` take, so it is built once and passed as one
2208
+ value: `t.snap(g, direction: :floor)`, `t.timesteps(g)`, `g.at(k)`. It parses
2209
+ and prints the udunits `"<unit> since <instant>"` form, holding a phased
2210
+ origin that the keyword pair cannot (`"12 hours since 2017-11-30 09:00"`).
2211
+ `CATime#grid` is the grid an array is stored on. Storage is unchanged.
2212
+
2213
+ - New: `CATime#snap(grid, direction:)` rounds to a tick grid, the shape
2214
+ `CArray#snap` has for numbers. `#floor` / `#ceil` / `#round` are its
2215
+ fixed-direction forms; their results and keyword forms are unchanged.
2216
+
2217
+ - New: a time element is taken directly as a start or origin literal, so a
2218
+ `floor` / `ceil` / `to_unit` answer feeds back into `CArray.time`,
2219
+ `time_range`, `time_series`, `CArray#time` and an `origin:`; it used to have
2220
+ to go out through `DateTime` and be re-parsed. A `:M` or `:Y` element names
2221
+ the first midnight of its granule. What an origin must satisfy is unchanged.
2222
+
2223
+ - New: `CArray.time` parses a year-month (`"2019-09"`) and a bare year
2224
+ (`"2019"`), so the form a `:M` / `:Y` element prints reads back in. A
2225
+ missing finer field names the head of that period.
2226
+
2227
+ - Change: `abs`, `abs2` and `arg` on a `cmplx64` array now return `float32`
2228
+ instead of `float64` -- the width that type carries its real values in, the
2229
+ same one `real` and `imag` already returned. `arg` on a `float32` array
2230
+ likewise returns `float32` rather than widening. `cmplx128` and `float64`
2231
+ are unchanged, and `arg` on an integer array still gives `float64`. To keep
2232
+ the old width, add `.to_type(:float64)`.
2233
+
2234
+ - Change: `CArray.fuse` takes the expression rather than the arrays it is
2235
+ over -- `CArray.fuse { (a + b) * c }` in place of
2236
+ `CArray.fuse(a, b, c) { |x, y, z| (x + y) * z }`. What comes back is the
2237
+ expression, so `x = CArray.fuse { ... }` now wants `.to_ca` for an array.
2238
+ Where the block's source cannot be read -- an `irb` prompt, inside `eval` --
2239
+ write `a.lazy + b.lazy`. `CArray.lazy(*args) { ... }` is gone.
2240
+
2241
+ - Change: a lazy expression (`a.lazy + b`, `CArray.fuse`) builds its mask when
2242
+ something reads it, rather than when the expression is built. A mask set on
2243
+ either operand after the expression was built is now seen; before, only the
2244
+ left one was. `root_array` and `ancestors` now stop at a lazy operation
2245
+ instead of walking into its left operand. Building a long masked expression
2246
+ is also no longer quadratic in the length of the chain.
2247
+
2248
+ - Change: the top-level constant `CA_NIL` is now `CArray::UNSPECIFIED`
2249
+ (`CA_UNSPECIFIED` in C). It is an internal sentinel for "the caller gave no
2250
+ argument", not a value to pass in; `unmask`, `shift(fill_value:)` and
2251
+ `window(fill_value:)` behave as before.
2252
+
2253
+ - Change: `group_by_category` reductions answer in the data type the core
2254
+ reduction promotes the value to, instead of one chosen per reduction. `sum`
2255
+ on an integer value now answers in float64 (`accumulate` is the spelling
2256
+ that stays in the value's type), and `mean`, `variance` and `median` on an
2257
+ object value stay exact. `sum` on a boolean value and `prod` or `mean` on a
2258
+ complex one, which raised, now work.
2259
+
2260
+ - Change: the `:*` unbound repeat is retired. `a[:*, nil]` raises `IndexError`;
2261
+ `CArray#unbound_repeat`, `CAUnboundRepeat` and `insert_axis(repeat: :*)` are
2262
+ gone. Use `:_`, which gives the same shape and now stretches on a store as
2263
+ well as in an operation. `CArray#broadcast_to` and
2264
+ `CArray.meshgrid(sparse: true)` are unaffected.
2265
+
2266
+ - Change: a binary operation requires shapes to agree, or to differ only in
2267
+ size-1 axes at equal ndim. `(3,2) + (2,3)` and `(3,2) + (6)` raise
2268
+ `ArgumentError` where they used to answer in one operand's shape; flatten
2269
+ both sides to combine the values in the order they lie. Comparisons, `fma`
2270
+ and the lazy forms follow the same rule. Scalars are unaffected, but a
2271
+ one-element 1-D array such as `CArray.int32(1)` counts as a shape.
2272
+
2273
+ - Change: an assignment requires the shapes to match. `t[] = src` with a
2274
+ differently shaped source raises `RuntimeError`; use `src.flatten`. In
2275
+ exchange a smaller source is repeated to fit, so `t[] = row[:_, nil, nil]`
2276
+ and `t[] = col` (shape `(n,1)`) work where they used to raise. A 1-D side on
2277
+ either end still passes, as do shapes differing only in size-1 axes; Ruby
2278
+ Arrays and scalars are unchanged.
2279
+
2280
+ - Change: `to_ca` on a view derived from a lazy marker returns a new entity
2281
+ rather than the view itself -- `a.lazy.shift(1, 0).to_ca`, inside a `fuse`
2282
+ block or not. `copy` behaves as before.
2283
+
2284
+ - Change: `/` and `%` follow Ruby instead of C. Integer division floors and the
2285
+ remainder carries the sign of the divisor; float `%` floors too, float `/` is
2286
+ unchanged. For the old behaviour use `fmod`, which now takes integers as well
2287
+ as floats.
2288
+
2289
+ - Change: `reminder` is removed -- it was IEEE 754 remainder on floats but C `%`
2290
+ on integers. Use `fmod` for the truncated remainder. The IEEE form has no
2291
+ replacement.
2292
+
2293
+ - Change: the result-type override of `CArray#conditional` and
2294
+ `CArray.select` is now `data_type:`, spelled the way the rest of the
2295
+ library spells it. There is no alias: `dtype:` raises `unknown keyword`.
2296
+
2297
+ - Change: a calendar-grid `origin:` given to the bucket-grid methods of a
2298
+ `CATime` array -- `timesteps`, `snap`, `floor`, `ceil`, `round`,
2299
+ `is_righttime` -- now has to be a month head (the 1st at 00:00); it used to
2300
+ drop the day and time silently. A `:Y` tick likewise has to start in
2301
+ January. `from_timesteps` already refused an off-grid origin.
2302
+
2303
+ - Change: the MemoryView producer emits the format vocabulary
2304
+ `ruby/memory_view.h` specifies rather than PEP 3118's, so below 32 bits it
2305
+ writes `c` / `C` / `s` / `S` in place of `b` / `B` / `h` / `H`. From 32 bits
2306
+ up the two already agreed, and `?`, `Zf` / `Zd`, `T{...}` and `Ns` stay PEP
2307
+ 3118, which Ruby has no spelling for. The consumer side already accepted
2308
+ both, so views produced by 3.0.0 still import.
2309
+
2310
+ - Change: multiplying and dividing a `cmplx64` array (`*`, `/`, `rcp`,
2311
+ `rcp_mul`) is computed in double and rounded once, so both are correctly
2312
+ rounded; the old route could be off by about 1800 units in the last place.
2313
+ A product that overflows a float but not a double no longer comes back NaN.
2314
+ Division is 4.2-5.3x faster and multiplication 1.3x slower. `+`, `-` and
2315
+ every `cmplx128` operation are unchanged.
2316
+
2317
+ - Change: element-wise math on a `float32` or `cmplx64` array is computed at
2318
+ that width rather than widened and rounded back, so `sqrt`, `exp`, `log`,
2319
+ the trigonometric and hyperbolic families, `atan2`, `hypot`, `abs` and `arg`
2320
+ are 1.1-3.5x faster there and can move by a bit or two in the last place.
2321
+ Complex `log`, `power`, `exp2` and `exp10` are unchanged, as are the
2322
+ rounding, min / max, comparison and variance families and the wider types.
2323
+
2324
+ - Change: a rolling `sum`, `mean`, `prod`, `min`, `max`, `all` or `any` --
2325
+ `a.windows(-1..1).sum` and the like -- over a window up to five cells wide on
2326
+ every axis is 2-5x faster, and 1.3-4x over a masked source; `min_count:` and
2327
+ `fill_value:` come along. `min`, `max` and `prod` answer exactly as before;
2328
+ `sum` and `mean` may differ in the last bits. A wider window, or any other
2329
+ reduction, is unchanged.
2330
+
2331
+ - Change: `CATime#to_unit` floors to a coarser grid instead of raising, and
2332
+ crosses the calendar / fixed-length boundary (`:M` <-> `:D`) through
2333
+ civil-date algebra. `:Y` / `:M` -> `:W` still raises.
2334
+
2335
+ - Change: `CATimedelta#to_unit` truncates toward zero instead of raising on a
2336
+ coarser target. Crossing the calendar boundary still raises.
2337
+
2338
+ - Fix: `nextafter` on a `float32` array returned its own input. The step was
2339
+ taken in double, and the next double above a float rounds back to that same
2340
+ float. It now steps by one float32 ulp.
2341
+
2342
+ - Fix: a lazy expression over an object array (`CArray.object`,
2343
+ `CA_OBJECT`) returned wrong values, and crashed when materialised
2344
+ repeatedly. Affects `to_ca` and `copy` on a lazy view, an eager operation
2345
+ with a lazy operand, and a reduction over one. Other data types were never
2346
+ affected.
2347
+
2348
+ - Fix: reading a concatenated view (`CArray.concat`, `CAFrame.concat`)
2349
+ backwards along the concatenated axis -- `m.reverse` and any other negative
2350
+ step -- raised IndexError instead of answering.
2351
+
2352
+ - Fix: reading a lazy expression (`a.lazy + b`, `CArray.fuse`) with a step
2353
+ other than one -- `expr[[0, 3, 2]]`, `expr.reverse` and the like -- returned
2354
+ values the expression cannot produce, because its operands were read from
2355
+ the wrong cells. Comparisons carried the same fault, `a.lazy > b` and
2356
+ one-operand ones such as `a.lazy.is_nan` alike. Contiguous reads were never
2357
+ affected.
2358
+
2359
+ - Fix: `a.value + b` raised `can not create mask array for the value array`
2360
+ when `b` carried a mask. It now propagates `b`'s mask.
2361
+
2362
+ - Fix: a rolling window that does not cover the cell it is centred on --
2363
+ `windows(1..2)`, the two cells after this one -- was read as if it started at
2364
+ the array's edge, so every answer came out shifted by the range's start, and
2365
+ `bounds: :truncate` produced anchors whose window did not fit. `windows(1..2)`
2366
+ on `[1..8]` now sums to `[5, 7, 9, 11, 13, 15, 8, 0]`. A window that covers
2367
+ its anchor, which is every centred one, is unaffected.
2368
+
2369
+ - Fix: storing a `Complex` into a `cmplx64` or `cmplx128` array kept the sign
2370
+ of a negative zero real part only when the imaginary part was also negative,
2371
+ so `Complex(-0.0, 0.0)` came back as `0.0+0.0i`. The sign of a zero picks the
2372
+ side of a branch cut, so a value stored this way could be carried to the
2373
+ wrong branch. All four sign combinations now round-trip, through element
2374
+ assignment and through `to_type`.
2375
+
2376
+ - Fix: `sinh`, `cosh`, `tanh`, `asinh`, `acosh` and `atanh` on a complex array
2377
+ gave the hyperbolic function of the real part alone: `cmplx128` and
2378
+ `cmplx64` arrays came back with `tanh(Re z)` where `ctanh(z)` was meant,
2379
+ wrong in both parts, and `acosh` and `atanh` also returned 0 or infinity
2380
+ where the true value is finite. They now agree with C99 `complex.h`. Real
2381
+ and object arrays were never affected.
2382
+
2383
+ - Fix: a C extension reading a view in column-major order -- axes and steps
2384
+ reversed against the view's own -- got wrong values from a view with a
2385
+ length-1 axis, such as `v[nil, :_]`, `v.reshape(n, 1)` or a one-column slice:
2386
+ the first cell repeated, a read out of bounds, or a hang.
2387
+ `carray-linalg-accelerate`'s `solve(a, b)` returned `b[0]` repeated for a
2388
+ single-column right-hand side.
2389
+
2390
+ - Fix: an operation between two views of an array that computes its values --
2391
+ a lazy expression such as `(a.lazy + b)`, or a `CAObject` over a file -- no
2392
+ longer reads that source one cell at a time. `+`, `fma` and comparisons on
2393
+ such a pair now run at the speed of copying each operand first, so the
2394
+ `.copy` that worked around it is no longer needed. Single-operand
2395
+ operations, copies, region transfers and reductions were already unaffected.
2396
+
2397
+ - Fix: views built inside a `CArray.fuse` block stay part of the expression
2398
+ instead of dropping out of it, so a stencil written the natural way is fused.
2399
+ `[]`, `shift`, `roll`, `flip`/`reverse`, `transpose`/`T`, `reshape`,
2400
+ `flatten`, `window`, `diagonal`, `tile` and `refer` keep the chain;
2401
+ `unbound_repeat` and `[:*, ...]` deliberately do not.
2402
+
2403
+ - Fix: a window or shift over a view parent no longer copies that parent in
2404
+ full on every transfer. `a[nil, nil].shift(1, 0)` and friends now read at
2405
+ parity with an entity parent and write several times faster.
2406
+
2407
+ - Fix: reductions over a bare `.lazy` marker no longer raise. Per-axis forms
2408
+ and anything over a masked array failed, so `a.lazy.sum(axis: 0)` raised
2409
+ while `a.lazy.sum` worked.
2410
+
2411
+ - Fix: `ca_test_flag` / `ca_set_flag` / `ca_unset_flag` in `carray.h`, which
2412
+ only a C extension calls, did not parenthesise their flag argument, so
2413
+ testing two flags at once was true for every array.
2414
+
2415
+ - Fix: a Face no longer hands back its storage bytes through the type casts.
2416
+ `as_type`, `fake` and `CArray.wrap_writable` raise; `CArray.wrap_readonly`
2417
+ converts as `to_type` does, which also makes `t.eq(o)` and `o.eq(t)` agree.
2418
+ Reach the storage explicitly with `t.parent.fake(...)`. Numeric Faces are
2419
+ unaffected.
2420
+
2421
+ - Fix: `arange` raised `NoMethodError` in every form; it builds the array now.
2422
+ Integer arguments count exactly, so a step dividing the span evenly no longer
2423
+ picks up an extra element. A zero step or a wrong argument count raises
2424
+ `ArgumentError`.
2425
+
2426
+ - Fix: `from_timesteps` on a week grid answered Thursdays. The week grid counts
2427
+ from the epoch, which is one, so it cannot hold an ISO Monday head; a week
2428
+ bucket now answers on the day grid and round-trips against `floor` cell for
2429
+ cell. A day-or-finer array keeps the Monday default, a week-stored array its
2430
+ own epoch-anchored ticks.
2431
+
2432
+ - Fix: a masked cell decided whether a `CATime` conversion fit. The range
2433
+ guards took their extremes with the mask stripped, so `to_unit` raised
2434
+ `RangeError` over a wide value that was masked out. They now answer UNDEF
2435
+ when there is nothing to bound -- an empty array, or every cell masked.
2436
+
2437
+ - Fix: `CATimedelta::Element#/` floored a negative duration, so `-30h / 4`
2438
+ answered `-8h` where the array form answered `-7h`. A duration is a
2439
+ magnitude, so it shrinks toward zero, matching the array form in all four
2440
+ sign combinations.
2441
+
2442
+ - Fix: `CArray.time` no longer rolls a field that is out of range over into
2443
+ another date. `"2019-02-31"` parsed to 2019-03-03, and `"201909"` -- a valid
2444
+ YYMMDD to Ruby, 2020-19-09 -- to 2021-07; both now raise.
2445
+
2446
+ - Fix: `CATime#to_unit` and `CATimedelta#to_unit` were wrong between two
2447
+ resolutions where neither tick is a whole multiple of the other: converting
2448
+ 3 hours to a `"90 minutes"` grid gave 1 unit rather than 2.
2449
+
2450
+ - Fix: importing a MemoryView whose mask is published as `C` or `c` no longer
2451
+ fails. The check knew only PEP 3118's `B`, `b` and `?`, so a producer that
2452
+ spells a byte in Ruby's format vocabulary was refused.
2453
+
2454
+ ## 3.0.0
2455
+
2456
+ First public release. Earlier versions existed on RubyGems, but the library
2457
+ was developed for the author's own use; 3.0 is where it is packaged,
2458
+ documented and tested as something other people can pick up. It is not
2459
+ source-compatible with 2.0.1.
2460
+
2461
+ See [README.md](../../README.md) for what the library does, and [docs/](../)
2462
+ and [guides/](../../guides/) for the reference and the guides.
2463
+
2464
+ **Requires Ruby 3.0 or later** (3.1 for the MemoryView-backed paths).