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
data/yard-stubs/ca_obj_window.rb
CHANGED
|
@@ -6,11 +6,24 @@
|
|
|
6
6
|
# In-range cells alias the parent, out-of-range cells take the fill value
|
|
7
7
|
# (or are masked). {CAShift} is the same view expressed as a translation.
|
|
8
8
|
class CAWindow < CAView
|
|
9
|
+
# @overload bounds
|
|
10
|
+
# Returns the boundary rule as a Symbol: `:fill`, `:mask`, `:nearest`,
|
|
11
|
+
# `:strict` or `:ruby`. A window made with `fill_value: UNDEF`
|
|
12
|
+
# answers `:mask`. A {CAShift} with `roll:` on some axes has a rule
|
|
13
|
+
# per axis; this answers the rule of axis 0.
|
|
14
|
+
# @return [Symbol]
|
|
15
|
+
def bounds; end
|
|
16
|
+
|
|
17
|
+
# @overload fill_value
|
|
18
|
+
# Returns the value given to out-of-range cells. It is fixed when the
|
|
19
|
+
# window is made; to change it, make the window again.
|
|
20
|
+
# @return [Object]
|
|
21
|
+
def fill_value; end
|
|
9
22
|
end
|
|
10
23
|
|
|
11
24
|
# Mask companion of {CAWindow}.
|
|
12
25
|
# @private
|
|
13
|
-
class
|
|
26
|
+
class CAWindow::Mask < CAWindow
|
|
14
27
|
end
|
|
15
28
|
|
|
16
29
|
class CArray
|
|
@@ -25,7 +38,7 @@ class CArray
|
|
|
25
38
|
# through `unmask` too.
|
|
26
39
|
#
|
|
27
40
|
# A range wider than its axis is how an array is **padded**: `a.window(-1..
|
|
28
|
-
# a.
|
|
41
|
+
# a.shape[0], -1..a.shape[1])` puts a one-cell border all round, which is NumPy's
|
|
29
42
|
# `pad` with no allocation (`fill_value:` is its `constant`, `bounds:
|
|
30
43
|
# :nearest` its `edge`). {#windows} is the different, plural thing: one
|
|
31
44
|
# such window anchored on every cell, folded.
|
|
@@ -33,29 +46,28 @@ class CArray
|
|
|
33
46
|
# Only unit-step ranges are accepted, and each range must run forward, so
|
|
34
47
|
# the `0..-1` end-relative notation cannot be used here.
|
|
35
48
|
#
|
|
36
|
-
# @overload window(*ranges, fill_value: 0, bounds:
|
|
49
|
+
# @overload window(*ranges, fill_value: 0, bounds: :fill)
|
|
37
50
|
# @param ranges [Array<Range, Integer>] one range per axis; the count
|
|
38
51
|
# must equal `self.ndim`.
|
|
39
52
|
# @param fill_value [Object] value given to out-of-range cells, written
|
|
40
53
|
# as a store writes it (a Time for a time array; a CAString's default
|
|
41
54
|
# is `""`); `UNDEF` masks them instead.
|
|
42
|
-
# @param bounds [
|
|
43
|
-
#
|
|
44
|
-
#
|
|
45
|
-
#
|
|
46
|
-
# `"mask"` masks the cell but warns — pass `fill_value: UNDEF` instead.
|
|
55
|
+
# @param bounds [Symbol] what an out-of-range index means: `:fill`
|
|
56
|
+
# (default) uses `fill_value`, `:nearest` clamps to the edge cell,
|
|
57
|
+
# `:ruby` reads negative indices from the far end, `:strict` raises.
|
|
58
|
+
# To mask the cells outside, pass `fill_value: UNDEF`.
|
|
47
59
|
# @return [CAWindow]
|
|
48
60
|
# @raise [ArgumentError] when the number of ranges does not equal `ndim`,
|
|
49
|
-
# when a range has a step other than 1 or runs backwards, when a
|
|
50
|
-
# is passed
|
|
51
|
-
#
|
|
52
|
-
#
|
|
53
|
-
# @raise [
|
|
54
|
-
# or when `bounds` is not a recognised value.
|
|
61
|
+
# when a range has a step other than 1 or runs backwards, or when a
|
|
62
|
+
# block is passed.
|
|
63
|
+
# @raise [ArgumentError] when `fill_value:` is given with a `bounds`
|
|
64
|
+
# other than `:fill`, or when `bounds` is not a recognised value.
|
|
65
|
+
# @raise [TypeError] when `bounds` is not a Symbol.
|
|
55
66
|
# @raise [IndexError] when `bounds` is `"strict"` and a range reaches
|
|
56
67
|
# outside `self`, or `"ruby"` and a range reaches past the end or
|
|
57
|
-
# before the first cell counted from the end
|
|
58
|
-
|
|
68
|
+
# before the first cell counted from the end, or `"nearest"` and a
|
|
69
|
+
# range takes cells of an axis of length 0.
|
|
70
|
+
def window(*ranges, fill_value: 0, bounds: :fill); end
|
|
59
71
|
|
|
60
72
|
# @!endgroup
|
|
61
73
|
end
|
data/yard-stubs/carray_access.rb
CHANGED
|
@@ -25,8 +25,24 @@ class CArray
|
|
|
25
25
|
# to land in and is discarded.
|
|
26
26
|
# - `:_` — newaxis: insert a size-1 axis at this position.
|
|
27
27
|
# - `:%` — repeat / tiling sugar.
|
|
28
|
+
# - `:~` — all the remaining axes.
|
|
28
29
|
# - `:>` — slab axis: wrap the result in a `CASlabIterator`.
|
|
29
|
-
# - a member name
|
|
30
|
+
# - a member name String — project a struct field (see `CARecord`).
|
|
31
|
+
#
|
|
32
|
+
# Any other one-character Symbol raises IndexError.
|
|
33
|
+
#
|
|
34
|
+
# A single boolean CArray as the whole index selects the cells where it
|
|
35
|
+
# is true, in row-major order, as a 1-D view. It must have the shape
|
|
36
|
+
# of `self`, or be 1-D with as many elements as `self` (a 1-D selector
|
|
37
|
+
# picks by position in the flattened array). A boolean array of any
|
|
38
|
+
# other shape raises ArgumentError -- a transposed one included; use
|
|
39
|
+
# `.flatten` to pick by position on purpose.
|
|
40
|
+
#
|
|
41
|
+
# A Symbol of two characters or more names a predicate: `a[:gt, 0]` is
|
|
42
|
+
# `a[a.gt(0)]`, with the arguments after the Symbol (keywords included)
|
|
43
|
+
# passed to the method. The method must return a boolean array of the
|
|
44
|
+
# shape of `self`; any other answer raises, so that a number, a list of
|
|
45
|
+
# addresses or an array of ranks is never read as an index.
|
|
30
46
|
#
|
|
31
47
|
# A single flat Integer (fewer indices than `ndim`) addresses the
|
|
32
48
|
# array in row-major flat order.
|
|
@@ -35,8 +51,12 @@ class CArray
|
|
|
35
51
|
# @return [CArray, Object] a view for a slicing form, or the element
|
|
36
52
|
# value (or `UNDEF` if masked) for an all-scalar index.
|
|
37
53
|
# @raise [IndexError] on an out-of-range index or an unrecognised form.
|
|
38
|
-
# @
|
|
39
|
-
#
|
|
54
|
+
# @raise [TypeError] when a predicate named by a Symbol returns
|
|
55
|
+
# anything but a boolean array.
|
|
56
|
+
# @raise [ArgumentError] when a boolean selector, or the answer of a
|
|
57
|
+
# predicate, has another shape.
|
|
58
|
+
# @see file:guides/users/02_indexing_and_slicing.md Indexing and slicing
|
|
59
|
+
# @see file:docs/topics/Indexer_decision_tree.md Indexer decision tree
|
|
40
60
|
def [](*index); end
|
|
41
61
|
|
|
42
62
|
# @overload []=(*index, value)
|
|
@@ -56,9 +76,36 @@ class CArray
|
|
|
56
76
|
# `UNDEF` to mask.
|
|
57
77
|
# @return [Object] `value`.
|
|
58
78
|
# @raise [IndexError] on an out-of-range index or an unsupported form.
|
|
59
|
-
# @
|
|
79
|
+
# @raise [ArgumentError] when a boolean selector has another shape
|
|
80
|
+
# (the rule of {#[]}).
|
|
81
|
+
# @see file:docs/topics/Indexer_decision_tree.md Indexer decision tree
|
|
60
82
|
def []=(*index, value); end
|
|
61
83
|
|
|
84
|
+
# @overload scan_index(shape, index)
|
|
85
|
+
# Classifies an index expression the way {#[]} would read it, for an
|
|
86
|
+
# array of the given shape, without building a view. For authors of
|
|
87
|
+
# wrappers that translate CArray's `[]` syntax into another form.
|
|
88
|
+
# @param shape [Array<Integer>] the shape of the array being indexed.
|
|
89
|
+
# @param index [Array] the arguments that would be passed to {#[]}.
|
|
90
|
+
# @return [CArray::IndexInfo] `type` is a Symbol naming the region
|
|
91
|
+
# type (`:all`, `:address`, `:flatten`, `:address_complex`, `:point`,
|
|
92
|
+
# `:block`, `:select`, `:iterator`, `:repeat`, `:grid`,
|
|
93
|
+
# `:address_array`, `:method_call`, `:member`), `index` is the
|
|
94
|
+
# payload for that type.
|
|
95
|
+
# @see file:docs/topics/Indexer_decision_tree.md Indexer decision tree
|
|
96
|
+
# (every pattern, region and payload format)
|
|
97
|
+
def self.scan_index(shape, index); end
|
|
98
|
+
|
|
99
|
+
# What {CArray.scan_index} returns: the region type an index expression
|
|
100
|
+
# selects and the payload of that type.
|
|
101
|
+
class IndexInfo < Struct
|
|
102
|
+
# @return [Symbol] the region type (`:block`, `:point`, `:grid`, ...).
|
|
103
|
+
attr_accessor :type
|
|
104
|
+
|
|
105
|
+
# @return [Object] the payload of the region type.
|
|
106
|
+
attr_accessor :index
|
|
107
|
+
end
|
|
108
|
+
|
|
62
109
|
# @!endgroup
|
|
63
110
|
|
|
64
111
|
# @!group Indexing and slicing
|
|
@@ -90,7 +137,8 @@ class CArray
|
|
|
90
137
|
# or a CArray of such addresses (arbitrary shape). A negative
|
|
91
138
|
# address counts from the end.
|
|
92
139
|
# @return [Array<Integer>, Array<CArray>] one entry per axis.
|
|
93
|
-
# @raise [IndexError] when any `addr` is out of range
|
|
140
|
+
# @raise [IndexError] when any `addr` is out of range, or when `addr` is
|
|
141
|
+
# float, complex, object or boolean.
|
|
94
142
|
def addr2index(addr); end
|
|
95
143
|
|
|
96
144
|
# @overload index2addr(*index)
|
|
@@ -101,7 +149,8 @@ class CArray
|
|
|
101
149
|
# must match that shape). Mask propagates from the inputs.
|
|
102
150
|
# @param index [Array<Integer, CArray>] one entry per axis.
|
|
103
151
|
# @return [Integer, CArray] the flat address(es).
|
|
104
|
-
# @raise [IndexError] on an out-of-range index
|
|
152
|
+
# @raise [IndexError] on an out-of-range index, or an index array that
|
|
153
|
+
# is float, complex, object or boolean.
|
|
105
154
|
# @raise [ArgumentError] on shape mismatch between non-scalar inputs.
|
|
106
155
|
def index2addr(*index); end
|
|
107
156
|
|
|
@@ -6,11 +6,9 @@ class CArray
|
|
|
6
6
|
# @!group Attributes
|
|
7
7
|
|
|
8
8
|
# @overload obj_type
|
|
9
|
-
# Returns the
|
|
10
|
-
# `
|
|
11
|
-
#
|
|
12
|
-
# Rarely needed in user code; the same information is available
|
|
13
|
-
# from `self.class`.
|
|
9
|
+
# Returns the integer that tells the C code what kind of array
|
|
10
|
+
# `self` is (the `CA_OBJ_*` value of the C API). Ruby code asks
|
|
11
|
+
# `self.class` instead.
|
|
14
12
|
# @return [Integer]
|
|
15
13
|
def obj_type; end
|
|
16
14
|
|
|
@@ -81,43 +79,31 @@ class CArray
|
|
|
81
79
|
# @return [Array<Integer>]
|
|
82
80
|
def dim; end
|
|
83
81
|
|
|
84
|
-
# @overload dim0
|
|
85
|
-
# Returns `shape[0]`.
|
|
86
|
-
# @return [Integer]
|
|
87
|
-
def dim0; end
|
|
88
|
-
|
|
89
|
-
# @overload dim1
|
|
90
|
-
# Returns `shape[1]`, or `nil` if `ndim < 2`.
|
|
91
|
-
# @return [Integer, nil]
|
|
92
|
-
def dim1; end
|
|
93
|
-
|
|
94
|
-
# @overload dim2
|
|
95
|
-
# Returns `shape[2]`, or `nil` if `ndim < 3`.
|
|
96
|
-
# @return [Integer, nil]
|
|
97
|
-
def dim2; end
|
|
98
|
-
|
|
99
|
-
# @overload dim3
|
|
100
|
-
# Returns `shape[3]`, or `nil` if `ndim < 4`.
|
|
101
|
-
# @return [Integer, nil]
|
|
102
|
-
def dim3; end
|
|
103
|
-
|
|
104
82
|
# @overload parent
|
|
105
83
|
# Returns the parent CArray of `self`, or `nil` if `self` has no
|
|
106
|
-
# parent (i.e. is an entity). For a Face (CATime, CARecord,
|
|
107
|
-
#
|
|
108
|
-
#
|
|
84
|
+
# parent (i.e. is an entity). For a Face (CATime, CARecord, ...,
|
|
85
|
+
# and a Face written in Ruby with `face: true`) it is a read-only
|
|
86
|
+
# view of the storage; a Face whose storage may be written names a
|
|
87
|
+
# method for it (`CATime#ticks`).
|
|
88
|
+
#
|
|
89
|
+
# A view that reads several arrays (a stack, a meld, a lazy
|
|
90
|
+
# expression of two or three operands) returns the first of them
|
|
91
|
+
# here and all of them from `parents`.
|
|
109
92
|
# @return [CArray, nil]
|
|
110
93
|
def parent; end
|
|
111
94
|
|
|
112
95
|
# @overload root_array
|
|
113
|
-
# Returns the array at the
|
|
114
|
-
#
|
|
96
|
+
# Returns the array at the end of the chain of single parents that
|
|
97
|
+
# starts at `self`: an entity, or a view that reads several arrays (a
|
|
98
|
+
# stack, a meld, a lazy expression of two or three operands). Such a
|
|
99
|
+
# view ends the chain, and its `parents` lead on to each of the arrays
|
|
100
|
+
# it reads. Returns `self` if `self` is an entity or such a view.
|
|
115
101
|
# @return [CArray]
|
|
116
102
|
def root_array; end
|
|
117
103
|
|
|
118
104
|
# @overload ancestors
|
|
119
|
-
# Returns the list of arrays in the
|
|
120
|
-
# to `self`.
|
|
105
|
+
# Returns the list of arrays in the chain of single parents, ordered
|
|
106
|
+
# from the root (see {#root_array}) to `self`.
|
|
121
107
|
# @return [Array<CArray>]
|
|
122
108
|
def ancestors; end
|
|
123
109
|
|
|
@@ -148,16 +134,18 @@ class CArray
|
|
|
148
134
|
def scalar?; end
|
|
149
135
|
|
|
150
136
|
# @overload entity?
|
|
151
|
-
# Returns `true` if `self` is an entity array
|
|
152
|
-
#
|
|
137
|
+
# Returns `true` if `self` is an entity: an array whose `ptr`
|
|
138
|
+
# always holds its memory. The memory may be its own or, for a
|
|
139
|
+
# {CAWrap}, memory owned elsewhere. The opposite of {#view?}.
|
|
153
140
|
# @return [Boolean]
|
|
154
141
|
def entity?; end
|
|
155
142
|
|
|
156
|
-
# @overload
|
|
157
|
-
# Returns `true` if `self` is a
|
|
158
|
-
#
|
|
143
|
+
# @overload view?
|
|
144
|
+
# Returns `true` if `self` is a view: an array that holds no
|
|
145
|
+
# memory of its own and takes its values from a parent or from a
|
|
146
|
+
# computation. The opposite of {#entity?}.
|
|
159
147
|
# @return [Boolean]
|
|
160
|
-
def
|
|
148
|
+
def view?; end
|
|
161
149
|
|
|
162
150
|
# @overload attached?
|
|
163
151
|
# Returns `true` if `self` is currently attached
|