carray 3.0.6 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.yardopts +1 -1
- data/CHANGELOG.md +7 -1830
- data/README.md +62 -35
- 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 +12 -15
- data/ext/ca_bincmp_dispatch.h +16 -38
- data/ext/ca_binop_dispatch.c +35 -0
- data/ext/ca_binop_dispatch.h +22 -46
- 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 -1504
- 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 +92 -165
- data/ext/ca_obj_bincmp.c +65 -48
- data/ext/ca_obj_binop.c +74 -49
- data/ext/ca_obj_bitarray.c +7 -21
- data/ext/ca_obj_bitfield.c +93 -26
- data/ext/ca_obj_block.c +11 -12
- data/ext/ca_obj_byte_swap.c +34 -34
- data/ext/ca_obj_const_string.c +464 -304
- data/ext/ca_obj_face.c +167 -121
- data/ext/ca_obj_face.h +32 -170
- data/ext/ca_obj_fake.c +127 -34
- data/ext/ca_obj_farray.c +13 -9
- data/ext/ca_obj_field.c +17 -13
- data/ext/ca_obj_fixlen_string.c +57 -34
- data/ext/ca_obj_grid.c +149 -113
- data/ext/ca_obj_meld.c +28 -26
- data/ext/ca_obj_moncmp.c +10 -21
- data/ext/ca_obj_monop.c +88 -73
- data/ext/ca_obj_object.c +60 -46
- data/ext/ca_obj_record.c +74 -22
- data/ext/ca_obj_reduce.c +10 -14
- data/ext/ca_obj_refer.c +146 -39
- data/ext/ca_obj_remap.c +11 -29
- data/ext/ca_obj_repeat.c +41 -23
- data/ext/ca_obj_roll.c +20 -28
- data/ext/ca_obj_select.c +17 -27
- data/ext/ca_obj_select_axis.c +35 -42
- data/ext/ca_obj_shift.c +22 -42
- data/ext/ca_obj_source.c +1 -5
- data/ext/ca_obj_stack.c +33 -29
- data/ext/ca_obj_stride.c +99 -62
- data/ext/ca_obj_string.c +8 -20
- data/ext/ca_obj_tile.c +14 -16
- 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 +48 -49
- data/ext/ca_obj_window.c +87 -99
- data/ext/ca_op_cmplx64.h +4 -0
- data/ext/ca_op_ipower.c +97 -27
- data/ext/ca_op_powi.h +9 -28
- 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 +23 -26
- data/ext/ca_sweep_engine.c +92 -26
- data/ext/ca_sweep_engine.h +22 -15
- data/ext/ca_transform_common.c +3 -8
- data/ext/ca_triop_dispatch.h +20 -32
- data/ext/caframe_csv_reader.c +12 -12
- data/ext/carray.h +300 -1009
- data/ext/carray_access.c +320 -207
- data/ext/carray_address_basis.c +128 -59
- data/ext/carray_attribute.c +81 -104
- data/ext/carray_bincount.c +12 -14
- data/ext/carray_broadcast.c +31 -27
- data/ext/carray_call_cfunc.c +174 -285
- data/ext/carray_call_cfunc.h +36 -28
- data/ext/carray_cast.c +1191 -351
- data/ext/carray_cast_func.rb +68 -8
- data/ext/carray_class.c +6 -11
- data/ext/carray_conversion.c +98 -39
- data/ext/carray_copy.c +52 -26
- data/ext/carray_core.c +286 -132
- data/ext/carray_count.c +53 -22
- data/ext/carray_element.c +49 -28
- data/ext/carray_factorize.c +64 -63
- data/ext/carray_generate.c +26 -19
- data/ext/carray_histogram.c +9 -11
- data/ext/carray_hold.c +7 -9
- data/ext/carray_index_classifier.c +127 -230
- data/ext/carray_index_classifier.h +11 -10
- data/ext/carray_integer_total.c +523 -0
- data/ext/carray_internal.h +1364 -156
- data/ext/carray_key_windows.c +3 -3
- data/ext/carray_lazy.c +37 -37
- data/ext/carray_loop.c +27 -23
- data/ext/carray_mask.c +235 -150
- data/ext/carray_math_kernel.h +23 -47
- data/ext/carray_mathfunc.c +10 -3
- data/ext/carray_median_percentile.c +106 -100
- data/ext/carray_memory_view.c +83 -69
- data/ext/carray_operator.c +490 -128
- data/ext/carray_order.c +163 -84
- data/ext/carray_partition.c +14 -16
- data/ext/carray_random.c +48 -42
- data/ext/carray_round.c +33 -5
- data/ext/carray_scatter.c +57 -39
- data/ext/carray_segment.c +42 -46
- data/ext/carray_slab.c +77 -51
- data/ext/carray_slab.h +44 -33
- data/ext/carray_sort.c +37 -31
- data/ext/carray_sort_kernel.c +36 -10
- data/ext/carray_struct.c +44 -34
- data/ext/carray_test.c +131 -81
- data/ext/carray_time_text.c +30 -31
- data/ext/carray_undef.c +50 -7
- data/ext/carray_utils.c +373 -139
- data/ext/extconf.rb +24 -17
- data/ext/mk_call_cfunc.rb +25 -31
- data/ext/mk_pow5_table.rb +2 -1
- data/ext/mkkernel.rb +819 -488
- 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 +272 -185
- data/lib/carray/basics.rb +298 -56
- data/lib/carray/bincount_nd.rb +41 -18
- data/lib/carray/block_iterator.rb +167 -119
- data/lib/carray/boolean_reduce.rb +7 -4
- data/lib/carray/categorical.rb +84 -59
- data/lib/carray/categorical_iterator.rb +90 -67
- data/lib/carray/complex.rb +61 -41
- data/lib/carray/conditional.rb +98 -23
- data/lib/carray/const_string.rb +112 -46
- data/lib/carray/core_extensions.rb +20 -69
- data/lib/carray/distance_limit.rb +7 -5
- data/lib/carray/factories.rb +269 -0
- data/lib/carray/fixlen_string.rb +95 -12
- data/lib/carray/frame/column_verbs.rb +76 -9
- data/lib/carray/frame/concat.rb +51 -7
- data/lib/carray/frame/convert.rb +2 -1
- data/lib/carray/frame/csv_parser.rb +20 -5
- data/lib/carray/frame/frame.rb +73 -31
- data/lib/carray/frame/group.rb +247 -187
- data/lib/carray/frame/io.rb +36 -12
- data/lib/carray/frame/join.rb +56 -17
- data/lib/carray/frame/records.rb +7 -5
- data/lib/carray/frame/reshape.rb +27 -7
- data/lib/carray/frame/sort.rb +10 -8
- data/lib/carray/frame/verbs.rb +217 -134
- data/lib/carray/frame/windows.rb +254 -19
- data/lib/carray/frame.rb +1 -2
- data/lib/carray/fuse_source.rb +28 -23
- 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 +104 -23
- data/lib/carray/key_windows.rb +93 -61
- data/lib/carray/lazy.rb +208 -111
- 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 +8 -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 +73 -72
- data/lib/carray/methods/{index.rb → coordinate.rb} +13 -13
- data/lib/carray/methods/discovery_along.rb +3 -3
- data/lib/carray/methods/factorize.rb +2 -0
- data/lib/carray/methods/gather_nd.rb +106 -103
- 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 +183 -143
- data/lib/carray/methods/join.rb +2 -1
- data/lib/carray/methods/lag.rb +6 -2
- data/lib/carray/methods/locate_addr.rb +157 -94
- 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 +23 -13
- 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 +50 -20
- data/lib/carray/rng.rb +1 -0
- data/lib/carray/runtime.rb +195 -17
- data/lib/carray/segment_iterator.rb +262 -137
- data/lib/carray/serialize.rb +635 -566
- data/lib/carray/slab_iterator.rb +114 -114
- data/lib/carray/stack.rb +14 -15
- data/lib/carray/string.rb +16 -22
- data/lib/carray/string_operation_extension.rb +97 -52
- data/lib/carray/struct.rb +122 -164
- data/lib/carray/struct_builder.rb +247 -73
- data/lib/carray/time.rb +663 -365
- data/lib/carray/window_iterator.rb +232 -155
- 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 +6 -2
- 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 +10 -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 +28 -16
- data/yard-stubs/carray_access.rb +55 -6
- data/yard-stubs/carray_attribute.rb +26 -38
- data/yard-stubs/carray_cast.rb +121 -162
- 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 +10 -5
- 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 +162 -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 +72 -33
- 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 +12 -3
- data/yard-stubs/carray_slab.rb +7 -4
- data/yard-stubs/carray_sort.rb +7 -6
- data/yard-stubs/carray_test.rb +18 -5
- data/yard-stubs/carray_undef.rb +44 -5
- data/yard-stubs/ruby_carray.rb +75 -40
- metadata +63 -25
- 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 -25387
- 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 -261
- data/lib/carray/data_type_limits.rb +0 -91
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# DOCUMENTATION ONLY — DO NOT REQUIRE.
|
|
2
|
+
# Stubs for the constants of CArray::Limits, which lib/carray/limits.rb
|
|
3
|
+
# defines with const_set. The values written here are the ones of the
|
|
4
|
+
# usual widths; the library computes them from the widths of the build.
|
|
5
|
+
# See yard-stubs/README.md and yard-stubs/STYLE.md.
|
|
6
|
+
|
|
7
|
+
class CArray
|
|
8
|
+
# What each numeric data type can hold.
|
|
9
|
+
#
|
|
10
|
+
# CArray::Limits::INT32_MAX # => 2147483647
|
|
11
|
+
# CArray::Limits::FLOAT32_EPSILON # => 1.1920928955078125e-07
|
|
12
|
+
#
|
|
13
|
+
# `MIN` and `MAX` bracket the range of every numeric type alike, so for
|
|
14
|
+
# a float type `MIN` is the bottom of the range and not Ruby's
|
|
15
|
+
# `Float::MIN`:
|
|
16
|
+
#
|
|
17
|
+
# CArray::Limits::FLOAT64_MIN # => -1.7976931348623157e+308
|
|
18
|
+
# Float::MIN # => 2.2250738585072014e-308
|
|
19
|
+
#
|
|
20
|
+
# Ruby's `Float::MIN`, the smallest positive normal value, is `TINY`
|
|
21
|
+
# here.
|
|
22
|
+
#
|
|
23
|
+
# Only the integer and float types have limits. A complex type is a
|
|
24
|
+
# pair of floats and is bounded by the limits of its component
|
|
25
|
+
# (`FLOAT32_*` for `:cmplx64`, `FLOAT64_*` for `:cmplx128`). The
|
|
26
|
+
# boolean, fixlen and object types have no numeric range.
|
|
27
|
+
module Limits
|
|
28
|
+
# The smallest value an `:int8` element holds.
|
|
29
|
+
INT8_MIN = -128
|
|
30
|
+
|
|
31
|
+
# The largest value an `:int8` element holds.
|
|
32
|
+
INT8_MAX = 127
|
|
33
|
+
|
|
34
|
+
# The smallest value an `:int16` element holds.
|
|
35
|
+
INT16_MIN = -32768
|
|
36
|
+
|
|
37
|
+
# The largest value an `:int16` element holds.
|
|
38
|
+
INT16_MAX = 32767
|
|
39
|
+
|
|
40
|
+
# The smallest value an `:int32` element holds.
|
|
41
|
+
INT32_MIN = -2147483648
|
|
42
|
+
|
|
43
|
+
# The largest value an `:int32` element holds.
|
|
44
|
+
INT32_MAX = 2147483647
|
|
45
|
+
|
|
46
|
+
# The smallest value an `:int64` element holds.
|
|
47
|
+
INT64_MIN = -9223372036854775808
|
|
48
|
+
|
|
49
|
+
# The largest value an `:int64` element holds.
|
|
50
|
+
INT64_MAX = 9223372036854775807
|
|
51
|
+
|
|
52
|
+
# The smallest value a `:uint8` element holds.
|
|
53
|
+
UINT8_MIN = 0
|
|
54
|
+
|
|
55
|
+
# The largest value a `:uint8` element holds.
|
|
56
|
+
UINT8_MAX = 255
|
|
57
|
+
|
|
58
|
+
# The smallest value a `:uint16` element holds.
|
|
59
|
+
UINT16_MIN = 0
|
|
60
|
+
|
|
61
|
+
# The largest value a `:uint16` element holds.
|
|
62
|
+
UINT16_MAX = 65535
|
|
63
|
+
|
|
64
|
+
# The smallest value a `:uint32` element holds.
|
|
65
|
+
UINT32_MIN = 0
|
|
66
|
+
|
|
67
|
+
# The largest value a `:uint32` element holds.
|
|
68
|
+
UINT32_MAX = 4294967295
|
|
69
|
+
|
|
70
|
+
# The smallest value a `:uint64` element holds.
|
|
71
|
+
UINT64_MIN = 0
|
|
72
|
+
|
|
73
|
+
# The largest value a `:uint64` element holds.
|
|
74
|
+
UINT64_MAX = 18446744073709551615
|
|
75
|
+
|
|
76
|
+
# The step from `1.0` to the next `:float32` value.
|
|
77
|
+
FLOAT32_EPSILON = 1.1920928955078125e-07
|
|
78
|
+
|
|
79
|
+
# The largest finite `:float32` value.
|
|
80
|
+
FLOAT32_MAX = 3.4028234663852886e+38
|
|
81
|
+
|
|
82
|
+
# The most negative finite `:float32` value, `-FLOAT32_MAX`.
|
|
83
|
+
FLOAT32_MIN = -3.4028234663852886e+38
|
|
84
|
+
|
|
85
|
+
# The smallest positive normal `:float32` value.
|
|
86
|
+
FLOAT32_TINY = 1.1754943508222875e-38
|
|
87
|
+
|
|
88
|
+
# The step from `1.0` to the next `:float64` value.
|
|
89
|
+
FLOAT64_EPSILON = 2.220446049250313e-16
|
|
90
|
+
|
|
91
|
+
# The largest finite `:float64` value.
|
|
92
|
+
FLOAT64_MAX = 1.7976931348623157e+308
|
|
93
|
+
|
|
94
|
+
# The most negative finite `:float64` value, `-FLOAT64_MAX`.
|
|
95
|
+
FLOAT64_MIN = -1.7976931348623157e+308
|
|
96
|
+
|
|
97
|
+
# The smallest positive normal `:float64` value.
|
|
98
|
+
FLOAT64_TINY = 2.2250738585072014e-308
|
|
99
|
+
end
|
|
100
|
+
end
|
data/yard-stubs/carray_loop.rb
CHANGED
|
@@ -101,26 +101,6 @@ class CArray
|
|
|
101
101
|
# @return [self]
|
|
102
102
|
def map_with_index!; end
|
|
103
103
|
|
|
104
|
-
# @overload collect!
|
|
105
|
-
# Alias of {#map!}.
|
|
106
|
-
def collect!; end
|
|
107
|
-
|
|
108
|
-
# @overload collect_addr!
|
|
109
|
-
# Alias of {#map_addr!}.
|
|
110
|
-
def collect_addr!; end
|
|
111
|
-
|
|
112
|
-
# @overload collect_index!
|
|
113
|
-
# Alias of {#map_index!}.
|
|
114
|
-
def collect_index!; end
|
|
115
|
-
|
|
116
|
-
# @overload collect_with_addr!
|
|
117
|
-
# Alias of {#map_with_addr!}.
|
|
118
|
-
def collect_with_addr!; end
|
|
119
|
-
|
|
120
|
-
# @overload collect_with_index!
|
|
121
|
-
# Alias of {#map_with_index!}.
|
|
122
|
-
def collect_with_index!; end
|
|
123
|
-
|
|
124
104
|
# @!endgroup
|
|
125
105
|
|
|
126
106
|
class << self
|
data/yard-stubs/carray_mask.rb
CHANGED
|
@@ -41,8 +41,8 @@ class CArray
|
|
|
41
41
|
# reads nothing from the masked ones.
|
|
42
42
|
#
|
|
43
43
|
# Nothing in a value array is masked, so `unmask` on it does nothing,
|
|
44
|
-
# while a write that would mask a cell (`UNDEF`, `mask
|
|
45
|
-
#
|
|
44
|
+
# while a write that would mask a cell (`UNDEF`, `mask=`)
|
|
45
|
+
# raises TypeError.
|
|
46
46
|
#
|
|
47
47
|
# On a Face the data slot is read through the Face. A {CACategorical}
|
|
48
48
|
# cell excluded by the sentinel code has no label, so its value reads
|
|
@@ -52,7 +52,7 @@ class CArray
|
|
|
52
52
|
|
|
53
53
|
# @overload mask
|
|
54
54
|
# Returns a new boolean view of the mask state of `self`. Each
|
|
55
|
-
# element is `
|
|
55
|
+
# element is `true` where `self` is masked and `false` where it is not.
|
|
56
56
|
# The returned view itself cannot carry a mask.
|
|
57
57
|
#
|
|
58
58
|
# The mask of a view is a view over its parent's mask: it follows
|
|
@@ -60,7 +60,11 @@ class CArray
|
|
|
60
60
|
# `clone`, which is another view onto the same parent mask (a write
|
|
61
61
|
# to it lands in the parent's mask). Use `copy` for a mask of its own.
|
|
62
62
|
#
|
|
63
|
-
# Returns `0` (Integer) if `self` has no mask array attached.
|
|
63
|
+
# Returns `0` (Integer) if `self` has no mask array attached. The
|
|
64
|
+
# `0` stands for a mask with no cell masked: `c.mask = a.mask` makes
|
|
65
|
+
# no cell of `c` masked, and `a.mask | b.mask` has the cells of
|
|
66
|
+
# `b.mask` set. `0` is true in Ruby, so use `has_mask?` to ask
|
|
67
|
+
# whether `self` has a mask.
|
|
64
68
|
# @return [CArray, Integer]
|
|
65
69
|
def mask; end
|
|
66
70
|
|
|
@@ -73,22 +77,24 @@ class CArray
|
|
|
73
77
|
# `new_mask` makes the cell masked, as a masked value does in any
|
|
74
78
|
# store. To mask the cells where a condition holds, prefer
|
|
75
79
|
# `self[cond] = UNDEF`. There a masked cell of `cond` selects nothing,
|
|
76
|
-
# as it does in any index.
|
|
80
|
+
# as it does in any index. To clear the mask, assign `false`; to give
|
|
81
|
+
# the masked cells a value as well, use {#unmask}.
|
|
77
82
|
# @param new_mask [CArray, Boolean, Integer] mask values. A
|
|
78
83
|
# non-CArray value is broadcast and stored elementwise; a CArray
|
|
79
84
|
# of any type is coerced to boolean.
|
|
80
85
|
# @return [Object] `new_mask`.
|
|
86
|
+
# @raise [TypeError] if `new_mask` is `nil`.
|
|
81
87
|
def mask=(new_mask); end
|
|
82
88
|
|
|
83
89
|
# @overload is_masked
|
|
84
90
|
# Returns a new boolean CArray of the same shape as `self`, with
|
|
85
|
-
# `
|
|
91
|
+
# `true` at masked positions and `false` elsewhere.
|
|
86
92
|
# @return [CArray]
|
|
87
93
|
def is_masked; end
|
|
88
94
|
|
|
89
95
|
# @overload is_not_masked
|
|
90
96
|
# Returns a new boolean CArray of the same shape as `self`, with
|
|
91
|
-
# `
|
|
97
|
+
# `true` at not-masked positions and `false` elsewhere.
|
|
92
98
|
# @return [CArray]
|
|
93
99
|
def is_not_masked; end
|
|
94
100
|
|
|
@@ -103,15 +109,23 @@ class CArray
|
|
|
103
109
|
# unmatched row -- takes no write and stays masked, without an error.
|
|
104
110
|
# `strip_mask` gives a new array, where every masked cell takes a value.
|
|
105
111
|
#
|
|
106
|
-
#
|
|
107
|
-
#
|
|
108
|
-
#
|
|
109
|
-
#
|
|
112
|
+
# A value or `method:` is required: `unmask` with no argument raises
|
|
113
|
+
# `ArgumentError`, as `strip_mask` does. To clear the mask without
|
|
114
|
+
# giving the masked cells a value, assign `mask = false`; what the
|
|
115
|
+
# cells then show is not defined (see {#value}).
|
|
116
|
+
#
|
|
110
117
|
# @overload unmask(fill_value)
|
|
111
118
|
# Clears the mask state and overwrites the data at previously
|
|
112
119
|
# masked positions with `fill_value`. Mutates `self`.
|
|
120
|
+
#
|
|
121
|
+
# `UNDEF` is a special argument: it is no value but "leave the cell
|
|
122
|
+
# masked", as storing `UNDEF` is, so `unmask(UNDEF)` does nothing. It
|
|
123
|
+
# is the one argument for which `unmask` leaves the mask in place. It
|
|
124
|
+
# is accepted so that a computed fill can be passed as it is:
|
|
125
|
+
# `a.unmask(a.mean)` leaves every cell masked, rather than raising,
|
|
126
|
+
# when every cell is masked and `a.mean` is `UNDEF`.
|
|
113
127
|
# @param fill_value [Object] value to store at each previously
|
|
114
|
-
# masked position, converted as a store into `self` converts it
|
|
128
|
+
# masked position, converted as a store into `self` converts it;
|
|
115
129
|
# `UNDEF` leaves the masked cells masked.
|
|
116
130
|
# @return [self]
|
|
117
131
|
# @overload unmask(method:, axis: nil)
|
|
@@ -121,8 +135,8 @@ class CArray
|
|
|
121
135
|
# masked cells with no value to carry, and cells outside the valid
|
|
122
136
|
# range (`:linear`), stay masked — so a mask may remain.
|
|
123
137
|
# @param method [Symbol] fill rule:
|
|
124
|
-
# `:forward`
|
|
125
|
-
# `:backward`
|
|
138
|
+
# `:forward` carries the last valid value forward;
|
|
139
|
+
# `:backward` carries the next valid value backward
|
|
126
140
|
# (defined for every data_type — numeric, complex, bool, object,
|
|
127
141
|
# fixlen, and Face); `:linear` interpolates each masked cell
|
|
128
142
|
# linearly by index from the two bracketing valid cells (numeric
|
|
@@ -135,6 +149,8 @@ class CArray
|
|
|
135
149
|
# float64 spacing there; the valid cells are not touched.
|
|
136
150
|
# @param axis [Integer, nil] scan axis (single axis). `nil` flattens.
|
|
137
151
|
# @return [self]
|
|
152
|
+
# @raise [ArgumentError] if neither a fill value nor `method:` is given,
|
|
153
|
+
# or if both are.
|
|
138
154
|
def unmask(*, method: nil, axis: nil); end
|
|
139
155
|
|
|
140
156
|
# `strip_mask` is the copy form of `unmask`: it returns a new array
|
|
@@ -146,18 +162,21 @@ class CArray
|
|
|
146
162
|
# `self`, with no mask attached, and `fill_value` substituted at
|
|
147
163
|
# positions that were masked in `self`. `self` is not modified.
|
|
148
164
|
#
|
|
149
|
-
#
|
|
165
|
+
# `UNDEF` is a special argument, as for {#unmask}: the copy keeps the
|
|
166
|
+
# mask, the one argument for which `strip_mask` leaves it in place.
|
|
167
|
+
# `a.strip_mask(a.mean)` gives a copy still masked everywhere when
|
|
168
|
+
# every cell is masked and `a.mean` is `UNDEF`.
|
|
150
169
|
# @param fill_value [Object] value to substitute at masked
|
|
151
|
-
# positions, converted as a store into `self` converts it
|
|
152
|
-
# `UNDEF` leaves them masked
|
|
170
|
+
# positions, converted as a store into `self` converts it;
|
|
171
|
+
# `UNDEF` leaves them masked.
|
|
153
172
|
# @return [CArray]
|
|
154
173
|
# @overload strip_mask(method:, axis: nil)
|
|
155
174
|
# Returns a new array with masked cells filled from neighbouring
|
|
156
175
|
# valid cells along `axis` (gap-fill). `self` is not modified.
|
|
157
176
|
# Residual (leading / trailing / out-of-range) masked cells that
|
|
158
177
|
# cannot be filled stay masked in the returned array.
|
|
159
|
-
# @param method [Symbol] fill rule: `:forward
|
|
160
|
-
# `:backward`
|
|
178
|
+
# @param method [Symbol] fill rule: `:forward`,
|
|
179
|
+
# `:backward` (any data_type), or `:linear` (numeric or a
|
|
161
180
|
# time Face). See {#unmask} for the full description.
|
|
162
181
|
# @param axis [Integer, nil] scan axis (single axis). `nil` flattens.
|
|
163
182
|
# @return [CArray]
|
|
@@ -169,35 +188,34 @@ class CArray
|
|
|
169
188
|
# degrade to the first / last element. Works for every data_type.
|
|
170
189
|
#
|
|
171
190
|
# @overload first(axis: nil, keep_axis: false)
|
|
172
|
-
# Returns the first
|
|
173
|
-
#
|
|
174
|
-
#
|
|
175
|
-
#
|
|
176
|
-
#
|
|
177
|
-
#
|
|
191
|
+
# Returns the first value that is not masked, along `axis`. It is a
|
|
192
|
+
# reduction like `sum`: it skips masked elements, and it takes `axis:`,
|
|
193
|
+
# not a count, so `a.first(2)` raises. It is not `Array#first`: on a
|
|
194
|
+
# masked `a[0]`, `a.first` is the next value that is not masked. The
|
|
195
|
+
# first `n` elements are `a[0...n]`.
|
|
196
|
+
#
|
|
197
|
+
# Where every element is masked, or there are none, the result is
|
|
198
|
+
# UNDEF. To put a default value there, write
|
|
199
|
+
# `a.first(axis: 0).strip_mask(v)`.
|
|
200
|
+
# @param axis [Integer, Array<Integer>, nil] the axis or axes to
|
|
201
|
+
# reduce; `nil` reduces the whole array to a scalar.
|
|
178
202
|
# @param keep_axis [Boolean] keep the reduced axis as a size-1 axis.
|
|
179
|
-
# @return [Object, CArray] a scalar for a
|
|
180
|
-
#
|
|
203
|
+
# @return [Object, CArray] a scalar for a whole-array reduction (UNDEF
|
|
204
|
+
# if every element is masked), otherwise a reduced CArray.
|
|
181
205
|
def first(axis: nil, keep_axis: false); end
|
|
182
206
|
|
|
183
207
|
# @overload last(axis: nil, keep_axis: false)
|
|
184
|
-
# Returns the last
|
|
185
|
-
#
|
|
186
|
-
#
|
|
187
|
-
#
|
|
208
|
+
# Returns the last value that is not masked, along `axis`. It is the
|
|
209
|
+
# reduction {#first} is, read from the end: it takes `axis:`, not a
|
|
210
|
+
# count, and it is not `Array#last`. The last `n` elements are
|
|
211
|
+
# `a[-n..]`.
|
|
212
|
+
# @param axis [Integer, Array<Integer>, nil] the axis or axes to
|
|
213
|
+
# reduce; `nil` reduces the whole array to a scalar.
|
|
188
214
|
# @param keep_axis [Boolean] keep the reduced axis as a size-1 axis.
|
|
189
|
-
# @return [Object, CArray] a scalar for a
|
|
190
|
-
#
|
|
215
|
+
# @return [Object, CArray] a scalar for a whole-array reduction (UNDEF
|
|
216
|
+
# if every element is masked), otherwise a reduced CArray.
|
|
191
217
|
def last(axis: nil, keep_axis: false); end
|
|
192
218
|
|
|
193
|
-
# @overload invert_mask
|
|
194
|
-
# Flips the mask state of every element of `self` in place
|
|
195
|
-
# (masked ↔ not masked). Mutates `self`.
|
|
196
|
-
# @return [self]
|
|
197
|
-
# @raise [FrozenError] if `self` is frozen or a view of a frozen array.
|
|
198
|
-
# @raise [RuntimeError] if `self` is read-only (a lazy expression, for one).
|
|
199
|
-
def invert_mask; end
|
|
200
|
-
|
|
201
219
|
# @overload inherit_mask(*others)
|
|
202
220
|
# Sets the mask of `self` to the logical OR of the current mask
|
|
203
221
|
# of `self` and the masks of each array in `others`. Mutates
|