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.
- checksums.yaml +4 -4
- data/.yardopts +1 -1
- data/CHANGELOG.md +7 -1940
- data/README.md +38 -32
- data/carray.gemspec +16 -4
- data/docs/changelogs/CHANGELOG-3.0.md +2464 -0
- data/ext/ca_array_pool.c +4 -5
- data/ext/ca_axis_descriptor.h +45 -30
- data/ext/ca_axis_dispatch.c +7 -4
- data/ext/ca_axis_group.c +6 -9
- data/ext/ca_bincmp_dispatch.h +16 -38
- data/ext/ca_binop_dispatch.c +27 -0
- data/ext/ca_binop_dispatch.h +22 -47
- data/ext/ca_categorical_iterator.c +36 -34
- data/ext/ca_compare.c +0 -1
- data/ext/ca_compare.h +8 -1
- data/ext/ca_composite_dispatch.h +6 -0
- data/ext/ca_for_buffer.h +6 -1
- data/ext/ca_group_iter.c +17 -18
- data/ext/ca_iter_state_fields.h +196 -0
- data/ext/ca_iter_substrate.h +84 -103
- data/ext/ca_kernel_iterator.c +125 -89
- data/ext/ca_kernel_iterator.h +229 -1506
- data/ext/ca_kernel_iterator_internal.h +1167 -0
- data/ext/ca_moncmp_dispatch.h +17 -24
- data/ext/ca_monop_dispatch.h +25 -74
- data/ext/ca_obj_array.c +90 -163
- data/ext/ca_obj_bincmp.c +47 -46
- data/ext/ca_obj_binop.c +38 -38
- data/ext/ca_obj_bitarray.c +5 -17
- data/ext/ca_obj_bitfield.c +15 -30
- data/ext/ca_obj_block.c +11 -12
- data/ext/ca_obj_byte_swap.c +32 -30
- data/ext/ca_obj_const_string.c +57 -62
- data/ext/ca_obj_face.c +99 -91
- data/ext/ca_obj_face.h +32 -170
- data/ext/ca_obj_fake.c +15 -21
- data/ext/ca_obj_farray.c +7 -9
- data/ext/ca_obj_field.c +17 -13
- data/ext/ca_obj_fixlen_string.c +8 -19
- data/ext/ca_obj_grid.c +137 -106
- data/ext/ca_obj_meld.c +23 -21
- data/ext/ca_obj_moncmp.c +10 -21
- data/ext/ca_obj_monop.c +24 -35
- data/ext/ca_obj_object.c +51 -37
- data/ext/ca_obj_record.c +74 -22
- data/ext/ca_obj_reduce.c +8 -10
- data/ext/ca_obj_refer.c +42 -29
- data/ext/ca_obj_remap.c +11 -29
- data/ext/ca_obj_repeat.c +41 -23
- data/ext/ca_obj_roll.c +18 -24
- data/ext/ca_obj_select.c +10 -22
- data/ext/ca_obj_select_axis.c +27 -36
- data/ext/ca_obj_shift.c +22 -42
- data/ext/ca_obj_source.c +1 -5
- data/ext/ca_obj_stack.c +28 -24
- data/ext/ca_obj_stride.c +53 -54
- data/ext/ca_obj_string.c +6 -18
- data/ext/ca_obj_tile.c +12 -12
- data/ext/ca_obj_time.c +12 -23
- data/ext/ca_obj_timedelta.c +12 -23
- data/ext/ca_obj_transpose.c +8 -10
- data/ext/ca_obj_triop.c +35 -39
- data/ext/ca_obj_window.c +67 -86
- data/ext/ca_op_cmplx64.h +4 -0
- data/ext/ca_op_ipower.c +34 -12
- data/ext/ca_op_powi.h +4 -0
- data/ext/ca_pow5_table.h +2 -1
- data/ext/ca_rng_normal.h +4 -0
- data/ext/ca_rng_xoshiro256pp.h +3 -0
- data/ext/ca_sort_kernels.h +20 -26
- data/ext/ca_sweep_engine.c +2 -3
- data/ext/ca_sweep_engine.h +17 -9
- data/ext/ca_transform_common.c +3 -8
- data/ext/ca_triop_dispatch.h +20 -32
- data/ext/caframe_csv_reader.c +11 -11
- data/ext/carray.h +300 -1011
- data/ext/carray_access.c +234 -180
- data/ext/carray_address_basis.c +33 -38
- data/ext/carray_attribute.c +81 -104
- data/ext/carray_bincount.c +12 -14
- data/ext/carray_broadcast.c +30 -26
- data/ext/carray_call_cfunc.c +169 -277
- data/ext/carray_call_cfunc.h +36 -28
- data/ext/carray_cast.c +912 -346
- data/ext/carray_cast_func.rb +31 -3
- data/ext/carray_class.c +6 -11
- data/ext/carray_conversion.c +43 -38
- data/ext/carray_copy.c +28 -26
- data/ext/carray_core.c +217 -126
- data/ext/carray_count.c +27 -15
- data/ext/carray_element.c +40 -25
- data/ext/carray_factorize.c +53 -52
- data/ext/carray_generate.c +26 -19
- data/ext/carray_histogram.c +8 -10
- data/ext/carray_hold.c +7 -9
- data/ext/carray_index_classifier.c +123 -228
- data/ext/carray_index_classifier.h +11 -10
- data/ext/carray_integer_total.c +523 -0
- data/ext/carray_internal.h +1274 -160
- data/ext/carray_key_windows.c +3 -3
- data/ext/carray_lazy.c +21 -36
- data/ext/carray_loop.c +19 -22
- data/ext/carray_mask.c +123 -145
- data/ext/carray_math_kernel.h +23 -47
- data/ext/carray_mathfunc.c +10 -3
- data/ext/carray_median_percentile.c +95 -94
- data/ext/carray_memory_view.c +42 -47
- data/ext/carray_operator.c +423 -122
- data/ext/carray_order.c +121 -85
- data/ext/carray_partition.c +13 -15
- data/ext/carray_random.c +47 -41
- data/ext/carray_round.c +9 -4
- data/ext/carray_scatter.c +54 -40
- data/ext/carray_segment.c +41 -45
- data/ext/carray_slab.c +64 -47
- data/ext/carray_slab.h +44 -33
- data/ext/carray_sort.c +32 -29
- data/ext/carray_sort_kernel.c +12 -10
- data/ext/carray_struct.c +38 -43
- data/ext/carray_test.c +47 -43
- data/ext/carray_time_text.c +24 -31
- data/ext/carray_undef.c +50 -7
- data/ext/carray_utils.c +258 -94
- data/ext/extconf.rb +24 -17
- data/ext/mk_call_cfunc.rb +19 -20
- data/ext/mk_pow5_table.rb +2 -1
- data/ext/mkkernel.rb +782 -461
- data/ext/ruby_carray.c +47 -42
- data/ext/version.h +7 -5
- data/lib/carray/attribute.rb +19 -18
- data/lib/carray/autoload_carray.rb +20 -15
- data/lib/carray/autoload_method_extension.rb +64 -57
- data/lib/carray/axis_group.rb +264 -180
- data/lib/carray/basics.rb +272 -48
- data/lib/carray/bincount_nd.rb +33 -16
- data/lib/carray/block_iterator.rb +123 -102
- data/lib/carray/boolean_reduce.rb +7 -4
- data/lib/carray/categorical.rb +63 -51
- data/lib/carray/categorical_iterator.rb +89 -67
- data/lib/carray/complex.rb +61 -41
- data/lib/carray/conditional.rb +49 -22
- data/lib/carray/const_string.rb +54 -62
- data/lib/carray/core_extensions.rb +1 -1
- data/lib/carray/distance_limit.rb +7 -5
- data/lib/carray/factories.rb +269 -0
- data/lib/carray/fixlen_string.rb +25 -24
- data/lib/carray/frame/column_verbs.rb +20 -8
- data/lib/carray/frame/concat.rb +3 -3
- data/lib/carray/frame/convert.rb +2 -1
- data/lib/carray/frame/csv_parser.rb +7 -1
- data/lib/carray/frame/frame.rb +35 -25
- data/lib/carray/frame/group.rb +183 -150
- data/lib/carray/frame/io.rb +26 -7
- data/lib/carray/frame/join.rb +37 -12
- data/lib/carray/frame/records.rb +1 -1
- data/lib/carray/frame/reshape.rb +3 -3
- data/lib/carray/frame/sort.rb +10 -8
- data/lib/carray/frame/verbs.rb +148 -118
- data/lib/carray/frame/windows.rb +232 -21
- data/lib/carray/frame.rb +1 -2
- data/lib/carray/fuse_source.rb +24 -21
- data/lib/carray/fusion.rb +30 -30
- data/lib/carray/histogram.rb +35 -16
- data/lib/carray/inspect.rb +7 -7
- data/lib/carray/iterator.rb +97 -24
- data/lib/carray/key_windows.rb +83 -57
- data/lib/carray/lazy.rb +196 -94
- data/lib/carray/limits.rb +80 -0
- data/lib/carray/mask_gap_fill.rb +21 -16
- data/lib/carray/math.rb +87 -50
- data/lib/carray/meld_reduce.rb +30 -8
- data/lib/carray/methods/align_addr.rb +29 -17
- data/lib/carray/methods/bin.rb +5 -1
- data/lib/carray/methods/bincount.rb +4 -2
- data/lib/carray/methods/bit_string.rb +19 -31
- data/lib/carray/methods/broadcast.rb +8 -3
- data/lib/carray/methods/choose.rb +5 -5
- data/lib/carray/methods/composition.rb +72 -71
- data/lib/carray/methods/{index.rb → coordinate.rb} +13 -13
- data/lib/carray/methods/discovery_along.rb +3 -3
- data/lib/carray/methods/gather_nd.rb +106 -106
- data/lib/carray/methods/insert_block.rb +2 -2
- data/lib/carray/methods/is_between.rb +6 -4
- data/lib/carray/methods/is_in.rb +165 -145
- data/lib/carray/methods/join.rb +2 -1
- data/lib/carray/methods/lag.rb +6 -2
- data/lib/carray/methods/locate_addr.rb +150 -138
- data/lib/carray/methods/mask_duplicates.rb +1 -1
- data/lib/carray/methods/meshgrid.rb +28 -16
- data/lib/carray/methods/mode.rb +67 -67
- data/lib/carray/methods/nunique.rb +9 -7
- data/lib/carray/methods/repeat.rb +12 -12
- data/lib/carray/methods/resize.rb +1 -1
- data/lib/carray/methods/snap.rb +24 -20
- data/lib/carray/methods/string_format.rb +2 -2
- data/lib/carray/methods/unique.rb +4 -2
- data/lib/carray/methods/value_counts.rb +1 -1
- data/lib/carray/mkmf.rb +25 -28
- data/lib/carray/percentile_arguments.rb +82 -0
- data/lib/carray/record_order.rb +18 -17
- data/lib/carray/rng.rb +1 -0
- data/lib/carray/runtime.rb +190 -22
- data/lib/carray/segment_iterator.rb +251 -129
- data/lib/carray/serialize.rb +618 -571
- data/lib/carray/slab_iterator.rb +114 -114
- data/lib/carray/stack.rb +11 -12
- data/lib/carray/string.rb +16 -22
- data/lib/carray/string_operation_extension.rb +76 -52
- data/lib/carray/struct.rb +122 -164
- data/lib/carray/struct_builder.rb +243 -72
- data/lib/carray/time.rb +496 -342
- data/lib/carray/window_iterator.rb +191 -150
- data/lib/carray.rb +6 -11
- data/yard-stubs/ca_obj_array.rb +20 -135
- data/yard-stubs/ca_obj_bitarray.rb +1 -8
- data/yard-stubs/ca_obj_bitfield.rb +4 -3
- data/yard-stubs/ca_obj_byte_swap.rb +21 -7
- data/yard-stubs/ca_obj_fake.rb +3 -1
- data/yard-stubs/ca_obj_farray.rb +1 -1
- data/yard-stubs/ca_obj_field.rb +8 -6
- data/yard-stubs/ca_obj_refer.rb +7 -5
- data/yard-stubs/ca_obj_roll.rb +7 -6
- data/yard-stubs/ca_obj_shift.rb +2 -3
- data/yard-stubs/ca_obj_stride.rb +5 -7
- data/yard-stubs/ca_obj_tile.rb +1 -1
- data/yard-stubs/ca_obj_time.rb +43 -0
- data/yard-stubs/ca_obj_transpose.rb +1 -1
- data/yard-stubs/ca_obj_window.rb +26 -15
- data/yard-stubs/carray_access.rb +51 -4
- data/yard-stubs/carray_attribute.rb +26 -38
- data/yard-stubs/carray_cast.rb +118 -165
- data/yard-stubs/carray_class.rb +3 -4
- data/yard-stubs/carray_conversion.rb +6 -7
- data/yard-stubs/carray_copy.rb +2 -1
- data/yard-stubs/carray_count.rb +5 -3
- data/yard-stubs/carray_element.rb +4 -3
- data/yard-stubs/carray_limits.rb +100 -0
- data/yard-stubs/carray_loop.rb +0 -20
- data/yard-stubs/carray_mask.rb +59 -41
- data/yard-stubs/carray_math.rb +157 -100
- data/yard-stubs/carray_mathfunc.rb +415 -3
- data/yard-stubs/carray_median_percentile.rb +29 -11
- data/yard-stubs/carray_memory_view.rb +2 -2
- data/yard-stubs/carray_order.rb +67 -34
- data/yard-stubs/carray_random.rb +6 -6
- data/yard-stubs/carray_reduce.rb +353 -0
- data/yard-stubs/carray_rng.rb +92 -0
- data/yard-stubs/carray_scatter.rb +10 -2
- data/yard-stubs/carray_slab.rb +7 -4
- data/yard-stubs/carray_sort.rb +7 -6
- data/yard-stubs/carray_undef.rb +44 -5
- data/yard-stubs/ruby_carray.rb +75 -40
- metadata +62 -24
- data/CHANGELOG.v1.md +0 -126
- data/ext/carray_build_flags.h +0 -3
- data/ext/carray_config.h +0 -28
- data/ext/carray_data_type.c +0 -90
- data/ext/carray_kernels_bincmp.c +0 -6457
- data/ext/carray_kernels_binop.c +0 -31534
- data/ext/carray_kernels_init.c +0 -1734
- data/ext/carray_kernels_moncmp.c +0 -2104
- data/ext/carray_kernels_monop.c +0 -25337
- data/ext/carray_kernels_reduce_aggregate.c +0 -27545
- data/ext/carray_kernels_reduce_boolean.c +0 -1924
- data/ext/carray_kernels_reduce_cumulative.c +0 -11646
- data/ext/carray_kernels_reduce_extreme.c +0 -21631
- data/ext/carray_kernels_reduce_variance.c +0 -5981
- data/ext/carray_kernels_scan.c +0 -4302
- data/ext/carray_kernels_search.c +0 -37776
- data/ext/carray_kernels_sort.c +0 -10814
- data/ext/carray_kernels_triop.c +0 -1864
- data/lib/carray/construct.rb +0 -360
- data/lib/carray/data_type_extension.rb +0 -262
- data/lib/carray/data_type_limits.rb +0 -91
data/yard-stubs/carray_cast.rb
CHANGED
|
@@ -23,61 +23,57 @@
|
|
|
23
23
|
# `Enumerator::ArithmeticSequence` already carries its own step, so
|
|
24
24
|
# `CA_INT32((0..6).step(2))` needs no second argument.
|
|
25
25
|
#
|
|
26
|
+
# `nil` is refused with `TypeError`: it is no data. An empty array is
|
|
27
|
+
# `CA_INT32([])`.
|
|
28
|
+
#
|
|
29
|
+
# A String is read as words separated by spaces or `,`, with `;` ending a
|
|
30
|
+
# row and `_` for an UNDEF cell: `CA_INT32("1 2; 3 4")` is
|
|
31
|
+
# `[[1, 2], [3, 4]]`. Each word is read as a cell of the type reads text:
|
|
32
|
+
# a decimal number, or for `CA_BOOLEAN` one of `1` / `0` / `true` /
|
|
33
|
+
# `false` (`CA_BOOLEAN("1 0 1")` is `[true, false, true]`). A word that
|
|
34
|
+
# does not read raises `ArgumentError`. `CA_OBJECT` and `CA_FIXLEN` keep
|
|
35
|
+
# the String as one value.
|
|
36
|
+
#
|
|
26
37
|
# `CA_FIXLEN` takes `bytes:` instead of a step; see {#CA_FIXLEN}.
|
|
27
38
|
module Kernel
|
|
28
39
|
# @!group CArray cast shorthands
|
|
29
40
|
|
|
30
41
|
# Coerces `obj` into a `:boolean` CArray. @return [CArray]
|
|
31
|
-
def CA_BOOLEAN(obj
|
|
42
|
+
def CA_BOOLEAN(obj, step = nil); end
|
|
32
43
|
# Coerces `obj` into an `:int8` CArray. @return [CArray]
|
|
33
|
-
def CA_INT8(obj
|
|
44
|
+
def CA_INT8(obj, step = nil); end
|
|
34
45
|
# Coerces `obj` into a `:uint8` CArray. @return [CArray]
|
|
35
|
-
def CA_UINT8(obj
|
|
46
|
+
def CA_UINT8(obj, step = nil); end
|
|
36
47
|
# Coerces `obj` into an `:int16` CArray. @return [CArray]
|
|
37
|
-
def CA_INT16(obj
|
|
48
|
+
def CA_INT16(obj, step = nil); end
|
|
38
49
|
# Coerces `obj` into a `:uint16` CArray. @return [CArray]
|
|
39
|
-
def CA_UINT16(obj
|
|
50
|
+
def CA_UINT16(obj, step = nil); end
|
|
40
51
|
# Coerces `obj` into an `:int32` CArray. @return [CArray]
|
|
41
|
-
def CA_INT32(obj
|
|
52
|
+
def CA_INT32(obj, step = nil); end
|
|
42
53
|
# Coerces `obj` into a `:uint32` CArray. @return [CArray]
|
|
43
|
-
def CA_UINT32(obj
|
|
54
|
+
def CA_UINT32(obj, step = nil); end
|
|
44
55
|
# Coerces `obj` into an `:int64` CArray. @return [CArray]
|
|
45
|
-
def CA_INT64(obj
|
|
56
|
+
def CA_INT64(obj, step = nil); end
|
|
46
57
|
# Coerces `obj` into a `:uint64` CArray. @return [CArray]
|
|
47
|
-
def CA_UINT64(obj
|
|
58
|
+
def CA_UINT64(obj, step = nil); end
|
|
48
59
|
# Coerces `obj` into a `:float32` CArray. @return [CArray]
|
|
49
|
-
def CA_FLOAT32(obj
|
|
60
|
+
def CA_FLOAT32(obj, step = nil); end
|
|
50
61
|
# Coerces `obj` into a `:float64` CArray. @return [CArray]
|
|
51
|
-
def CA_FLOAT64(obj
|
|
62
|
+
def CA_FLOAT64(obj, step = nil); end
|
|
52
63
|
# Coerces `obj` into a `:cmplx64` CArray. @return [CArray]
|
|
53
|
-
def CA_CMPLX64(obj
|
|
64
|
+
def CA_CMPLX64(obj, step = nil); end
|
|
54
65
|
# Coerces `obj` into a `:cmplx128` CArray. @return [CArray]
|
|
55
|
-
def CA_CMPLX128(obj
|
|
66
|
+
def CA_CMPLX128(obj, step = nil); end
|
|
56
67
|
# Coerces `obj` into an `:object` CArray. @return [CArray]
|
|
57
|
-
def CA_OBJECT(obj
|
|
68
|
+
def CA_OBJECT(obj, step = nil); end
|
|
58
69
|
# Coerces `obj` into a `CA_SIZE` (platform native size) CArray.
|
|
59
70
|
# @return [CArray]
|
|
60
|
-
def CA_SIZE(obj
|
|
71
|
+
def CA_SIZE(obj, step = nil); end
|
|
61
72
|
# Coerces `obj` into a `:fixlen` CArray. `bytes` defaults to the
|
|
62
73
|
# longest top-level element of an `Array`, or `0` for `nil`.
|
|
63
74
|
# @return [CArray]
|
|
64
75
|
def CA_FIXLEN(obj, bytes: nil); end
|
|
65
76
|
|
|
66
|
-
# Alias of {#CA_UINT8}. @return [CArray]
|
|
67
|
-
def CA_BYTE(obj = nil, step = nil); end
|
|
68
|
-
# Alias of {#CA_INT16}. @return [CArray]
|
|
69
|
-
def CA_SHORT(obj = nil, step = nil); end
|
|
70
|
-
# Alias of {#CA_INT32}. @return [CArray]
|
|
71
|
-
def CA_INT(obj = nil, step = nil); end
|
|
72
|
-
# Alias of {#CA_FLOAT32}. @return [CArray]
|
|
73
|
-
def CA_FLOAT(obj = nil, step = nil); end
|
|
74
|
-
# Alias of {#CA_FLOAT64}. @return [CArray]
|
|
75
|
-
def CA_DOUBLE(obj = nil, step = nil); end
|
|
76
|
-
# Alias of {#CA_CMPLX64}. @return [CArray]
|
|
77
|
-
def CA_COMPLEX(obj = nil, step = nil); end
|
|
78
|
-
# Alias of {#CA_CMPLX128}. @return [CArray]
|
|
79
|
-
def CA_DCOMPLEX(obj = nil, step = nil); end
|
|
80
|
-
|
|
81
77
|
# @!endgroup
|
|
82
78
|
end
|
|
83
79
|
|
|
@@ -105,12 +101,21 @@ class CArray
|
|
|
105
101
|
# float types. A cell that is not a String goes through `Integer()` /
|
|
106
102
|
# `Float()` as before.
|
|
107
103
|
#
|
|
104
|
+
# When `data_type` is `:boolean`, a String cell is read by its words:
|
|
105
|
+
# `1` / `0` / `true` / `false` in any case, with spaces around them
|
|
106
|
+
# ignored. Any other text becomes UNDEF, as does a value that is not
|
|
107
|
+
# `true`, `false`, `0` or `1`.
|
|
108
|
+
#
|
|
108
109
|
# From a float or complex array to an integer type, a NaN cell (in
|
|
109
110
|
# either part) becomes UNDEF. A finite value outside the integer type
|
|
110
111
|
# is converted as the machine's C converts it.
|
|
111
|
-
# @param data_type [Symbol,
|
|
112
|
+
# @param data_type [Symbol, Class, String] target element type;
|
|
113
|
+
# a data class (from `CArray.struct`) reads fixlen cells of its size as records (a
|
|
114
|
+
# {CARecord}), makes records from an object array of its instances,
|
|
115
|
+
# and refuses other cells.
|
|
112
116
|
# @param bytes [Integer, nil] element width in bytes, required for
|
|
113
|
-
# `:fixlen
|
|
117
|
+
# `:fixlen`; another type refuses a
|
|
118
|
+
# width other than its own.
|
|
114
119
|
# @return [CArray]
|
|
115
120
|
def to_type(data_type, bytes: nil); end
|
|
116
121
|
|
|
@@ -177,28 +182,6 @@ class CArray
|
|
|
177
182
|
# @return [CArray]
|
|
178
183
|
def fixlen(bytes: nil); end
|
|
179
184
|
|
|
180
|
-
# @overload byte
|
|
181
|
-
# Alias of {#uint8}. @return [CArray]
|
|
182
|
-
def byte; end
|
|
183
|
-
# @overload short
|
|
184
|
-
# Alias of {#int16}. @return [CArray]
|
|
185
|
-
def short; end
|
|
186
|
-
# @overload int
|
|
187
|
-
# Alias of {#int32}. @return [CArray]
|
|
188
|
-
def int; end
|
|
189
|
-
# @overload float
|
|
190
|
-
# Alias of {#float32}. @return [CArray]
|
|
191
|
-
def float; end
|
|
192
|
-
# @overload double
|
|
193
|
-
# Alias of {#float64}. @return [CArray]
|
|
194
|
-
def double; end
|
|
195
|
-
# @overload complex
|
|
196
|
-
# Alias of {#cmplx64}. @return [CArray]
|
|
197
|
-
def complex; end
|
|
198
|
-
# @overload dcomplex
|
|
199
|
-
# Alias of {#cmplx128}. @return [CArray]
|
|
200
|
-
def dcomplex; end
|
|
201
|
-
|
|
202
185
|
# -- as_type: reinterpreting view (no copy) ---------------------------
|
|
203
186
|
|
|
204
187
|
# @overload as_type(data_type, bytes: nil)
|
|
@@ -213,7 +196,8 @@ class CArray
|
|
|
213
196
|
# Note: for an `:object` source the on-the-fly cast to a numeric type
|
|
214
197
|
# uses the lenient path and does NOT mask parse failures — a
|
|
215
198
|
# non-numeric string reads as `0.0` (float) and raises for an integer
|
|
216
|
-
# target
|
|
199
|
+
# or boolean target (a boolean cell reads `1` / `0` / `true` / `false`
|
|
200
|
+
# as {#to_type} does). Use {#to_type} instead for parse-with-mask (an unparseable
|
|
217
201
|
# cell becomes UNDEF). The `CA_<TYPE>(obj)` construction shorthands
|
|
218
202
|
# take this same non-masking path.
|
|
219
203
|
# From a float or complex array to an integer type, reading a NaN cell
|
|
@@ -225,9 +209,13 @@ class CArray
|
|
|
225
209
|
# descriptor instead of the string), and no view decodes a surface. Take
|
|
226
210
|
# the values with {#to_type}, or the storage with `face.parent.as_type`.
|
|
227
211
|
# A Numeric Face, whose surface *is* its storage, adapts as usual.
|
|
228
|
-
# @param data_type [Symbol,
|
|
212
|
+
# @param data_type [Symbol, Class, String] target element type;
|
|
213
|
+
# a data class (from `CArray.struct`) reads fixlen cells of its size as records (a
|
|
214
|
+
# {CARecord}) and refuses other cells, and a Face whose storage
|
|
215
|
+
# is not its values (a const string).
|
|
229
216
|
# @param bytes [Integer, nil] element width in bytes, required for
|
|
230
|
-
# `:fixlen
|
|
217
|
+
# `:fixlen`; another type refuses a
|
|
218
|
+
# width other than its own.
|
|
231
219
|
# @return [CAMonOp, CAFake]
|
|
232
220
|
# @raise [TypeError] when `self` is a Face and the request would read its
|
|
233
221
|
# storage under another type.
|
|
@@ -236,72 +224,62 @@ class CArray
|
|
|
236
224
|
def as_type(data_type, bytes: nil); end
|
|
237
225
|
|
|
238
226
|
# @overload as_boolean
|
|
239
|
-
# Returns a {
|
|
227
|
+
# Returns a {CAMonOp} `:boolean` view of `self`. Short-hand of
|
|
240
228
|
# `as_type(:boolean)`.
|
|
241
|
-
# @return [
|
|
229
|
+
# @return [CAMonOp]
|
|
242
230
|
def as_boolean; end
|
|
243
231
|
# @overload as_int8
|
|
244
|
-
# Returns a {
|
|
245
|
-
# @return [
|
|
232
|
+
# Returns a {CAMonOp} `:int8` view of `self`. Short-hand of `as_type(:int8)`.
|
|
233
|
+
# @return [CAMonOp]
|
|
246
234
|
def as_int8; end
|
|
247
235
|
# @overload as_uint8
|
|
248
|
-
# Returns a {
|
|
249
|
-
# @return [
|
|
236
|
+
# Returns a {CAMonOp} `:uint8` view of `self`. Short-hand of `as_type(:uint8)`.
|
|
237
|
+
# @return [CAMonOp]
|
|
250
238
|
def as_uint8; end
|
|
251
239
|
# @overload as_int16
|
|
252
|
-
# Returns a {
|
|
253
|
-
# @return [
|
|
240
|
+
# Returns a {CAMonOp} `:int16` view of `self`. Short-hand of `as_type(:int16)`.
|
|
241
|
+
# @return [CAMonOp]
|
|
254
242
|
def as_int16; end
|
|
255
243
|
# @overload as_uint16
|
|
256
|
-
# Returns a {
|
|
257
|
-
# @return [
|
|
244
|
+
# Returns a {CAMonOp} `:uint16` view of `self`. Short-hand of `as_type(:uint16)`.
|
|
245
|
+
# @return [CAMonOp]
|
|
258
246
|
def as_uint16; end
|
|
259
247
|
# @overload as_int32
|
|
260
|
-
# Returns a {
|
|
261
|
-
# @return [
|
|
248
|
+
# Returns a {CAMonOp} `:int32` view of `self`. Short-hand of `as_type(:int32)`.
|
|
249
|
+
# @return [CAMonOp]
|
|
262
250
|
def as_int32; end
|
|
263
251
|
# @overload as_uint32
|
|
264
|
-
# Returns a {
|
|
265
|
-
# @return [
|
|
252
|
+
# Returns a {CAMonOp} `:uint32` view of `self`. Short-hand of `as_type(:uint32)`.
|
|
253
|
+
# @return [CAMonOp]
|
|
266
254
|
def as_uint32; end
|
|
267
255
|
# @overload as_int64
|
|
268
|
-
# Returns a {
|
|
269
|
-
# @return [
|
|
256
|
+
# Returns a {CAMonOp} `:int64` view of `self`. Short-hand of `as_type(:int64)`.
|
|
257
|
+
# @return [CAMonOp]
|
|
270
258
|
def as_int64; end
|
|
271
259
|
# @overload as_uint64
|
|
272
|
-
# Returns a {
|
|
273
|
-
# @return [
|
|
260
|
+
# Returns a {CAMonOp} `:uint64` view of `self`. Short-hand of `as_type(:uint64)`.
|
|
261
|
+
# @return [CAMonOp]
|
|
274
262
|
def as_uint64; end
|
|
275
263
|
# @overload as_float32
|
|
276
|
-
# Returns a {
|
|
264
|
+
# Returns a {CAMonOp} `:float32` view of `self`. Short-hand of
|
|
277
265
|
# `as_type(:float32)`.
|
|
278
|
-
# @return [
|
|
266
|
+
# @return [CAMonOp]
|
|
279
267
|
def as_float32; end
|
|
280
268
|
# @overload as_float64
|
|
281
|
-
# Returns a {
|
|
269
|
+
# Returns a {CAMonOp} `:float64` view of `self`. Short-hand of
|
|
282
270
|
# `as_type(:float64)`.
|
|
283
|
-
# @return [
|
|
271
|
+
# @return [CAMonOp]
|
|
284
272
|
def as_float64; end
|
|
285
|
-
# @overload as_float128
|
|
286
|
-
# Returns a {CAFake} `:float128` view of `self`. Short-hand of
|
|
287
|
-
# `as_type(:float128)`.
|
|
288
|
-
# @return [CAFake]
|
|
289
|
-
def as_float128; end
|
|
290
273
|
# @overload as_cmplx64
|
|
291
|
-
# Returns a {
|
|
274
|
+
# Returns a {CAMonOp} `:cmplx64` view of `self`. Short-hand of
|
|
292
275
|
# `as_type(:cmplx64)`.
|
|
293
|
-
# @return [
|
|
276
|
+
# @return [CAMonOp]
|
|
294
277
|
def as_cmplx64; end
|
|
295
278
|
# @overload as_cmplx128
|
|
296
|
-
# Returns a {
|
|
279
|
+
# Returns a {CAMonOp} `:cmplx128` view of `self`. Short-hand of
|
|
297
280
|
# `as_type(:cmplx128)`.
|
|
298
|
-
# @return [
|
|
281
|
+
# @return [CAMonOp]
|
|
299
282
|
def as_cmplx128; end
|
|
300
|
-
# @overload as_cmplx256
|
|
301
|
-
# Returns a {CAFake} `:cmplx256` view of `self`. Short-hand of
|
|
302
|
-
# `as_type(:cmplx256)`.
|
|
303
|
-
# @return [CAFake]
|
|
304
|
-
def as_cmplx256; end
|
|
305
283
|
# @overload as_object
|
|
306
284
|
# Returns a {CAFake} `:object` view of `self`. Short-hand of
|
|
307
285
|
# `as_type(:object)`.
|
|
@@ -314,53 +292,6 @@ class CArray
|
|
|
314
292
|
# @return [CAFake]
|
|
315
293
|
def as_fixlen(bytes: nil); end
|
|
316
294
|
|
|
317
|
-
# @overload as_byte
|
|
318
|
-
# Alias of {#as_uint8}. @return [CAFake]
|
|
319
|
-
def as_byte; end
|
|
320
|
-
# @overload as_short
|
|
321
|
-
# Alias of {#as_int16}. @return [CAFake]
|
|
322
|
-
def as_short; end
|
|
323
|
-
# @overload as_int
|
|
324
|
-
# Alias of {#as_int32}. @return [CAFake]
|
|
325
|
-
def as_int; end
|
|
326
|
-
# @overload as_float
|
|
327
|
-
# Alias of {#as_float32}. @return [CAFake]
|
|
328
|
-
def as_float; end
|
|
329
|
-
# @overload as_double
|
|
330
|
-
# Alias of {#as_float64}. @return [CAFake]
|
|
331
|
-
def as_double; end
|
|
332
|
-
# @overload as_complex
|
|
333
|
-
# Alias of {#as_cmplx64}. @return [CAFake]
|
|
334
|
-
def as_complex; end
|
|
335
|
-
# @overload as_dcomplex
|
|
336
|
-
# Alias of {#as_cmplx128}. @return [CAFake]
|
|
337
|
-
def as_dcomplex; end
|
|
338
|
-
|
|
339
|
-
# -- clip-then-cast ---------------------------------------------------
|
|
340
|
-
|
|
341
|
-
# @!method clip_int8
|
|
342
|
-
# Returns an `:int8` copy of `self` with values clamped to the
|
|
343
|
-
# `:int8` range (-128..127) before casting. @return [CArray]
|
|
344
|
-
# @!method clip_uint8
|
|
345
|
-
# Returns a `:uint8` copy clamped to 0..255. @return [CArray]
|
|
346
|
-
# @!method clip_int16
|
|
347
|
-
# Returns an `:int16` copy clamped to -32768..32767.
|
|
348
|
-
# @return [CArray]
|
|
349
|
-
# @!method clip_uint16
|
|
350
|
-
# Returns a `:uint16` copy clamped to 0..65535. @return [CArray]
|
|
351
|
-
# @!method clip_int32
|
|
352
|
-
# Returns an `:int32` copy clamped to the `:int32` range.
|
|
353
|
-
# @return [CArray]
|
|
354
|
-
# @!method clip_uint32
|
|
355
|
-
# Returns a `:uint32` copy clamped to 0..4294967295.
|
|
356
|
-
# @return [CArray]
|
|
357
|
-
# @!method clip_int64
|
|
358
|
-
# Returns an `:int64` copy clamped to the `:int64` range.
|
|
359
|
-
# @return [CArray]
|
|
360
|
-
# @!method clip_uint64
|
|
361
|
-
# Returns a `:uint64` copy clamped to the `:uint64` range.
|
|
362
|
-
# @return [CArray]
|
|
363
|
-
|
|
364
295
|
# -- coercion ---------------------------------------------------------
|
|
365
296
|
|
|
366
297
|
# @overload cast_with(other)
|
|
@@ -387,8 +318,7 @@ class CArray
|
|
|
387
318
|
#
|
|
388
319
|
# The name is a statement of intent, not a property of the result: you are
|
|
389
320
|
# declaring that writes are coming, so only sources that can actually take
|
|
390
|
-
# a write are accepted — a writable CArray, `
|
|
391
|
-
# an object whose `#to_ca` honours `writable: true`, or a writable
|
|
321
|
+
# a write are accepted — a writable CArray, an object whose `#to_ca` honours `writable: true`, or a writable
|
|
392
322
|
# MemoryView producer (wrapped zero-copy). Anything that would have to be
|
|
393
323
|
# *copied* to become a CArray is refused up front, because a copy would
|
|
394
324
|
# swallow the writes silently. That is the whole difference from
|
|
@@ -406,14 +336,16 @@ class CArray
|
|
|
406
336
|
# through to the source. A Face is refused for that same reason the
|
|
407
337
|
# other way round: the writes would land on the storage its surface
|
|
408
338
|
# hides. Wrap `face.parent` when that is what you mean.
|
|
409
|
-
# @param other [CArray,
|
|
410
|
-
# @param data_type [Symbol,
|
|
411
|
-
# `nil` keeps the source type
|
|
339
|
+
# @param other [CArray, Object] source to wrap.
|
|
340
|
+
# @param data_type [Symbol, Class, nil] target element type;
|
|
341
|
+
# `nil` keeps the source type; a data class (from `CArray.struct`) reads fixlen cells of its size as records (a
|
|
342
|
+
# {CARecord}) and refuses other cells, and a Face whose storage
|
|
343
|
+
# is not its values (a const string).
|
|
412
344
|
# @return [CArray]
|
|
413
345
|
# @raise [RuntimeError] when `other` is read-only, its MemoryView is
|
|
414
346
|
# read-only, or its `to_ca` refuses `writable: true`.
|
|
415
|
-
# @raise [TypeError] when `other` cannot be wrapped as a
|
|
416
|
-
# `other#to_ca` returns something that is not a CArray.
|
|
347
|
+
# @raise [TypeError] when `other` is `nil` or cannot be wrapped as a
|
|
348
|
+
# CArray, or `other#to_ca` returns something that is not a CArray.
|
|
417
349
|
# @raise [ArgumentError] when `other#to_ca` does not accept `writable:`.
|
|
418
350
|
# @raise [TypeError] when `other` is a Face and `data_type` differs from
|
|
419
351
|
# its surface type.
|
|
@@ -427,7 +359,7 @@ class CArray
|
|
|
427
359
|
# declaring that nothing will be written back, which frees this call to
|
|
428
360
|
# convert as widely as it can — a conversion that copies is fine when
|
|
429
361
|
# nobody writes to it. So on top of everything {.wrap_writable} takes
|
|
430
|
-
# (a CArray,
|
|
362
|
+
# (a CArray, an object responding to `#to_ca`, a MemoryView
|
|
431
363
|
# producer) this also accepts an Array (via `to_ca`) and a Numeric /
|
|
432
364
|
# String / arbitrary object, which become a one-element CScalar. It calls
|
|
433
365
|
# `to_ca` with no arguments, so a copy is welcome here.
|
|
@@ -439,7 +371,8 @@ class CArray
|
|
|
439
371
|
#
|
|
440
372
|
# Two conversions are worth knowing before you rely on them: with a
|
|
441
373
|
# numeric `data_type` a String is reinterpreted as **raw bytes** (a copy),
|
|
442
|
-
# not parsed, so `"abcd"` with `:uint8` gives four elements
|
|
374
|
+
# not parsed, so `"abcd"` with `:uint8` gives four elements (a length
|
|
375
|
+
# that is no whole number of cells is refused); and with
|
|
443
376
|
# `data_type` omitted, anything that is not already CArray-shaped lands on
|
|
444
377
|
# `:object` rather than a guessed numeric type, so pass `data_type`
|
|
445
378
|
# explicitly when the value is headed for a numeric kernel.
|
|
@@ -447,12 +380,16 @@ class CArray
|
|
|
447
380
|
# nothing here promises a view: its surface values for `:object`, and its
|
|
448
381
|
# own `#to_numeric` for a numeric type. Reading its storage instead is
|
|
449
382
|
# `face.parent`.
|
|
450
|
-
# @param other [CArray, Numeric, String, Array,
|
|
451
|
-
#
|
|
452
|
-
# @param data_type [Symbol, Integer, Class, nil] target element type;
|
|
383
|
+
# @param other [CArray, Numeric, String, Array, Object] source to wrap.
|
|
384
|
+
# @param data_type [Symbol, Class, nil] target element type;
|
|
453
385
|
# `nil` keeps the source type for a CArray-shaped source, and is
|
|
454
|
-
# `:object` otherwise.
|
|
386
|
+
# `:object` otherwise; a data class (from `CArray.struct`) reads fixlen cells of its size as records (a
|
|
387
|
+
# {CARecord}) and refuses other cells, and a Face whose storage
|
|
388
|
+
# is not its values (a const string).
|
|
455
389
|
# @return [CArray]
|
|
390
|
+
# @raise [TypeError] when `other` is `nil` (an empty array is `[]`).
|
|
391
|
+
# @raise [ArgumentError] when `other` is a String whose length is no
|
|
392
|
+
# whole number of cells of a numeric `data_type`.
|
|
456
393
|
# @raise [TypeError] when `other` is a Face asked for a numeric type and
|
|
457
394
|
# it declares no `#to_numeric`.
|
|
458
395
|
def self.wrap_readonly(other, data_type = nil); end
|
|
@@ -480,21 +417,31 @@ class CArray
|
|
|
480
417
|
# - Integer / Float / Complex / true / false / nil / Object -> *value*,
|
|
481
418
|
# data_type inferred (3 -> `:int64`, 3.14 -> `:float64`,
|
|
482
419
|
# 1+2i -> `:cmplx128`, ...)
|
|
420
|
+
# - Ruby Array -> no data type: beside an object array it is one more
|
|
421
|
+
# object value, otherwise it is refused (make it a CArray of the type
|
|
422
|
+
# you mean)
|
|
483
423
|
#
|
|
484
424
|
# The arrays and data_type representations promote together. A
|
|
485
425
|
# scalar (a value, or a CScalar) then joins their type the way it
|
|
486
426
|
# does beside an operator: one of the same kind takes that type
|
|
487
427
|
# (`result_type(float32_array, 0.1)` is `:float32`, as
|
|
488
428
|
# `float32_array + 0.1` is), one of another kind promotes
|
|
489
|
-
# (`result_type(int32_array, 1.5)` is `:float64`),
|
|
490
|
-
#
|
|
429
|
+
# (`result_type(int32_array, 1.5)` is `:float64`), a Complex beside a
|
|
430
|
+
# float32 array keeps the width (`:cmplx64`), and an Integer
|
|
431
|
+
# that does not fit an integer type takes a type that holds it and the
|
|
432
|
+
# array's values (`:int64`, or `:object` where no integer type does,
|
|
433
|
+
# as for `2**64`). Beside a boolean array an Integer meets the numbers
|
|
434
|
+
# 0 and 1 as an operator reads them: `:int64`, or `:object` past the
|
|
435
|
+
# int64 range. With no array or
|
|
491
436
|
# data_type representation, every argument promotes by its own type.
|
|
492
437
|
#
|
|
493
438
|
# This is the type an operator computes in: `int32_array + float32_array`
|
|
494
439
|
# is `:float32`. Arrays joined value for value ({CArray.stack},
|
|
495
|
-
# {CArray.meld}, {CArray.concatenate})
|
|
496
|
-
#
|
|
497
|
-
#
|
|
440
|
+
# {CArray.meld}, {CArray.concatenate}) refuse that pair through
|
|
441
|
+
# {.promote_list}, since `float32` does not hold every `int32` exactly,
|
|
442
|
+
# and ask for `data_type:`. They join an `int64` or `uint64` array with
|
|
443
|
+
# a `float64` or `cmplx128` one in that type while its integers are
|
|
444
|
+
# within 2**53, and refuse the list when one is past it.
|
|
498
445
|
#
|
|
499
446
|
# Integer args are interpreted as *values*, not as data_type codes:
|
|
500
447
|
# `result_type(8)` returns `:int64` because the value 8 is an Integer,
|
|
@@ -503,6 +450,7 @@ class CArray
|
|
|
503
450
|
# @param args [Array<CArray, Symbol, String, Class, Object>] operands.
|
|
504
451
|
# @return [Symbol]
|
|
505
452
|
# @raise [ArgumentError] when called with no arguments.
|
|
453
|
+
# @raise [TypeError] when a Ruby Array is given beside no object array.
|
|
506
454
|
# @raise [CArray::DataTypeError] when two inputs are mutually incompatible
|
|
507
455
|
# (e.g. `:object` with `:fixlen`).
|
|
508
456
|
# @example
|
|
@@ -523,12 +471,15 @@ class CArray
|
|
|
523
471
|
# elements passes through (CAStack lifts it), unless the class is not
|
|
524
472
|
# portable (CAConstString) or the elements disagree on state
|
|
525
473
|
# (CATime with different units); a list of primitives is
|
|
526
|
-
# promoted via {.result_type} + {.wrap_readonly}
|
|
527
|
-
#
|
|
528
|
-
#
|
|
529
|
-
#
|
|
530
|
-
#
|
|
531
|
-
# or
|
|
474
|
+
# promoted via {.result_type} + {.wrap_readonly}; a mix of Face and
|
|
475
|
+
# non-Face, or heterogeneous Face classes, is rejected. The arrays are
|
|
476
|
+
# joined value for value, so a pair whose common type would change
|
|
477
|
+
# some of their values is refused: signed with unsigned integers
|
|
478
|
+
# (`uint8` with `int8` meet in `uint8`, where -1 reads as 255) and an
|
|
479
|
+
# integer of 32 bits or more with `float32` (which holds integers only
|
|
480
|
+
# up to 2**24). Give `data_type:` to join them; the message names the
|
|
481
|
+
# type that holds both (`int16`, `:object` for a 64-bit pair,
|
|
482
|
+
# `float64`).
|
|
532
483
|
#
|
|
533
484
|
# With an explicit primitive `data_type`: all-primitive elements are
|
|
534
485
|
# wrapped read-only to the requested type; any Face element is
|
|
@@ -538,7 +489,9 @@ class CArray
|
|
|
538
489
|
# @param data_type [Symbol, nil] target element type, or `nil` to
|
|
539
490
|
# auto-detect.
|
|
540
491
|
# @return [Array<CArray>]
|
|
541
|
-
# @raise [ArgumentError] on an empty list or
|
|
492
|
+
# @raise [ArgumentError] on an empty list or a Face reject case.
|
|
493
|
+
# @raise [CArray::DataTypeError] when the common type would change
|
|
494
|
+
# some values and no `data_type:` is given.
|
|
542
495
|
def self.promote_list(list, data_type: nil); end
|
|
543
496
|
|
|
544
497
|
# @!endgroup
|
data/yard-stubs/carray_class.rb
CHANGED
|
@@ -7,10 +7,9 @@ class CArray
|
|
|
7
7
|
# @!group Platform inquiries
|
|
8
8
|
|
|
9
9
|
# @overload endian
|
|
10
|
-
# Returns the host byte order
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
# @return [Integer]
|
|
10
|
+
# Returns the host byte order, `:little` or `:big`.
|
|
11
|
+
# {.big_endian?} / {.little_endian?} ask the same as a predicate.
|
|
12
|
+
# @return [Symbol]
|
|
14
13
|
def endian; end
|
|
15
14
|
|
|
16
15
|
# @overload big_endian?
|
|
@@ -27,7 +27,7 @@ class CArray
|
|
|
27
27
|
#
|
|
28
28
|
# Masked cells skip the block; if the block returns
|
|
29
29
|
# `CArray::UNDEF`, the corresponding output cell is masked.
|
|
30
|
-
# @param data_type [Symbol,
|
|
30
|
+
# @param data_type [Symbol, String, nil]
|
|
31
31
|
# @param bytes [Integer, nil] element byte size for `:fixlen`.
|
|
32
32
|
# @yieldparam elem [Object] one element of `self`.
|
|
33
33
|
# @yieldreturn [Object] value to store in the result.
|
|
@@ -62,12 +62,11 @@ class CArray
|
|
|
62
62
|
def dump_binary(io = nil); end
|
|
63
63
|
|
|
64
64
|
# @overload to_s
|
|
65
|
-
#
|
|
66
|
-
#
|
|
67
|
-
#
|
|
68
|
-
# `
|
|
69
|
-
#
|
|
70
|
-
# message. Use `inspect` for a readable form.
|
|
65
|
+
# Returns the same text as `inspect`. Ruby uses `to_s` where it puts
|
|
66
|
+
# an object into text (string interpolation, `puts`, error messages),
|
|
67
|
+
# so those show the readable form. Writing an array to an IO
|
|
68
|
+
# (`io.write(a)`, `File.write(path, a)`) therefore writes this text;
|
|
69
|
+
# for the element bytes, use `dump_binary`.
|
|
71
70
|
# @return [String]
|
|
72
71
|
def to_s; end
|
|
73
72
|
|
data/yard-stubs/carray_copy.rb
CHANGED
|
@@ -64,7 +64,8 @@ class CArray
|
|
|
64
64
|
# @param data_type [Symbol] target element type
|
|
65
65
|
# (e.g. `:int32`, `:float64`, `:fixlen`).
|
|
66
66
|
# @param bytes [Integer] element byte size; required for
|
|
67
|
-
# `:fixlen` (1 or more)
|
|
67
|
+
# `:fixlen` (1 or more); another type refuses a width
|
|
68
|
+
# other than its own.
|
|
68
69
|
# @return [CArray]
|
|
69
70
|
# @overload template { value }
|
|
70
71
|
# With a 0-arity block, fills every element of the result with
|
data/yard-stubs/carray_count.rb
CHANGED
|
@@ -7,7 +7,7 @@ class CArray
|
|
|
7
7
|
|
|
8
8
|
# @overload count(axis: nil)
|
|
9
9
|
# With no value argument, returns the number of present (not-masked)
|
|
10
|
-
# cells — the arity-0
|
|
10
|
+
# cells — the arity-0 case of dispatch by arity, answering "how
|
|
11
11
|
# many are there". Forwards to {#count_not_masked} (which stays as
|
|
12
12
|
# an explicit, self-documenting named method).
|
|
13
13
|
#
|
|
@@ -20,7 +20,7 @@ class CArray
|
|
|
20
20
|
# Returns the number of cells of `self` that equal `v`, with
|
|
21
21
|
# mask-aware reduction along `axis`.
|
|
22
22
|
#
|
|
23
|
-
# `count`
|
|
23
|
+
# `count` dispatches by arity (like Ruby's
|
|
24
24
|
# `Array#count`): no argument counts present cells, `count(UNDEF)`
|
|
25
25
|
# counts masked cells, and `count(v)` counts cells equal to `v`.
|
|
26
26
|
# Mask-cardinality and value-match are distinct concepts, so the
|
|
@@ -38,7 +38,9 @@ class CArray
|
|
|
38
38
|
# vocabulary, not a value).
|
|
39
39
|
# - `v` is `nil`, a String, a Symbol or another value that is not a
|
|
40
40
|
# number, on an array that is not `:object` or `:fixlen`: `0`. It
|
|
41
|
-
# is no value of such an array, so no cell equals it.
|
|
41
|
+
# is no value of such an array, so no cell equals it. So is a
|
|
42
|
+
# `Complex` with an imaginary part on an integer or float array.
|
|
43
|
+
# - `self` is complex: cells equal to `v`, as {#eq} compares.
|
|
42
44
|
# - `v` is a CArray: broadcasts; each `v[k]` is counted
|
|
43
45
|
# independently and stacked into a result whose trailing axes
|
|
44
46
|
# have shape `v.shape`. Not supported when `self.data_type` is
|
|
@@ -71,8 +71,8 @@ class CArray
|
|
|
71
71
|
# @return [self]
|
|
72
72
|
# @raise [CArray::DataTypeError] for a non-numeric or complex
|
|
73
73
|
# `data_type` (complex values have no order).
|
|
74
|
-
# @raise [RangeError] when `v`
|
|
75
|
-
#
|
|
74
|
+
# @raise [RangeError] when an Integer `v` is below the type, as `pmin`
|
|
75
|
+
# refuses it. One above the type leaves the cell as it is.
|
|
76
76
|
def elem_min(idx, v); end
|
|
77
77
|
|
|
78
78
|
# @overload elem_max(idx, v)
|
|
@@ -84,7 +84,8 @@ class CArray
|
|
|
84
84
|
# @return [self]
|
|
85
85
|
# @raise [CArray::DataTypeError] for a non-numeric or complex
|
|
86
86
|
# `data_type`.
|
|
87
|
-
# @raise [RangeError] when `v`
|
|
87
|
+
# @raise [RangeError] when an Integer `v` is above the type, as `pmax`
|
|
88
|
+
# refuses it. One below the type leaves the cell as it is.
|
|
88
89
|
def elem_max(idx, v); end
|
|
89
90
|
|
|
90
91
|
# @!endgroup
|