carray 3.0.1 → 3.0.3
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +824 -0
- data/README.md +5 -6
- data/carray.gemspec +1 -1
- data/ext/ca_axis_dispatch.c +258 -4
- data/ext/ca_axis_group.c +368 -184
- data/ext/ca_binop_dispatch.c +54 -32
- data/ext/ca_binop_dispatch.h +1 -0
- data/ext/ca_categorical_iterator.c +90 -41
- data/ext/ca_compare.c +8 -2
- data/ext/ca_for_buffer.h +21 -68
- data/ext/ca_group_iter.c +27 -11
- data/ext/ca_kernel_iterator.c +960 -245
- data/ext/ca_kernel_iterator.h +352 -181
- data/ext/ca_monop_dispatch.c +4 -4
- data/ext/ca_monop_dispatch.h +4 -0
- data/ext/ca_obj_array.c +194 -42
- data/ext/ca_obj_bincmp.c +152 -121
- data/ext/ca_obj_binop.c +107 -210
- data/ext/ca_obj_bitarray.c +37 -24
- data/ext/ca_obj_bitfield.c +95 -62
- data/ext/ca_obj_block.c +5 -4
- data/ext/ca_obj_byte_swap.c +40 -40
- data/ext/ca_obj_const_string.c +180 -50
- data/ext/ca_obj_face.c +428 -62
- data/ext/ca_obj_face.h +107 -47
- data/ext/ca_obj_fake.c +21 -50
- data/ext/ca_obj_farray.c +1 -0
- data/ext/ca_obj_field.c +16 -3
- data/ext/ca_obj_fixlen_string.c +39 -26
- data/ext/ca_obj_grid.c +181 -124
- data/ext/ca_obj_meld.c +235 -55
- data/ext/ca_obj_moncmp.c +61 -61
- data/ext/ca_obj_monop.c +125 -107
- data/ext/ca_obj_object.c +551 -233
- data/ext/ca_obj_record.c +51 -16
- data/ext/ca_obj_reduce.c +5 -8
- data/ext/ca_obj_refer.c +117 -33
- data/ext/ca_obj_remap.c +57 -17
- data/ext/ca_obj_repeat.c +21 -5
- data/ext/ca_obj_roll.c +115 -11
- data/ext/ca_obj_select.c +88 -75
- data/ext/ca_obj_select_axis.c +58 -60
- data/ext/ca_obj_shift.c +22 -102
- data/ext/ca_obj_stack.c +223 -123
- data/ext/ca_obj_stride.c +267 -35
- data/ext/ca_obj_string.c +25 -22
- data/ext/ca_obj_tile.c +32 -16
- data/ext/ca_obj_time.c +23 -25
- data/ext/ca_obj_timedelta.c +21 -23
- data/ext/ca_obj_transpose.c +12 -3
- data/ext/ca_obj_triop.c +110 -117
- data/ext/ca_obj_window.c +157 -29
- data/ext/ca_op_ipower.c +25 -13
- data/ext/ca_op_powi.h +57 -30
- data/ext/ca_pow5_table.h +656 -0
- data/ext/ca_rng_normal.h +42 -0
- data/ext/ca_rng_xoshiro256pp.h +105 -0
- data/ext/ca_sort_kernels.h +70 -0
- data/ext/ca_sweep_engine.c +385 -198
- data/ext/ca_sweep_engine.h +31 -23
- data/ext/ca_triop_dispatch.c +4 -1
- data/ext/ca_triop_dispatch.h +5 -2
- data/ext/caframe_csv_reader.c +463 -0
- data/ext/carray.h +90 -28
- data/ext/carray_access.c +487 -231
- data/ext/carray_address_basis.c +731 -0
- data/ext/carray_attribute.c +45 -3
- data/ext/carray_bincount.c +32 -2
- data/ext/carray_broadcast.c +49 -17
- data/ext/carray_call_cfunc.c +667 -511
- data/ext/carray_cast.c +1556 -247
- data/ext/carray_cast_func.rb +34 -21
- data/ext/carray_conversion.c +197 -73
- data/ext/carray_copy.c +84 -38
- data/ext/carray_core.c +591 -119
- data/ext/carray_count.c +148 -96
- data/ext/carray_element.c +18 -27
- data/ext/carray_factorize.c +604 -291
- data/ext/carray_generate.c +76 -40
- data/ext/carray_histogram.c +152 -94
- data/ext/carray_hold.c +2 -1
- data/ext/carray_index_classifier.c +63 -96
- data/ext/carray_internal.h +400 -1
- data/ext/carray_lazy.c +834 -79
- data/ext/carray_loop.c +88 -66
- data/ext/carray_mask.c +705 -324
- data/ext/carray_math_kernel.h +1 -0
- data/ext/carray_median_percentile.c +263 -63
- data/ext/carray_memory_view.c +254 -248
- data/ext/carray_operator.c +1093 -363
- data/ext/carray_order.c +133 -69
- data/ext/carray_partition.c +102 -56
- data/ext/carray_random.c +582 -204
- data/ext/carray_scatter.c +308 -65
- data/ext/carray_segment.c +257 -0
- data/ext/carray_slab.c +183 -70
- data/ext/carray_sort.c +235 -240
- data/ext/carray_sort_kernel.c +8 -1
- data/ext/carray_struct.c +99 -21
- data/ext/carray_test.c +167 -64
- data/ext/carray_time_text.c +1182 -0
- data/ext/carray_utils.c +363 -98
- data/ext/extconf.rb +27 -2
- data/ext/mk_call_cfunc.rb +103 -118
- data/ext/mk_pow5_table.rb +35 -0
- data/ext/mkkernel.rb +1349 -851
- data/ext/ruby_carray.c +17 -2
- data/ext/version.h +4 -4
- data/ext/version.rb +4 -2
- data/lib/carray/attribute.rb +39 -0
- data/lib/carray/autoload_carray.rb +24 -3
- data/lib/carray/autoload_method_extension.rb +18 -0
- data/lib/carray/axis_group.rb +245 -20
- data/lib/carray/basics.rb +95 -25
- data/lib/carray/bincount_nd.rb +6 -0
- data/lib/carray/block_iterator.rb +200 -54
- data/lib/carray/boolean_reduce.rb +21 -29
- data/lib/carray/categorical.rb +244 -59
- data/lib/carray/categorical_iterator.rb +391 -757
- data/lib/carray/complex.rb +36 -29
- data/lib/carray/conditional.rb +94 -7
- data/lib/carray/const_string.rb +177 -27
- data/lib/carray/construct.rb +40 -0
- data/lib/carray/data_type_extension.rb +3 -0
- data/lib/carray/data_type_limits.rb +91 -0
- data/lib/carray/fixlen_string.rb +1 -1
- data/lib/carray/frame/concat.rb +157 -6
- data/lib/carray/frame/convert.rb +13 -7
- data/lib/carray/frame/csv_parser.rb +590 -76
- data/lib/carray/frame/describe.rb +79 -0
- data/lib/carray/frame/frame.rb +205 -35
- data/lib/carray/frame/group.rb +199 -40
- data/lib/carray/frame/io.rb +452 -60
- data/lib/carray/frame/join.rb +134 -46
- data/lib/carray/frame/records.rb +54 -19
- data/lib/carray/frame/reshape.rb +448 -0
- data/lib/carray/frame/sort.rb +26 -2
- data/lib/carray/frame/verbs.rb +726 -56
- data/lib/carray/frame.rb +2 -0
- data/lib/carray/fuse_source.rb +111 -2
- data/lib/carray/fusion.rb +229 -38
- data/lib/carray/inspect.rb +71 -20
- data/lib/carray/iterator.rb +157 -2
- data/lib/carray/lazy.rb +54 -67
- data/lib/carray/mask_gap_fill.rb +66 -50
- data/lib/carray/math.rb +32 -19
- data/lib/carray/meld_reduce.rb +40 -7
- data/lib/carray/methods/align_addr.rb +8 -4
- data/lib/carray/methods/bincount.rb +2 -2
- data/lib/carray/methods/bit_string.rb +14 -3
- data/lib/carray/methods/composition.rb +16 -10
- data/lib/carray/methods/discovery_along.rb +74 -0
- data/lib/carray/methods/factorize.rb +50 -0
- data/lib/carray/methods/gather_nd.rb +13 -2
- data/lib/carray/methods/insert_block.rb +9 -14
- data/lib/carray/methods/is_in.rb +130 -6
- data/lib/carray/methods/join.rb +1 -1
- data/lib/carray/methods/locate_addr.rb +235 -21
- data/lib/carray/methods/mask_duplicates.rb +35 -1
- data/lib/carray/methods/mode.rb +18 -1
- data/lib/carray/methods/nunique.rb +22 -1
- data/lib/carray/methods/repeat.rb +91 -0
- data/lib/carray/methods/resize.rb +21 -23
- data/lib/carray/methods/snap.rb +34 -12
- data/lib/carray/methods/unique.rb +52 -3
- data/lib/carray/record_order.rb +208 -0
- data/lib/carray/rng.rb +86 -0
- data/lib/carray/runtime.rb +14 -11
- data/lib/carray/segment_iterator.rb +990 -0
- data/lib/carray/serialize.rb +197 -27
- data/lib/carray/slab_iterator.rb +109 -40
- data/lib/carray/stack.rb +10 -4
- data/lib/carray/string_operation_extension.rb +9 -4
- data/lib/carray/struct.rb +142 -51
- data/lib/carray/struct_builder.rb +110 -14
- data/lib/carray/table.rb +2 -2
- data/lib/carray/time.rb +535 -105
- data/lib/carray/window_iterator.rb +259 -82
- data/lib/carray.rb +4 -2
- data/yard-stubs/ca_obj_array.rb +4 -4
- data/yard-stubs/ca_obj_bitarray.rb +7 -0
- data/yard-stubs/ca_obj_bitfield.rb +23 -12
- data/yard-stubs/ca_obj_block.rb +2 -7
- data/yard-stubs/ca_obj_fake.rb +1 -1
- data/yard-stubs/ca_obj_field.rb +1 -1
- data/yard-stubs/ca_obj_refer.rb +3 -3
- data/yard-stubs/ca_obj_roll.rb +0 -1
- data/yard-stubs/ca_obj_stride.rb +10 -7
- data/yard-stubs/ca_obj_transpose.rb +1 -1
- data/yard-stubs/ca_obj_window.rb +11 -4
- data/yard-stubs/carray_access.rb +6 -5
- data/yard-stubs/carray_broadcast.rb +2 -2
- data/yard-stubs/carray_cast.rb +78 -43
- data/yard-stubs/carray_conversion.rb +13 -1
- data/yard-stubs/carray_copy.rb +8 -3
- data/yard-stubs/carray_core.rb +3 -83
- data/yard-stubs/carray_count.rb +16 -2
- data/yard-stubs/carray_lazy.rb +210 -1
- data/yard-stubs/carray_loop.rb +4 -1
- data/yard-stubs/carray_mask.rb +34 -10
- data/yard-stubs/carray_math.rb +1499 -4
- data/yard-stubs/carray_median_percentile.rb +26 -8
- data/yard-stubs/carray_order.rb +43 -82
- data/yard-stubs/carray_scatter.rb +10 -3
- data/yard-stubs/carray_segment.rb +72 -0
- data/yard-stubs/carray_slab.rb +11 -8
- data/yard-stubs/carray_sort.rb +50 -8
- data/yard-stubs/carray_test.rb +10 -0
- data/yard-stubs/carray_utils.rb +0 -26
- metadata +19 -19
- data/ext/ca_for_each_element.h +0 -239
- data/ext/carray_build_flags.h +0 -3
- data/ext/carray_config.h +0 -28
- data/ext/carray_kernels_bincmp.c +0 -4446
- data/ext/carray_kernels_binop.c +0 -11001
- data/ext/carray_kernels_init.c +0 -1131
- data/ext/carray_kernels_map.c +0 -3467
- data/ext/carray_kernels_moncmp.c +0 -2097
- data/ext/carray_kernels_monop.c +0 -18313
- data/ext/carray_kernels_reduce_aggregate.c +0 -25837
- data/ext/carray_kernels_reduce_boolean.c +0 -330
- data/ext/carray_kernels_reduce_cumulative.c +0 -14593
- data/ext/carray_kernels_reduce_extreme.c +0 -16948
- data/ext/carray_kernels_reduce_variance.c +0 -3910
- data/ext/carray_kernels_scan.c +0 -3693
- data/ext/carray_kernels_search.c +0 -32138
- data/ext/carray_kernels_sort.c +0 -10626
- data/ext/carray_kernels_triop.c +0 -1392
data/yard-stubs/ca_obj_block.rb
CHANGED
|
@@ -10,7 +10,8 @@ class CABlock
|
|
|
10
10
|
# @overload size0
|
|
11
11
|
# Returns the parent dimension sizes that the block is carved
|
|
12
12
|
# from (one Integer per axis). Distinct from `shape`, which is
|
|
13
|
-
# the block's own shape (=
|
|
13
|
+
# the block's own shape (= what it exposes after step / stride
|
|
14
|
+
# logic).
|
|
14
15
|
# @return [Array<Integer>]
|
|
15
16
|
def size0; end
|
|
16
17
|
|
|
@@ -26,12 +27,6 @@ class CABlock
|
|
|
26
27
|
# @return [Array<Integer>]
|
|
27
28
|
def step; end
|
|
28
29
|
|
|
29
|
-
# @overload count
|
|
30
|
-
# Returns the per-axis number of elements the block exposes.
|
|
31
|
-
# Same as `shape`.
|
|
32
|
-
# @return [Array<Integer>]
|
|
33
|
-
def count; end
|
|
34
|
-
|
|
35
30
|
# @overload offset
|
|
36
31
|
# Returns the block's base flat offset into the parent (in
|
|
37
32
|
# element units), set at construction and adjusted as start[]
|
data/yard-stubs/ca_obj_fake.rb
CHANGED
|
@@ -22,7 +22,7 @@ class CArray
|
|
|
22
22
|
# reinterpret the storage on purpose. A Numeric Face, whose surface *is*
|
|
23
23
|
# its storage, is unaffected.
|
|
24
24
|
# @param data_type [Symbol, Integer, Class, String]
|
|
25
|
-
# @param bytes [Integer] element byte size for `:fixlen
|
|
25
|
+
# @param bytes [Integer] element byte size for `:fixlen` (1 or more).
|
|
26
26
|
# @return [CAFake]
|
|
27
27
|
# @raise [TypeError] when `self` is a Face and the request would read its
|
|
28
28
|
# storage under another type.
|
data/yard-stubs/ca_obj_field.rb
CHANGED
|
@@ -18,7 +18,7 @@ class CArray
|
|
|
18
18
|
# @param bytes [Integer, nil] element size; required for `:fixlen`,
|
|
19
19
|
# inferred otherwise.
|
|
20
20
|
# @return [CAField]
|
|
21
|
-
# @raise [
|
|
21
|
+
# @raise [ArgumentError] when `offset` is negative or the
|
|
22
22
|
# `offset + bytes` window falls outside one parent record.
|
|
23
23
|
# @overload field(offset, template)
|
|
24
24
|
# Returns a CARefer over a {CAField}: takes `template.elements *
|
data/yard-stubs/ca_obj_refer.rb
CHANGED
|
@@ -32,10 +32,10 @@ class CArray
|
|
|
32
32
|
# defaults to `self.bytes`.
|
|
33
33
|
# @param offset [Integer] offset in parent elements.
|
|
34
34
|
# @return [CARefer, CARecord]
|
|
35
|
-
# @raise [
|
|
35
|
+
# @raise [ArgumentError] when the byte widths do not divide
|
|
36
36
|
# evenly, when `offset` is negative, or when the requested
|
|
37
37
|
# view extends past the parent's data.
|
|
38
|
-
# @raise [
|
|
38
|
+
# @raise [CArray::DataTypeError] when reinterpreting a CA_OBJECT parent
|
|
39
39
|
# with a non-object `data_type`.
|
|
40
40
|
def refer(*argv); end
|
|
41
41
|
|
|
@@ -54,7 +54,7 @@ class CArray
|
|
|
54
54
|
# @return [CArray] the reshape view.
|
|
55
55
|
# @raise [ArgumentError] when the number of dims exceeds
|
|
56
56
|
# `CA_RANK_MAX`.
|
|
57
|
-
# @raise [
|
|
57
|
+
# @raise [ArgumentError] when the product does not equal
|
|
58
58
|
# `self.elements` (with no placeholder), when the placeholder
|
|
59
59
|
# cannot be inferred, when more than one placeholder is
|
|
60
60
|
# given, or when a `nil` has no matching source axis.
|
data/yard-stubs/ca_obj_roll.rb
CHANGED
|
@@ -38,7 +38,6 @@ class CArray
|
|
|
38
38
|
# shorter than `ndim` (missing axes default to `0`).
|
|
39
39
|
# @return [CARoll]
|
|
40
40
|
# @raise [ArgumentError] when more than `ndim` shifts are given.
|
|
41
|
-
# @raise [IndexError] when any parent dimension is non-positive.
|
|
42
41
|
def roll(*shifts); end
|
|
43
42
|
|
|
44
43
|
# @!endgroup
|
data/yard-stubs/ca_obj_stride.rb
CHANGED
|
@@ -20,7 +20,8 @@ class CArray
|
|
|
20
20
|
|
|
21
21
|
# Returns a {CAStride} view of `self` with the given byte strides and
|
|
22
22
|
# starting byte offset, inheriting the receiver's data type and element
|
|
23
|
-
# size. Memory is shared with the receiver
|
|
23
|
+
# size. Memory is shared with the receiver, and a Face receiver stays the
|
|
24
|
+
# Face.
|
|
24
25
|
#
|
|
25
26
|
# This is a low-level escape hatch: the strides and offset are **not**
|
|
26
27
|
# bounds-checked against the receiver's memory, so a combination that
|
|
@@ -46,7 +47,8 @@ class CArray
|
|
|
46
47
|
#
|
|
47
48
|
# Truncate mode: a trailing partial window is dropped rather than padded.
|
|
48
49
|
# Memory is shared with the parent, and because windows overlap, one parent
|
|
49
|
-
# cell is visible from several positions of the view.
|
|
50
|
+
# cell is visible from several positions of the view. A Face parent stays
|
|
51
|
+
# the Face.
|
|
50
52
|
#
|
|
51
53
|
# Reduce over the trailing `ndim` axes for a rolling statistic.
|
|
52
54
|
#
|
|
@@ -70,7 +72,7 @@ class CArray
|
|
|
70
72
|
# The window axes are inserted before the trailing axes, so the result rank
|
|
71
73
|
# is `ndim + S`. With `S == ndim` there are no trailing axes and the
|
|
72
74
|
# result is identical to {#sliding_windows}. Truncate mode; memory is
|
|
73
|
-
# shared with the parent.
|
|
75
|
+
# shared with the parent, and a Face parent stays the Face.
|
|
74
76
|
#
|
|
75
77
|
# @overload unfold(window, step: nil)
|
|
76
78
|
# @overload unfold(w0, w1, ..., step: nil)
|
|
@@ -93,13 +95,14 @@ class CArray
|
|
|
93
95
|
# tile size: nothing is truncated and no cell is aliased twice. Reduce over
|
|
94
96
|
# the trailing `ndim` axes (e.g. `v.mean(-1, -2)` for a 2-D parent) for
|
|
95
97
|
# per-tile statistics such as pooling or block-wise aggregation. Memory is
|
|
96
|
-
# shared with the parent.
|
|
98
|
+
# shared with the parent, and a Face parent stays the Face.
|
|
97
99
|
#
|
|
98
100
|
# @overload block_view(block)
|
|
99
101
|
# @overload block_view(b0, b1, ...)
|
|
100
102
|
# @param block [Array<Integer>, Integer] tile length per axis, one per
|
|
101
103
|
# dimension, as an Array or as variadic arguments.
|
|
102
|
-
# @return [CAStride] of rank `2 * ndim
|
|
104
|
+
# @return [CAStride] of rank `2 * ndim` (the parent's Face class when
|
|
105
|
+
# the parent is a Face).
|
|
103
106
|
# @raise [ArgumentError] when the tile count does not equal `ndim`, when
|
|
104
107
|
# a tile length is not positive, when an axis is not divisible by its
|
|
105
108
|
# tile length, or when `2 * ndim` exceeds `CA_RANK_MAX`.
|
|
@@ -148,8 +151,8 @@ class CArray
|
|
|
148
151
|
# @overload flip(axis)
|
|
149
152
|
# @overload flip(a0, a1, ...)
|
|
150
153
|
# @overload flip([a0, a1, ...])
|
|
151
|
-
# @param axis [Array<Integer>, Integer] axes to reverse; negative
|
|
152
|
-
# count from the last axis.
|
|
154
|
+
# @param axis [Array<Integer>, Integer, nil] axes to reverse; negative
|
|
155
|
+
# indices count from the last axis. `flip(nil)` is the same as `flip`.
|
|
153
156
|
# @return [CAStride]
|
|
154
157
|
# @raise [ArgumentError] when an axis is out of range or repeated.
|
|
155
158
|
def flip(*axis); end
|
|
@@ -29,7 +29,7 @@ class CArray
|
|
|
29
29
|
# @param imap [Array<Integer>] permutation of `0 ... ndim`.
|
|
30
30
|
# @return [CATranspose]
|
|
31
31
|
# @raise [ArgumentError] when `imap.length != ndim`.
|
|
32
|
-
# @raise [
|
|
32
|
+
# @raise [ArgumentError] when an entry of `imap` is out of range
|
|
33
33
|
# or duplicated.
|
|
34
34
|
def transpose(*imap); end
|
|
35
35
|
|
data/yard-stubs/ca_obj_window.rb
CHANGED
|
@@ -20,7 +20,14 @@ class CArray
|
|
|
20
20
|
# axis, which may extend past either end of the parent. Cells inside the
|
|
21
21
|
# parent alias it, so writes through the view reach the parent; cells
|
|
22
22
|
# outside take `fill_value` (default `0`), and `fill_value: UNDEF` masks
|
|
23
|
-
# them instead.
|
|
23
|
+
# them instead. A write that lands outside the parent has no cell to land
|
|
24
|
+
# in and is discarded.
|
|
25
|
+
#
|
|
26
|
+
# A range wider than its axis is how an array is **padded**: `a.window(-1..
|
|
27
|
+
# a.dim0, -1..a.dim1)` puts a one-cell border all round, which is NumPy's
|
|
28
|
+
# `pad` with no allocation (`fill_value:` is its `constant`, `bounds:
|
|
29
|
+
# :nearest` its `edge`). {#windows} is the different, plural thing: one
|
|
30
|
+
# such window anchored on every cell, folded.
|
|
24
31
|
#
|
|
25
32
|
# Only unit-step ranges are accepted, and each range must run forward, so
|
|
26
33
|
# the `0..-1` end-relative notation cannot be used here.
|
|
@@ -30,7 +37,8 @@ class CArray
|
|
|
30
37
|
# must equal `self.ndim`.
|
|
31
38
|
# @param fill_value [Object] value given to out-of-range cells; `UNDEF`
|
|
32
39
|
# masks them instead.
|
|
33
|
-
# @param bounds [String] what an out-of-range index means
|
|
40
|
+
# @param bounds [String, Symbol] what an out-of-range index means; a
|
|
41
|
+
# Symbol says the same as the String, matching {#windows}: `"fill"`
|
|
34
42
|
# (default) uses `fill_value`, `"nearest"` clamps to the edge cell,
|
|
35
43
|
# `"ruby"` reads negative indices from the far end, `"strict"` raises.
|
|
36
44
|
# `"mask"` masks the cell but warns — pass `fill_value: UNDEF` instead.
|
|
@@ -40,8 +48,7 @@ class CArray
|
|
|
40
48
|
# is passed (the block form was removed in 3.0), or when `bounds` is
|
|
41
49
|
# `"periodic"` / `"reflect"` (both removed in 3.0; use {#roll} for a
|
|
42
50
|
# cyclic shift).
|
|
43
|
-
# @raise [
|
|
44
|
-
# @raise [RuntimeError] when `bounds` conflicts with `fill_value: UNDEF`,
|
|
51
|
+
# @raise [ArgumentError] when `bounds` conflicts with `fill_value: UNDEF`,
|
|
45
52
|
# or when `bounds` is not a recognised value.
|
|
46
53
|
def window(*ranges, fill_value: 0, bounds: "fill"); end
|
|
47
54
|
|
data/yard-stubs/carray_access.rb
CHANGED
|
@@ -22,7 +22,7 @@ class CArray
|
|
|
22
22
|
# - Integer CArray — fancy gather (index array); shape follows the
|
|
23
23
|
# index array.
|
|
24
24
|
# - `:_` — newaxis: insert a size-1 axis at this position.
|
|
25
|
-
# -
|
|
25
|
+
# - `:%` — repeat / tiling sugar.
|
|
26
26
|
# - `:>` — slab axis: wrap the result in a `CASlabIterator`.
|
|
27
27
|
# - a member name Symbol — project a struct field (see `CARecord`).
|
|
28
28
|
#
|
|
@@ -82,9 +82,10 @@ class CArray
|
|
|
82
82
|
# Array of length `self.ndim`, so `i, j = ca.addr2index(x)` unpacks
|
|
83
83
|
# uniformly for scalar and vector inputs.
|
|
84
84
|
# @param addr [Integer, CArray] a flat address in `0...elements`,
|
|
85
|
-
# or a CArray of such addresses (arbitrary shape).
|
|
85
|
+
# or a CArray of such addresses (arbitrary shape). A negative
|
|
86
|
+
# address counts from the end.
|
|
86
87
|
# @return [Array<Integer>, Array<CArray>] one entry per axis.
|
|
87
|
-
# @raise [
|
|
88
|
+
# @raise [IndexError] when any `addr` is out of range.
|
|
88
89
|
def addr2index(addr); end
|
|
89
90
|
|
|
90
91
|
# @overload index2addr(*index)
|
|
@@ -106,8 +107,8 @@ class CArray
|
|
|
106
107
|
# @param addr [Integer, CArray] a flat address or a CArray of them.
|
|
107
108
|
# @param shape [Array<Integer>] the row-major shape defining the grid.
|
|
108
109
|
# @return [Array<Integer>, Array<CArray>] one entry per axis.
|
|
109
|
-
# @raise [
|
|
110
|
-
#
|
|
110
|
+
# @raise [IndexError] when any `addr` is out of range.
|
|
111
|
+
# @raise [ArgumentError] when `shape:` is missing.
|
|
111
112
|
def self.addr2index(addr, shape:); end
|
|
112
113
|
|
|
113
114
|
# @overload index2addr(*index, shape:)
|
|
@@ -23,9 +23,9 @@ class CArray
|
|
|
23
23
|
# @param shape [Array<Integer>] target shape, with
|
|
24
24
|
# `length >= self.ndim`.
|
|
25
25
|
# @return [CArray]
|
|
26
|
-
# @raise [
|
|
26
|
+
# @raise [ArgumentError] if a source axis cannot be paired with a
|
|
27
27
|
# target axis (cross-ndim expansion is intentionally strict —
|
|
28
|
-
# see {CArray.broadcast} for the explicit-`:_`
|
|
28
|
+
# see {CArray.broadcast} for the explicit-`:_` axis
|
|
29
29
|
# declaration form).
|
|
30
30
|
# @example
|
|
31
31
|
# a = CArray.float64(3) { [1.0, 2.0, 3.0] }
|
data/yard-stubs/carray_cast.rb
CHANGED
|
@@ -8,57 +8,75 @@
|
|
|
8
8
|
# is a top-level function that coerces `obj` (a CArray, Array,
|
|
9
9
|
# Numeric, or anything castable) into a CArray of the named element
|
|
10
10
|
# type, equivalent to `obj.to_ca.as_type(:<type>)`.
|
|
11
|
+
#
|
|
12
|
+
# These are casts, not shape spellings: `CA_INT32(3, 3)` is not the
|
|
13
|
+
# `(3, 3)` array that `CArray.int32(3, 3)` builds, and is refused.
|
|
14
|
+
# A `Range` accepts one more argument, the step, and that is the only
|
|
15
|
+
# two-argument form:
|
|
16
|
+
#
|
|
17
|
+
# CA_INT32(0..6) # => [ 0, 1, 2, 3, 4, 5, 6 ]
|
|
18
|
+
# CA_INT32(0..6, 2) # => [ 0, 2, 4, 6 ]
|
|
19
|
+
# CA_INT32(0, 2) # ArgumentError
|
|
20
|
+
#
|
|
21
|
+
# A step of `0` raises `RuntimeError`. A step given for anything but a
|
|
22
|
+
# `Range`, or a third argument, raises `ArgumentError`. An
|
|
23
|
+
# `Enumerator::ArithmeticSequence` already carries its own step, so
|
|
24
|
+
# `CA_INT32((0..6).step(2))` needs no second argument.
|
|
25
|
+
#
|
|
26
|
+
# `CA_FIXLEN` takes `bytes:` instead of a step; see {#CA_FIXLEN}.
|
|
11
27
|
module Kernel
|
|
12
28
|
# @!group CArray cast shorthands
|
|
13
29
|
|
|
14
30
|
# Coerces `obj` into a `:boolean` CArray. @return [CArray]
|
|
15
|
-
def CA_BOOLEAN(obj); end
|
|
31
|
+
def CA_BOOLEAN(obj = nil, step = nil); end
|
|
16
32
|
# Coerces `obj` into an `:int8` CArray. @return [CArray]
|
|
17
|
-
def CA_INT8(obj); end
|
|
33
|
+
def CA_INT8(obj = nil, step = nil); end
|
|
18
34
|
# Coerces `obj` into a `:uint8` CArray. @return [CArray]
|
|
19
|
-
def CA_UINT8(obj); end
|
|
35
|
+
def CA_UINT8(obj = nil, step = nil); end
|
|
20
36
|
# Coerces `obj` into an `:int16` CArray. @return [CArray]
|
|
21
|
-
def CA_INT16(obj); end
|
|
37
|
+
def CA_INT16(obj = nil, step = nil); end
|
|
22
38
|
# Coerces `obj` into a `:uint16` CArray. @return [CArray]
|
|
23
|
-
def CA_UINT16(obj); end
|
|
39
|
+
def CA_UINT16(obj = nil, step = nil); end
|
|
24
40
|
# Coerces `obj` into an `:int32` CArray. @return [CArray]
|
|
25
|
-
def CA_INT32(obj); end
|
|
41
|
+
def CA_INT32(obj = nil, step = nil); end
|
|
26
42
|
# Coerces `obj` into a `:uint32` CArray. @return [CArray]
|
|
27
|
-
def CA_UINT32(obj); end
|
|
43
|
+
def CA_UINT32(obj = nil, step = nil); end
|
|
28
44
|
# Coerces `obj` into an `:int64` CArray. @return [CArray]
|
|
29
|
-
def CA_INT64(obj); end
|
|
45
|
+
def CA_INT64(obj = nil, step = nil); end
|
|
30
46
|
# Coerces `obj` into a `:uint64` CArray. @return [CArray]
|
|
31
|
-
def CA_UINT64(obj); end
|
|
47
|
+
def CA_UINT64(obj = nil, step = nil); end
|
|
32
48
|
# Coerces `obj` into a `:float32` CArray. @return [CArray]
|
|
33
|
-
def CA_FLOAT32(obj); end
|
|
49
|
+
def CA_FLOAT32(obj = nil, step = nil); end
|
|
34
50
|
# Coerces `obj` into a `:float64` CArray. @return [CArray]
|
|
35
|
-
def CA_FLOAT64(obj); end
|
|
51
|
+
def CA_FLOAT64(obj = nil, step = nil); end
|
|
36
52
|
# Coerces `obj` into a `:cmplx64` CArray. @return [CArray]
|
|
37
|
-
def CA_CMPLX64(obj); end
|
|
53
|
+
def CA_CMPLX64(obj = nil, step = nil); end
|
|
38
54
|
# Coerces `obj` into a `:cmplx128` CArray. @return [CArray]
|
|
39
|
-
def CA_CMPLX128(obj); end
|
|
55
|
+
def CA_CMPLX128(obj = nil, step = nil); end
|
|
40
56
|
# Coerces `obj` into an `:object` CArray. @return [CArray]
|
|
41
|
-
def CA_OBJECT(obj); end
|
|
57
|
+
def CA_OBJECT(obj = nil, step = nil); end
|
|
42
58
|
# Coerces `obj` into a `CA_SIZE` (platform native size) CArray.
|
|
43
59
|
# @return [CArray]
|
|
44
|
-
def CA_SIZE(obj); end
|
|
45
|
-
# Coerces `obj` into a `:fixlen` CArray.
|
|
46
|
-
|
|
60
|
+
def CA_SIZE(obj = nil, step = nil); end
|
|
61
|
+
# Coerces `obj` into a `:fixlen` CArray. `bytes` defaults to the
|
|
62
|
+
# longest top-level element of an `Array`, or `0` for `nil`.
|
|
63
|
+
# @return [CArray]
|
|
64
|
+
def CA_FIXLEN(obj, bytes: nil); end
|
|
47
65
|
|
|
48
66
|
# Alias of {#CA_UINT8}. @return [CArray]
|
|
49
|
-
def CA_BYTE(obj); end
|
|
67
|
+
def CA_BYTE(obj = nil, step = nil); end
|
|
50
68
|
# Alias of {#CA_INT16}. @return [CArray]
|
|
51
|
-
def CA_SHORT(obj); end
|
|
69
|
+
def CA_SHORT(obj = nil, step = nil); end
|
|
52
70
|
# Alias of {#CA_INT32}. @return [CArray]
|
|
53
|
-
def CA_INT(obj); end
|
|
71
|
+
def CA_INT(obj = nil, step = nil); end
|
|
54
72
|
# Alias of {#CA_FLOAT32}. @return [CArray]
|
|
55
|
-
def CA_FLOAT(obj); end
|
|
73
|
+
def CA_FLOAT(obj = nil, step = nil); end
|
|
56
74
|
# Alias of {#CA_FLOAT64}. @return [CArray]
|
|
57
|
-
def CA_DOUBLE(obj); end
|
|
75
|
+
def CA_DOUBLE(obj = nil, step = nil); end
|
|
58
76
|
# Alias of {#CA_CMPLX64}. @return [CArray]
|
|
59
|
-
def CA_COMPLEX(obj); end
|
|
77
|
+
def CA_COMPLEX(obj = nil, step = nil); end
|
|
60
78
|
# Alias of {#CA_CMPLX128}. @return [CArray]
|
|
61
|
-
def CA_DCOMPLEX(obj); end
|
|
79
|
+
def CA_DCOMPLEX(obj = nil, step = nil); end
|
|
62
80
|
|
|
63
81
|
# @!endgroup
|
|
64
82
|
end
|
|
@@ -71,17 +89,21 @@ class CArray
|
|
|
71
89
|
# @overload to_type(data_type, bytes: nil)
|
|
72
90
|
# Returns a new entity holding the elements of `self` converted to
|
|
73
91
|
# `data_type` (an eager copy that owns its storage). Masked cells are
|
|
74
|
-
# carried across
|
|
75
|
-
# subclass) the result
|
|
92
|
+
# carried across, and so are the attributes `self` shows (`attrs`).
|
|
93
|
+
# When `data_type` is a data_class (a CAStruct subclass) the result
|
|
94
|
+
# is wrapped in CARecord.
|
|
76
95
|
#
|
|
77
96
|
# When `self` is an `:object` array and `data_type` is an integer or
|
|
78
|
-
# float type,
|
|
79
|
-
#
|
|
80
|
-
#
|
|
81
|
-
#
|
|
82
|
-
#
|
|
83
|
-
#
|
|
84
|
-
#
|
|
97
|
+
# float type, a String cell is read as a decimal number, not as a Ruby
|
|
98
|
+
# literal: `"010"` is 10, and `"0x10"` / `"1_000"` / `"0b11"` are not
|
|
99
|
+
# numbers. An integer type takes a number whose value is exactly an
|
|
100
|
+
# integer (`"1.0"`, `"1e3"`) but not `"1.5"`. A cell that cannot be
|
|
101
|
+
# read becomes UNDEF (masked) rather than a silent `0.0` or a raise:
|
|
102
|
+
# `nil`, `""`, `"xx"`, and a String integer the type cannot hold
|
|
103
|
+
# (`"300"` into `:int8`) all map to UNDEF. Explicit `nan` / `inf` /
|
|
104
|
+
# `infinity` (optional sign, any case) are kept as NaN / ±Infinity for
|
|
105
|
+
# float types. A cell that is not a String goes through `Integer()` /
|
|
106
|
+
# `Float()` as before.
|
|
85
107
|
# @param data_type [Symbol, Integer, Class, String] target element type.
|
|
86
108
|
# @param bytes [Integer, nil] element width in bytes, required for
|
|
87
109
|
# `:fixlen`.
|
|
@@ -337,7 +359,7 @@ class CArray
|
|
|
337
359
|
# primitive the binary operators use.
|
|
338
360
|
# @param other [CArray, Object] the second operand.
|
|
339
361
|
# @return [Array(CArray, CArray)]
|
|
340
|
-
# @raise [
|
|
362
|
+
# @raise [CArray::DataTypeError] when the two data_types have no common type.
|
|
341
363
|
def cast_with(other); end
|
|
342
364
|
|
|
343
365
|
# `coerce` is documented with its definition in ext/carray_operator.c;
|
|
@@ -376,10 +398,9 @@ class CArray
|
|
|
376
398
|
# `nil` keeps the source type (or `:object` when `other` is `nil`).
|
|
377
399
|
# @return [CArray]
|
|
378
400
|
# @raise [RuntimeError] when `other` is read-only, its MemoryView is
|
|
379
|
-
# read-only, its `to_ca` refuses `writable: true
|
|
380
|
-
#
|
|
381
|
-
#
|
|
382
|
-
# CArray.
|
|
401
|
+
# read-only, or its `to_ca` refuses `writable: true`.
|
|
402
|
+
# @raise [TypeError] when `other` cannot be wrapped as a CArray, or
|
|
403
|
+
# `other#to_ca` returns something that is not a CArray.
|
|
383
404
|
# @raise [ArgumentError] when `other#to_ca` does not accept `writable:`.
|
|
384
405
|
# @raise [TypeError] when `other` is a Face and `data_type` differs from
|
|
385
406
|
# its surface type.
|
|
@@ -445,20 +466,30 @@ class CArray
|
|
|
445
466
|
# data_type inferred (3 -> `:int64`, 3.14 -> `:float64`,
|
|
446
467
|
# 1+2i -> `:cmplx128`, ...)
|
|
447
468
|
#
|
|
448
|
-
#
|
|
449
|
-
#
|
|
469
|
+
# The arrays and data_type representations promote together. A
|
|
470
|
+
# scalar (a value, or a CScalar) then joins their type the way it
|
|
471
|
+
# does beside an operator: one of the same kind takes that type
|
|
472
|
+
# (`result_type(float32_array, 0.1)` is `:float32`, as
|
|
473
|
+
# `float32_array + 0.1` is), one of another kind promotes
|
|
474
|
+
# (`result_type(int32_array, 1.5)` is `:float64`), and an Integer
|
|
475
|
+
# that does not fit an integer type takes `:int64`. With no array or
|
|
476
|
+
# data_type representation, every argument promotes by its own type.
|
|
477
|
+
#
|
|
478
|
+
# Integer args are interpreted as *values*, not as data_type codes:
|
|
450
479
|
# `result_type(8)` returns `:int64` because the value 8 is an Integer,
|
|
451
480
|
# not because a data_type code equals 8. Use `result_type(:int64)` or
|
|
452
481
|
# `result_type(CA_INT64)` to be explicit about data_type intent.
|
|
453
482
|
# @param args [Array<CArray, Symbol, String, Class, Object>] operands.
|
|
454
483
|
# @return [Symbol]
|
|
455
484
|
# @raise [ArgumentError] when called with no arguments.
|
|
456
|
-
# @raise [
|
|
485
|
+
# @raise [CArray::DataTypeError] when two inputs are mutually incompatible
|
|
457
486
|
# (e.g. `:object` with `:fixlen`).
|
|
458
487
|
# @example
|
|
459
488
|
# CArray.result_type(:int32, :float32) #=> :float32
|
|
460
489
|
# CArray.result_type(3, 3.14) #=> :float64
|
|
461
490
|
# CArray.result_type(true, 3) #=> :int64
|
|
491
|
+
# CArray.result_type(CA_INT8([1]), 1) #=> :int8
|
|
492
|
+
# CArray.result_type(CA_INT8([1]), 300) #=> :int64
|
|
462
493
|
def self.result_type(*args); end
|
|
463
494
|
|
|
464
495
|
# @overload promote_list(list, data_type: nil)
|
|
@@ -471,8 +502,12 @@ class CArray
|
|
|
471
502
|
# elements passes through (CAStack lifts it), unless the class is not
|
|
472
503
|
# portable (CAConstString) or the elements disagree on state
|
|
473
504
|
# (CATime with different units); a list of primitives is
|
|
474
|
-
# promoted via {.result_type} + {.wrap_readonly}
|
|
475
|
-
#
|
|
505
|
+
# promoted via {.result_type} + {.wrap_readonly}, except that a list
|
|
506
|
+
# mixing signed and unsigned integers takes a type that holds both
|
|
507
|
+
# (`uint8` with `int8` is `int16`, 64-bit pairs are `:object`), and an
|
|
508
|
+
# integer of 32 bits or more beside `float32` takes `float64`, since
|
|
509
|
+
# the arrays are joined value for value; a mix of Face and non-Face,
|
|
510
|
+
# or heterogeneous Face classes, is rejected.
|
|
476
511
|
#
|
|
477
512
|
# With an explicit primitive `data_type`: all-primitive elements are
|
|
478
513
|
# wrapped read-only to the requested type; any Face element is
|
|
@@ -38,6 +38,13 @@ class CArray
|
|
|
38
38
|
|
|
39
39
|
# @!group Copy and conversion
|
|
40
40
|
|
|
41
|
+
# On a Face (`CATime`, `CACategorical`, `CAConstString`, ...) the
|
|
42
|
+
# bytes are its storage, and none of its state is written: not the
|
|
43
|
+
# unit of a `CATime`, not the labels of a `CACategorical`. A
|
|
44
|
+
# `CAConstString` cell is a `(start, end)` pair into its own byte
|
|
45
|
+
# pool, so its strings are not written at all; call
|
|
46
|
+
# `to_fixlen_string` first to dump the text.
|
|
47
|
+
#
|
|
41
48
|
# @overload dump_binary
|
|
42
49
|
# Returns a new binary String containing the raw element bytes of
|
|
43
50
|
# `self` in row-major order.
|
|
@@ -60,6 +67,10 @@ class CArray
|
|
|
60
67
|
# @return [String]
|
|
61
68
|
def to_s; end
|
|
62
69
|
|
|
70
|
+
# On a Face the bytes are read into its storage, and its state is
|
|
71
|
+
# the receiver's own: load into a Face set up with the same state
|
|
72
|
+
# (unit, labels) that was in force when the bytes were dumped.
|
|
73
|
+
#
|
|
63
74
|
# @overload load_binary(io)
|
|
64
75
|
# Reads `ca_length(self)` bytes from `io` and overwrites the
|
|
65
76
|
# element data of `self` in row-major order. `io` may be a
|
|
@@ -67,7 +78,8 @@ class CArray
|
|
|
67
78
|
# `read(n, buf = nil)`.
|
|
68
79
|
# @param io [String, IO, #read]
|
|
69
80
|
# @return [self]
|
|
70
|
-
# @raise [RuntimeError] on short read
|
|
81
|
+
# @raise [RuntimeError] on a short read.
|
|
82
|
+
# @raise [ArgumentError] when a String source is not the array's size.
|
|
71
83
|
# @raise [CArray::DataTypeError] if `self.data_type` is
|
|
72
84
|
# `:object`.
|
|
73
85
|
def load_binary(io); end
|
data/yard-stubs/carray_copy.rb
CHANGED
|
@@ -8,10 +8,15 @@ class CArray
|
|
|
8
8
|
# @overload copy
|
|
9
9
|
# Returns a fresh entity CArray with the same shape, `data_type`,
|
|
10
10
|
# element values, and mask state as `self`. Always allocates and
|
|
11
|
-
# copies, even when `self` is already an entity.
|
|
11
|
+
# copies, even when `self` is already an entity. The copy gets the
|
|
12
|
+
# attributes `self` shows (`attrs`) as its own.
|
|
12
13
|
#
|
|
13
14
|
# Use `copy` when you need an array you own and can mutate
|
|
14
|
-
# without affecting any source.
|
|
15
|
+
# without affecting any source. It is the only way to copy a
|
|
16
|
+
# CArray: `to_ca` returns `self`, and `dup` / `clone` on a view
|
|
17
|
+
# return another view onto the same storage, so writing to any of
|
|
18
|
+
# them writes to the source. Don't use `dup`, `clone` or `to_ca`
|
|
19
|
+
# to copy.
|
|
15
20
|
# @return [CArray] independent entity.
|
|
16
21
|
# @example A view's copy is independent of its source
|
|
17
22
|
# a = CArray.float64(4).seq
|
|
@@ -59,7 +64,7 @@ class CArray
|
|
|
59
64
|
# @param data_type [Symbol] target element type
|
|
60
65
|
# (e.g. `:int32`, `:float64`, `:fixlen`).
|
|
61
66
|
# @param bytes [Integer] element byte size; required for
|
|
62
|
-
# `:fixlen
|
|
67
|
+
# `:fixlen` (1 or more), ignored for numeric types.
|
|
63
68
|
# @return [CArray]
|
|
64
69
|
# @overload template { value }
|
|
65
70
|
# With a 0-arity block, fills every element of the result with
|
data/yard-stubs/carray_core.rb
CHANGED
|
@@ -3,64 +3,6 @@
|
|
|
3
3
|
# See yard-stubs/README.md and yard-stubs/STYLE.md.
|
|
4
4
|
|
|
5
5
|
class CArray
|
|
6
|
-
# @!group Attach lifecycle
|
|
7
|
-
#
|
|
8
|
-
# The `attach` / `attach!` family is an internal lifecycle API used
|
|
9
|
-
# by library authors writing CArray-aware C extensions. End users
|
|
10
|
-
# should not normally need to call these methods — view algebra and
|
|
11
|
-
# `CArray#[]` / `[]=` handle attach/sync transparently.
|
|
12
|
-
#
|
|
13
|
-
# The block-form `attach` (no sync on exit) and `attach!` (sync on
|
|
14
|
-
# exit) wrap a body of code so that the underlying memory block is
|
|
15
|
-
# guaranteed to be materialized while the block runs and is
|
|
16
|
-
# released afterward. The dunder forms (`__attach__`, `__sync__`,
|
|
17
|
-
# `__detach__`) expose the raw three-step protocol for callers that
|
|
18
|
-
# cannot use a block.
|
|
19
|
-
|
|
20
|
-
# @overload attach { ... }
|
|
21
|
-
# Attaches `self`, yields, and detaches on block exit. No sync
|
|
22
|
-
# is performed.
|
|
23
|
-
# @yield
|
|
24
|
-
# @return [Object] the block's return value.
|
|
25
|
-
def attach; end
|
|
26
|
-
|
|
27
|
-
# @overload attach! { ... }
|
|
28
|
-
# Attaches `self`, yields, then syncs and detaches on block exit.
|
|
29
|
-
# Use this form when the block mutates `self.ptr` and you need
|
|
30
|
-
# the changes flushed back to the parent.
|
|
31
|
-
# @yield
|
|
32
|
-
# @return [Object] the block's return value.
|
|
33
|
-
def attach!; end
|
|
34
|
-
|
|
35
|
-
# @private
|
|
36
|
-
# @overload __attach__
|
|
37
|
-
# Raw attach: materializes the memory block of `self` and leaves
|
|
38
|
-
# it attached. Caller is responsible for the matching
|
|
39
|
-
# `__detach__` (and `__sync__`, if changes were made).
|
|
40
|
-
#
|
|
41
|
-
# Prefer the block form {#attach!} unless block scope is
|
|
42
|
-
# impossible.
|
|
43
|
-
# @return [self]
|
|
44
|
-
# @api private
|
|
45
|
-
def __attach__; end
|
|
46
|
-
|
|
47
|
-
# @private
|
|
48
|
-
# @overload __sync__
|
|
49
|
-
# Raw sync: writes any pending changes in `self.ptr` back to the
|
|
50
|
-
# parent. Requires `self` to be currently attached.
|
|
51
|
-
# @return [self]
|
|
52
|
-
# @api private
|
|
53
|
-
def __sync__; end
|
|
54
|
-
|
|
55
|
-
# @private
|
|
56
|
-
# @overload __detach__
|
|
57
|
-
# Raw detach: releases the memory block paired with `__attach__`.
|
|
58
|
-
# @return [self]
|
|
59
|
-
# @api private
|
|
60
|
-
def __detach__; end
|
|
61
|
-
|
|
62
|
-
# @!endgroup
|
|
63
|
-
|
|
64
6
|
# @!group Attributes
|
|
65
7
|
|
|
66
8
|
# @overload members
|
|
@@ -68,7 +10,7 @@ class CArray
|
|
|
68
10
|
# Only valid when `self` carries a `data_class` (e.g. a
|
|
69
11
|
# `CARecord`).
|
|
70
12
|
# @return [Array<Symbol>]
|
|
71
|
-
# @raise [
|
|
13
|
+
# @raise [TypeError] if `self` has no `data_class`.
|
|
72
14
|
def members; end
|
|
73
15
|
|
|
74
16
|
# @overload fields
|
|
@@ -76,7 +18,7 @@ class CArray
|
|
|
76
18
|
# declaration order. Each entry is a CArray sharing storage with
|
|
77
19
|
# `self`.
|
|
78
20
|
# @return [Array<CArray>]
|
|
79
|
-
# @raise [
|
|
21
|
+
# @raise [TypeError] if `self` has no `data_class`.
|
|
80
22
|
def fields; end
|
|
81
23
|
|
|
82
24
|
# @overload fields_at(*names)
|
|
@@ -85,30 +27,8 @@ class CArray
|
|
|
85
27
|
# @param names [Array<Symbol, String, Integer>] member names or
|
|
86
28
|
# positional indices.
|
|
87
29
|
# @return [Array<CArray>]
|
|
88
|
-
# @raise [
|
|
30
|
+
# @raise [TypeError] if `self` has no `data_class`.
|
|
89
31
|
def fields_at(*names); end
|
|
90
32
|
|
|
91
33
|
# @!endgroup
|
|
92
|
-
|
|
93
|
-
class << self
|
|
94
|
-
# @!group Attach lifecycle
|
|
95
|
-
|
|
96
|
-
# @overload attach(*arrays) { ... }
|
|
97
|
-
# Attaches every CArray in `arrays`, yields, and detaches them
|
|
98
|
-
# in reverse order on block exit. No sync is performed.
|
|
99
|
-
# @param arrays [Array<CArray>]
|
|
100
|
-
# @yield
|
|
101
|
-
# @return [Object] the block's return value.
|
|
102
|
-
def attach(*arrays); end
|
|
103
|
-
|
|
104
|
-
# @overload attach!(*arrays) { ... }
|
|
105
|
-
# Attaches every CArray in `arrays`, yields, then syncs and
|
|
106
|
-
# detaches each on block exit.
|
|
107
|
-
# @param arrays [Array<CArray>]
|
|
108
|
-
# @yield
|
|
109
|
-
# @return [Object] the block's return value.
|
|
110
|
-
def attach!(*arrays); end
|
|
111
|
-
|
|
112
|
-
# @!endgroup
|
|
113
|
-
end
|
|
114
34
|
end
|
data/yard-stubs/carray_count.rb
CHANGED
|
@@ -26,6 +26,11 @@ class CArray
|
|
|
26
26
|
# Mask-cardinality and value-match are distinct concepts, so the
|
|
27
27
|
# overloading is unambiguous.
|
|
28
28
|
#
|
|
29
|
+
# On an `:object` array a cell counts when it is `==` to `v` (so `1`
|
|
30
|
+
# and `1.0` match), as {#eq} compares; the hash-based family
|
|
31
|
+
# ({#is_in}, {#value_counts}) uses `eql?` instead, as Ruby's
|
|
32
|
+
# `Array#uniq` does.
|
|
33
|
+
#
|
|
29
34
|
# Dispatch:
|
|
30
35
|
# - no argument: forwards to {#count_not_masked} (present-cell
|
|
31
36
|
# count).
|
|
@@ -40,7 +45,14 @@ class CArray
|
|
|
40
45
|
# stores 0/1, so `count(1)` == `count(true)`. Any other value
|
|
41
46
|
# (`2`, `1.0`, `nil`, …) raises `TypeError`.
|
|
42
47
|
# - `self` is numeric, `v` is scalar: `v` must be numeric (true /
|
|
43
|
-
# false are rejected).
|
|
48
|
+
# false are rejected -- they are the boolean array's domain).
|
|
49
|
+
# On an integer array a Float `v`, or a `v` array of a wider
|
|
50
|
+
# type, is compared in the type the two share, as {#eq} compares:
|
|
51
|
+
# `CA_INT32([1, 2]).count(1.5)` is `0`. An Integer `v` that does
|
|
52
|
+
# not fit the array raises `RangeError`.
|
|
53
|
+
# - `self.data_type == :object`, `v` is scalar: cells equal to `v`
|
|
54
|
+
# by Ruby `==`, so `count(1)` and `count(1.0)` agree, and `true` /
|
|
55
|
+
# `false` / `nil` are ordinary values to count.
|
|
44
56
|
#
|
|
45
57
|
# When `axis` is `nil` (default), reduces over all axes and
|
|
46
58
|
# returns an `Integer`. Otherwise reduces along the given
|
|
@@ -50,7 +62,9 @@ class CArray
|
|
|
50
62
|
# identity `0`, so the count over no cells is `0`, not `UNDEF`
|
|
51
63
|
# (pass `min_count:` to get `UNDEF` below a threshold instead).
|
|
52
64
|
#
|
|
53
|
-
# `:fixlen`
|
|
65
|
+
# `:fixlen` compares the whole cell by `memcmp`, with a short String
|
|
66
|
+
# query padded out to the cell width -- so a 4-byte cell holding
|
|
67
|
+
# `"a\0\0\0"` is counted by `count("a")`.
|
|
54
68
|
#
|
|
55
69
|
# A time array counts by its own values: `CATime` / `CATimedelta`
|
|
56
70
|
# descend to their storage and reconcile `v` into their unit, so `v`
|