carray 2.0.1 → 3.0.1
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 +6 -25
- data/CHANGELOG.md +338 -0
- data/{NEWS.md → CHANGELOG.v1.md} +3 -0
- data/LICENSE +1 -1
- data/README.md +120 -36
- data/carray.gemspec +32 -30
- data/ext/ca_array_pool.c +91 -0
- data/ext/ca_axis_descriptor.h +186 -0
- data/ext/ca_axis_dispatch.c +924 -0
- data/ext/ca_axis_group.c +1244 -0
- data/ext/ca_bincmp_dispatch.c +76 -0
- data/ext/ca_bincmp_dispatch.h +85 -0
- data/ext/ca_binop_dispatch.c +124 -0
- data/ext/ca_binop_dispatch.h +152 -0
- data/ext/ca_categorical_iterator.c +1375 -0
- data/ext/ca_compare.c +94 -0
- data/ext/ca_compare.h +26 -0
- data/ext/ca_composite_dispatch.c +414 -0
- data/ext/ca_composite_dispatch.h +116 -0
- data/ext/ca_for_buffer.h +96 -0
- data/ext/ca_for_each_element.h +239 -0
- data/ext/ca_group_iter.c +304 -0
- data/ext/ca_iter_substrate.h +325 -0
- data/ext/ca_kernel_iterator.c +4367 -0
- data/ext/ca_kernel_iterator.h +2596 -0
- data/ext/ca_moncmp_dispatch.c +37 -0
- data/ext/ca_moncmp_dispatch.h +62 -0
- data/ext/ca_monop_dispatch.c +200 -0
- data/ext/ca_monop_dispatch.h +235 -0
- data/ext/ca_obj_array.c +355 -359
- data/ext/ca_obj_bincmp.c +839 -0
- data/ext/ca_obj_binop.c +948 -0
- data/ext/ca_obj_bitarray.c +369 -164
- data/ext/ca_obj_bitfield.c +294 -234
- data/ext/ca_obj_block.c +189 -711
- data/ext/ca_obj_byte_swap.c +766 -0
- data/ext/ca_obj_const_string.c +967 -0
- data/ext/ca_obj_face.c +750 -0
- data/ext/ca_obj_face.h +279 -0
- data/ext/ca_obj_fake.c +239 -100
- data/ext/ca_obj_farray.c +54 -441
- data/ext/ca_obj_field.c +82 -529
- data/ext/ca_obj_fixlen_string.c +308 -0
- data/ext/ca_obj_grid.c +866 -440
- data/ext/ca_obj_meld.c +1039 -0
- data/ext/ca_obj_moncmp.c +588 -0
- data/ext/ca_obj_monop.c +1123 -0
- data/ext/ca_obj_object.c +866 -296
- data/ext/ca_obj_record.c +470 -0
- data/ext/ca_obj_reduce.c +97 -82
- data/ext/ca_obj_refer.c +593 -459
- data/ext/ca_obj_remap.c +475 -0
- data/ext/ca_obj_repeat.c +92 -477
- data/ext/ca_obj_roll.c +624 -0
- data/ext/ca_obj_select.c +344 -296
- data/ext/ca_obj_select_axis.c +1306 -0
- data/ext/ca_obj_shift.c +231 -793
- data/ext/ca_obj_source.c +78 -0
- data/ext/ca_obj_stack.c +1173 -0
- data/ext/ca_obj_stride.c +2584 -0
- data/ext/ca_obj_string.c +270 -0
- data/ext/ca_obj_tile.c +622 -0
- data/ext/ca_obj_time.c +548 -0
- data/ext/ca_obj_timedelta.c +437 -0
- data/ext/ca_obj_transpose.c +62 -516
- data/ext/ca_obj_triop.c +785 -0
- data/ext/ca_obj_window.c +1202 -565
- data/ext/ca_op_byte_swap.c +175 -0
- data/ext/ca_op_cmplx64.h +123 -0
- data/ext/ca_op_ipower.c +316 -0
- data/ext/ca_op_powi.h +88 -0
- data/ext/ca_sort_kernels.h +132 -0
- data/ext/ca_sweep_engine.c +473 -0
- data/ext/ca_sweep_engine.h +166 -0
- data/ext/ca_transform_common.c +235 -0
- data/ext/ca_triop_dispatch.c +55 -0
- data/ext/ca_triop_dispatch.h +62 -0
- data/ext/carray.h +810 -420
- data/ext/carray_access.c +873 -731
- data/ext/carray_attribute.c +98 -329
- data/ext/carray_bincount.c +255 -0
- data/ext/carray_broadcast.c +376 -0
- data/ext/carray_build_flags.h +3 -0
- data/ext/carray_call_cfunc.c +2897 -874
- data/ext/carray_call_cfunc.h +313 -0
- data/ext/carray_cast.c +1264 -315
- data/ext/carray_cast_func.rb +81 -40
- data/ext/carray_class.c +53 -63
- data/ext/carray_config.h +28 -0
- data/ext/carray_conversion.c +350 -346
- data/ext/carray_copy.c +168 -270
- data/ext/carray_core.c +1396 -206
- data/ext/carray_count.c +312 -0
- data/ext/carray_data_type.c +43 -19
- data/ext/carray_element.c +585 -213
- data/ext/carray_factorize.c +2542 -0
- data/ext/carray_generate.c +230 -559
- data/ext/carray_histogram.c +490 -0
- data/ext/carray_hold.c +228 -0
- data/ext/carray_index_classifier.c +1021 -0
- data/ext/carray_index_classifier.h +27 -0
- data/ext/carray_internal.h +136 -0
- data/ext/carray_kernels_bincmp.c +4446 -0
- data/ext/carray_kernels_binop.c +11001 -0
- data/ext/carray_kernels_init.c +1131 -0
- data/ext/carray_kernels_map.c +3467 -0
- data/ext/carray_kernels_moncmp.c +2097 -0
- data/ext/carray_kernels_monop.c +18313 -0
- data/ext/carray_kernels_reduce_aggregate.c +25837 -0
- data/ext/carray_kernels_reduce_boolean.c +330 -0
- data/ext/carray_kernels_reduce_cumulative.c +14593 -0
- data/ext/carray_kernels_reduce_extreme.c +16948 -0
- data/ext/carray_kernels_reduce_variance.c +3910 -0
- data/ext/carray_kernels_scan.c +3693 -0
- data/ext/carray_kernels_search.c +32138 -0
- data/ext/carray_kernels_sort.c +10626 -0
- data/ext/carray_kernels_triop.c +1392 -0
- data/ext/carray_lazy.c +737 -0
- data/ext/carray_loop.c +88 -200
- data/ext/carray_mask.c +853 -158
- data/ext/carray_math_kernel.h +120 -0
- data/ext/carray_mathfunc.c +10 -241
- data/ext/carray_median_percentile.c +1257 -0
- data/ext/carray_memory_view.c +1650 -0
- data/ext/carray_operator.c +1525 -320
- data/ext/carray_order.c +664 -1394
- data/ext/carray_partition.c +416 -0
- data/ext/carray_random.c +518 -0
- data/ext/carray_scatter.c +357 -0
- data/ext/carray_slab.c +1219 -0
- data/ext/carray_slab.h +84 -0
- data/ext/carray_sort.c +829 -0
- data/ext/carray_sort_kernel.c +620 -0
- data/ext/carray_struct.c +695 -0
- data/ext/carray_test.c +343 -229
- data/ext/carray_undef.c +34 -17
- data/ext/carray_utils.c +175 -74
- data/ext/extconf.rb +234 -55
- data/ext/mk_call_cfunc.rb +671 -0
- data/ext/mkkernel.rb +9096 -0
- data/ext/ruby_carray.c +211 -108
- data/ext/version.h +4 -14
- data/ext/version.rb +5 -13
- data/lib/carray/arrow_tensor.rb +401 -0
- data/lib/carray/attribute.rb +166 -0
- data/lib/carray/autoload_carray.rb +239 -0
- data/lib/carray/autoload_method_extension.rb +45 -0
- data/lib/carray/axis_group.rb +711 -0
- data/lib/carray/basics.rb +481 -0
- data/lib/carray/bincount_nd.rb +358 -0
- data/lib/carray/block_iterator.rb +614 -0
- data/lib/carray/boolean_reduce.rb +109 -0
- data/lib/carray/categorical.rb +561 -0
- data/lib/carray/categorical_iterator.rb +1084 -0
- data/lib/carray/complex.rb +150 -0
- data/lib/carray/conditional.rb +216 -0
- data/lib/carray/const_string.rb +228 -0
- data/lib/carray/construct.rb +160 -328
- data/lib/carray/core_extensions.rb +297 -0
- data/lib/carray/data_type_extension.rb +250 -0
- data/lib/carray/fixlen_string.rb +95 -0
- data/lib/carray/frame/concat.rb +132 -0
- data/lib/carray/frame/convert.rb +95 -0
- data/lib/carray/frame/csv_parser.rb +211 -0
- data/lib/carray/frame/frame.rb +642 -0
- data/lib/carray/frame/group.rb +186 -0
- data/lib/carray/frame/io.rb +321 -0
- data/lib/carray/frame/join.rb +248 -0
- data/lib/carray/frame/records.rb +99 -0
- data/lib/carray/frame/sort.rb +113 -0
- data/lib/carray/frame/verbs.rb +316 -0
- data/lib/carray/frame.rb +16 -0
- data/lib/carray/fuse_source.rb +123 -0
- data/lib/carray/fusion.rb +218 -0
- data/lib/carray/histogram.rb +512 -0
- data/lib/carray/inspect.rb +37 -26
- data/lib/carray/iterator.rb +58 -349
- data/lib/carray/lazy.rb +941 -0
- data/lib/carray/mask_gap_fill.rb +200 -0
- data/lib/carray/math.rb +78 -342
- data/lib/carray/meld_reduce.rb +289 -0
- data/lib/carray/methods/align_addr.rb +116 -0
- data/lib/carray/methods/bin.rb +128 -0
- data/lib/carray/methods/bincount.rb +87 -0
- data/lib/carray/methods/bit_string.rb +92 -0
- data/lib/carray/methods/broadcast.rb +63 -0
- data/lib/carray/methods/choose.rb +39 -0
- data/lib/carray/methods/composition.rb +280 -0
- data/lib/carray/methods/gather_nd.rb +206 -0
- data/lib/carray/methods/index.rb +39 -0
- data/lib/carray/methods/insert_block.rb +99 -0
- data/lib/carray/methods/is_in.rb +141 -0
- data/lib/carray/methods/join.rb +90 -0
- data/lib/carray/methods/locate_addr.rb +52 -0
- data/lib/carray/methods/mask_duplicates.rb +41 -0
- data/lib/carray/methods/meshgrid.rb +90 -0
- data/lib/carray/methods/mode.rb +126 -0
- data/lib/carray/methods/nunique.rb +46 -0
- data/lib/carray/methods/resize.rb +56 -0
- data/lib/carray/methods/snap.rb +161 -0
- data/lib/carray/methods/string_format.rb +57 -0
- data/lib/carray/methods/unique.rb +47 -0
- data/lib/carray/methods/value_counts.rb +71 -0
- data/lib/carray/mkmf.rb +124 -101
- data/lib/carray/runtime.rb +89 -0
- data/lib/carray/serialize.rb +478 -167
- data/lib/carray/slab_iterator.rb +305 -0
- data/lib/carray/stack.rb +291 -0
- data/lib/carray/string.rb +56 -180
- data/lib/carray/string_operation_extension.rb +289 -0
- data/lib/carray/struct.rb +335 -323
- data/lib/carray/struct_builder.rb +697 -0
- data/lib/carray/table.rb +41 -2
- data/lib/carray/time.rb +2654 -38
- data/lib/carray/window_iterator.rb +927 -0
- data/lib/carray.rb +55 -57
- data/yard-stubs/ca_obj_array.rb +385 -0
- data/yard-stubs/ca_obj_bitarray.rb +38 -0
- data/yard-stubs/ca_obj_bitfield.rb +43 -0
- data/yard-stubs/ca_obj_block.rb +73 -0
- data/yard-stubs/ca_obj_byte_swap.rb +56 -0
- data/yard-stubs/ca_obj_fake.rb +31 -0
- data/yard-stubs/ca_obj_farray.rb +32 -0
- data/yard-stubs/ca_obj_field.rb +45 -0
- data/yard-stubs/ca_obj_grid.rb +35 -0
- data/yard-stubs/ca_obj_refer.rb +72 -0
- data/yard-stubs/ca_obj_roll.rb +45 -0
- data/yard-stubs/ca_obj_shift.rb +43 -0
- data/yard-stubs/ca_obj_stride.rb +181 -0
- data/yard-stubs/ca_obj_tile.rb +29 -0
- data/yard-stubs/ca_obj_transpose.rb +40 -0
- data/yard-stubs/ca_obj_window.rb +49 -0
- data/yard-stubs/carray_access.rb +131 -0
- data/yard-stubs/carray_attribute.rb +246 -0
- data/yard-stubs/carray_broadcast.rb +37 -0
- data/yard-stubs/carray_cast.rb +489 -0
- data/yard-stubs/carray_class.rb +65 -0
- data/yard-stubs/carray_conversion.rb +76 -0
- data/yard-stubs/carray_copy.rb +79 -0
- data/yard-stubs/carray_core.rb +114 -0
- data/yard-stubs/carray_count.rb +79 -0
- data/yard-stubs/carray_element.rb +108 -0
- data/yard-stubs/carray_generate.rb +66 -0
- data/yard-stubs/carray_lazy.rb +23 -0
- data/yard-stubs/carray_loop.rb +140 -0
- data/yard-stubs/carray_mask.rb +259 -0
- data/yard-stubs/carray_math.rb +132 -0
- data/yard-stubs/carray_mathfunc.rb +45 -0
- data/yard-stubs/carray_median_percentile.rb +89 -0
- data/yard-stubs/carray_memory_view.rb +163 -0
- data/yard-stubs/carray_order.rb +312 -0
- data/yard-stubs/carray_random.rb +89 -0
- data/yard-stubs/carray_scatter.rb +106 -0
- data/yard-stubs/carray_slab.rb +57 -0
- data/yard-stubs/carray_sort.rb +163 -0
- data/yard-stubs/carray_test.rb +85 -0
- data/yard-stubs/carray_undef.rb +64 -0
- data/yard-stubs/carray_utils.rb +97 -0
- data/yard-stubs/ruby_carray.rb +193 -0
- metadata +220 -138
- data/Rakefile +0 -51
- data/TODO.md +0 -18
- data/ext/ca_iter_block.c +0 -257
- data/ext/ca_iter_dimension.c +0 -299
- data/ext/ca_iter_window.c +0 -214
- data/ext/ca_obj_mapping.c +0 -644
- data/ext/ca_obj_unbound_repeat.c +0 -529
- data/ext/carray_iterator.c +0 -641
- data/ext/carray_math.rb +0 -850
- data/ext/carray_numeric.c +0 -259
- data/ext/carray_sort_addr.c +0 -254
- data/ext/carray_stat.c +0 -2100
- data/ext/carray_stat_proc.rb +0 -1999
- data/ext/mkmath.rb +0 -741
- data/ext/ruby_ccomplex.c +0 -509
- data/ext/ruby_float_func.c +0 -86
- data/lib/carray/array.rb +0 -8
- data/lib/carray/autoload/autoload_base.rb +0 -19
- data/lib/carray/autoload/autoload_gem_cairo.rb +0 -9
- data/lib/carray/autoload/autoload_gem_ffi.rb +0 -9
- data/lib/carray/autoload/autoload_gem_gnuplot.rb +0 -2
- data/lib/carray/autoload/autoload_gem_io_csv.rb +0 -14
- data/lib/carray/autoload/autoload_gem_io_pg.rb +0 -6
- data/lib/carray/autoload/autoload_gem_io_sqlite3.rb +0 -12
- data/lib/carray/autoload/autoload_gem_narray.rb +0 -10
- data/lib/carray/autoload/autoload_gem_numo_narray.rb +0 -15
- data/lib/carray/autoload/autoload_gem_opencv.rb +0 -16
- data/lib/carray/autoload/autoload_gem_random.rb +0 -8
- data/lib/carray/autoload/autoload_gem_rmagick.rb +0 -23
- data/lib/carray/autoload/autoload_gem_zimg.rb +0 -3
- data/lib/carray/autoload/autoload_io_imagemagick.rb +0 -6
- data/lib/carray/autoload/autoload_math_histogram.rb +0 -5
- data/lib/carray/autoload/autoload_math_recurrence.rb +0 -6
- data/lib/carray/autoload/autoload_object_iterator.rb +0 -1
- data/lib/carray/autoload/autoload_object_link.rb +0 -1
- data/lib/carray/autoload/autoload_object_pack.rb +0 -2
- data/lib/carray/autoload.rb +0 -141
- data/lib/carray/basic.rb +0 -191
- data/lib/carray/broadcast.rb +0 -101
- data/lib/carray/compose.rb +0 -315
- data/lib/carray/convert.rb +0 -115
- data/lib/carray/info.rb +0 -110
- data/lib/carray/io/imagemagick.rb +0 -235
- data/lib/carray/mask.rb +0 -102
- data/lib/carray/math/histogram.rb +0 -177
- data/lib/carray/math/recurrence.rb +0 -93
- data/lib/carray/object/ca_obj_iterator.rb +0 -50
- data/lib/carray/object/ca_obj_link.rb +0 -50
- data/lib/carray/object/ca_obj_pack.rb +0 -99
- data/lib/carray/obsolete.rb +0 -256
- data/lib/carray/ordering.rb +0 -181
- data/lib/carray/testing.rb +0 -51
- data/lib/carray/transform.rb +0 -109
- data/mailmap +0 -1
- data/misc/Methods.ja.md +0 -182
- data/misc/NOTE +0 -51
- data/spec/Classes/CABitfield_spec.rb +0 -58
- data/spec/Classes/CABlockIterator_spec.rb +0 -114
- data/spec/Classes/CABlock_spec.rb +0 -205
- data/spec/Classes/CAField_spec.rb +0 -39
- data/spec/Classes/CAGrid_spec.rb +0 -75
- data/spec/Classes/CAMap_spec.rb +0 -0
- data/spec/Classes/CAMapping_spec.rb +0 -105
- data/spec/Classes/CAObject_attribute_spec.rb +0 -33
- data/spec/Classes/CAObject_spec.rb +0 -33
- data/spec/Classes/CARefer_spec.rb +0 -93
- data/spec/Classes/CARepeat_spec.rb +0 -65
- data/spec/Classes/CASelect_spec.rb +0 -22
- data/spec/Classes/CAShift_spec.rb +0 -16
- data/spec/Classes/CAStruct_spec.rb +0 -71
- data/spec/Classes/CATranspose_spec.rb +0 -60
- data/spec/Classes/CAUnboudRepeat_spec.rb +0 -102
- data/spec/Classes/CAWindow_spec.rb +0 -54
- data/spec/Classes/CAWrap_spec.rb +0 -8
- data/spec/Classes/CArray_spec.rb +0 -184
- data/spec/Classes/CScalar_spec.rb +0 -55
- data/spec/Features/feature_130_spec.rb +0 -19
- data/spec/Features/feature_attributes_spec.rb +0 -280
- data/spec/Features/feature_boolean_spec.rb +0 -98
- data/spec/Features/feature_broadcast.rb +0 -116
- data/spec/Features/feature_cast_function.rb +0 -19
- data/spec/Features/feature_cast_spec.rb +0 -33
- data/spec/Features/feature_class_spec.rb +0 -84
- data/spec/Features/feature_complex_spec.rb +0 -42
- data/spec/Features/feature_composite_spec.rb +0 -124
- data/spec/Features/feature_convert_spec.rb +0 -46
- data/spec/Features/feature_copy_spec.rb +0 -123
- data/spec/Features/feature_creation_spec.rb +0 -84
- data/spec/Features/feature_element_spec.rb +0 -144
- data/spec/Features/feature_extream_spec.rb +0 -54
- data/spec/Features/feature_generate_spec.rb +0 -74
- data/spec/Features/feature_index_spec.rb +0 -69
- data/spec/Features/feature_mask_spec.rb +0 -580
- data/spec/Features/feature_math_spec.rb +0 -97
- data/spec/Features/feature_order_spec.rb +0 -146
- data/spec/Features/feature_ref_store_spec.rb +0 -209
- data/spec/Features/feature_serialization_spec.rb +0 -125
- data/spec/Features/feature_stat_spec.rb +0 -397
- data/spec/Features/feature_virtual_spec.rb +0 -48
- data/spec/Features/method_eq_spec.rb +0 -81
- data/spec/Features/method_is_nan_spec.rb +0 -12
- data/spec/Features/method_map_spec.rb +0 -54
- data/spec/Features/method_max_with.rb +0 -20
- data/spec/Features/method_min_with.rb +0 -19
- data/spec/Features/method_ne_spec.rb +0 -18
- data/spec/Features/method_project_spec.rb +0 -188
- data/spec/Features/method_ref_spec.rb +0 -27
- data/spec/Features/method_round_spec.rb +0 -11
- data/spec/Features/method_s_linspace_spec.rb +0 -48
- data/spec/Features/method_s_span_spec.rb +0 -14
- data/spec/Features/method_seq_spec.rb +0 -47
- data/spec/Features/method_sort_with.rb +0 -43
- data/spec/Features/method_sorted_with.rb +0 -29
- data/spec/Features/method_span_spec.rb +0 -42
- data/spec/Features/method_wrap_readonly_spec.rb +0 -43
- data/spec/UnitTest/test_CAVirtual.rb +0 -214
- data/spec/spec_all.rb +0 -10
- data/utils/ca_ase.rb +0 -21
- data/utils/ca_methods.rb +0 -15
- data/utils/cast_checker.rb +0 -30
- data/utils/convert_test.rb +0 -73
- data/utils/extract_yard.rb +0 -22
- data/utils/guess_shape.rb +0 -76
- data/utils/monkey_patch_methods.rb +0 -62
- data/utils/remove_resource_fork.sh +0 -5
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# DOCUMENTATION ONLY — DO NOT REQUIRE.
|
|
2
|
+
# Stubs for methods defined in ext/carray_access.c.
|
|
3
|
+
# See yard-stubs/README.md and yard-stubs/STYLE.md.
|
|
4
|
+
#
|
|
5
|
+
# The indexer surface (`[]` / `[]=`) is large; the per-form detail lives in
|
|
6
|
+
# the user guides (see the @see links) rather than being duplicated here.
|
|
7
|
+
|
|
8
|
+
class CArray
|
|
9
|
+
# @!group Indexing and slicing
|
|
10
|
+
|
|
11
|
+
# @overload [](*index)
|
|
12
|
+
# Returns a view of `self` (or a single element) selected by one
|
|
13
|
+
# `index` per axis. Every array-returning form is a view onto the
|
|
14
|
+
# original storage — writing through it reaches the source.
|
|
15
|
+
#
|
|
16
|
+
# Accepted per-axis index forms:
|
|
17
|
+
# - Integer — one position (negative counts from the end); an
|
|
18
|
+
# all-Integer index returns the single element (masked -> UNDEF).
|
|
19
|
+
# - `nil` — the whole axis.
|
|
20
|
+
# - Range — a contiguous (or stepped, via a stepped Range) sub-range.
|
|
21
|
+
# - boolean CArray — masked selection along that axis.
|
|
22
|
+
# - Integer CArray — fancy gather (index array); shape follows the
|
|
23
|
+
# index array.
|
|
24
|
+
# - `:_` — newaxis: insert a size-1 axis at this position.
|
|
25
|
+
# - `:*` / `:%` — repeat / tiling sugar.
|
|
26
|
+
# - `:>` — slab axis: wrap the result in a `CASlabIterator`.
|
|
27
|
+
# - a member name Symbol — project a struct field (see `CARecord`).
|
|
28
|
+
#
|
|
29
|
+
# A single flat Integer (fewer indices than `ndim`) addresses the
|
|
30
|
+
# array in row-major flat order.
|
|
31
|
+
# @param index [Array<Integer, Range, nil, CArray, Symbol>] one entry
|
|
32
|
+
# per axis (or a single flat address).
|
|
33
|
+
# @return [CArray, Object] a view for a slicing form, or the element
|
|
34
|
+
# value (or `UNDEF` if masked) for an all-scalar index.
|
|
35
|
+
# @raise [IndexError] on an out-of-range index or an unrecognised form.
|
|
36
|
+
# @see file:docs/drafts/02_indexing_and_slicing.md Indexing and slicing
|
|
37
|
+
# @see file:docs/drafts/16_indexer_reference.md Indexer reference
|
|
38
|
+
def [](*index); end
|
|
39
|
+
|
|
40
|
+
# @overload []=(*index, value)
|
|
41
|
+
# Sets the cells of `self` selected by `index` (same per-axis forms as
|
|
42
|
+
# {#[]}) to `value`. `value` may be a scalar (broadcast), an Array, or
|
|
43
|
+
# a CArray whose element count matches the selection; assigning `UNDEF`
|
|
44
|
+
# masks the selected cells.
|
|
45
|
+
#
|
|
46
|
+
# Assignment through a slab iterator (`:>`) is not supported — use a
|
|
47
|
+
# block index (e.g. `ca[range, nil] = val`) or `each_slab`.
|
|
48
|
+
# @param index [Array<Integer, Range, nil, CArray, Symbol>] one entry
|
|
49
|
+
# per axis (or a single flat address).
|
|
50
|
+
# @param value [Object, Array, CArray] the value(s) to store, or
|
|
51
|
+
# `UNDEF` to mask.
|
|
52
|
+
# @return [Object] `value`.
|
|
53
|
+
# @raise [IndexError] on an out-of-range index or an unsupported form.
|
|
54
|
+
# @see file:docs/drafts/16_indexer_reference.md Indexer reference
|
|
55
|
+
def []=(*index, value); end
|
|
56
|
+
|
|
57
|
+
# @!endgroup
|
|
58
|
+
|
|
59
|
+
# @!group Indexing and slicing
|
|
60
|
+
|
|
61
|
+
# @overload fill(value)
|
|
62
|
+
# Sets every element of `self` to `value` and clears any mask.
|
|
63
|
+
# @param value [Object] the fill value.
|
|
64
|
+
# @return [self]
|
|
65
|
+
def fill(value); end
|
|
66
|
+
|
|
67
|
+
# @overload fill_copy(value)
|
|
68
|
+
# Returns a copy of `self` with every element set to `value`.
|
|
69
|
+
# @param value [Object] the fill value.
|
|
70
|
+
# @return [CArray] the filled copy.
|
|
71
|
+
def fill_copy(value); end
|
|
72
|
+
|
|
73
|
+
# @!endgroup
|
|
74
|
+
|
|
75
|
+
# @!group Index and address conversion
|
|
76
|
+
|
|
77
|
+
# @overload addr2index(addr)
|
|
78
|
+
# Unravels a flat row-major address into per-axis indices, sized by
|
|
79
|
+
# `self.shape`. With an Integer `addr` returns N Integers; with a
|
|
80
|
+
# CArray of addresses returns N CArrays of the same shape as `addr`
|
|
81
|
+
# (mask propagated per cell). In both cases the return is a Ruby
|
|
82
|
+
# Array of length `self.ndim`, so `i, j = ca.addr2index(x)` unpacks
|
|
83
|
+
# uniformly for scalar and vector inputs.
|
|
84
|
+
# @param addr [Integer, CArray] a flat address in `0...elements`,
|
|
85
|
+
# or a CArray of such addresses (arbitrary shape).
|
|
86
|
+
# @return [Array<Integer>, Array<CArray>] one entry per axis.
|
|
87
|
+
# @raise [ArgumentError] when any `addr` is out of range.
|
|
88
|
+
def addr2index(addr); end
|
|
89
|
+
|
|
90
|
+
# @overload index2addr(*index)
|
|
91
|
+
# Folds per-axis indices into flat row-major address(es), using
|
|
92
|
+
# `self.shape`. With all-Integer indices returns a single Integer;
|
|
93
|
+
# when any index is a CArray, returns a CArray of addresses whose
|
|
94
|
+
# shape follows the first non-scalar input (other non-scalar inputs
|
|
95
|
+
# must match that shape). Mask propagates from the inputs.
|
|
96
|
+
# @param index [Array<Integer, CArray>] one entry per axis.
|
|
97
|
+
# @return [Integer, CArray] the flat address(es).
|
|
98
|
+
# @raise [IndexError] on an out-of-range index.
|
|
99
|
+
# @raise [ArgumentError] on shape mismatch between non-scalar inputs.
|
|
100
|
+
def index2addr(*index); end
|
|
101
|
+
|
|
102
|
+
# @overload addr2index(addr, shape:)
|
|
103
|
+
# Class-form of {#addr2index} that takes an explicit `shape:` rather
|
|
104
|
+
# than reading it from a receiver. Useful for coordinate arithmetic
|
|
105
|
+
# without allocating a template CArray.
|
|
106
|
+
# @param addr [Integer, CArray] a flat address or a CArray of them.
|
|
107
|
+
# @param shape [Array<Integer>] the row-major shape defining the grid.
|
|
108
|
+
# @return [Array<Integer>, Array<CArray>] one entry per axis.
|
|
109
|
+
# @raise [ArgumentError] when any `addr` is out of range or `shape:`
|
|
110
|
+
# is missing.
|
|
111
|
+
def self.addr2index(addr, shape:); end
|
|
112
|
+
|
|
113
|
+
# @overload index2addr(*index, shape:)
|
|
114
|
+
# Class-form of {#index2addr}.
|
|
115
|
+
# @param index [Array<Integer, CArray>] one entry per axis.
|
|
116
|
+
# @param shape [Array<Integer>] the row-major shape defining the grid.
|
|
117
|
+
# @return [Integer, CArray] the flat address(es).
|
|
118
|
+
# @raise [ArgumentError] on out-of-range index, shape mismatch, or
|
|
119
|
+
# missing `shape:`.
|
|
120
|
+
def self.index2addr(*index, shape:); end
|
|
121
|
+
|
|
122
|
+
# @overload normalize_index(idx)
|
|
123
|
+
# Returns a canonical form of the index array `idx` classified against
|
|
124
|
+
# `self`'s shape (scalars normalised, `nil` for whole axes, `[start,
|
|
125
|
+
# count, step]` for blocks). Used to inspect how an index resolves.
|
|
126
|
+
# @param idx [Array] the raw index spec.
|
|
127
|
+
# @return [Array] the normalised per-axis index.
|
|
128
|
+
def normalize_index(idx); end
|
|
129
|
+
|
|
130
|
+
# @!endgroup
|
|
131
|
+
end
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
# DOCUMENTATION ONLY — DO NOT REQUIRE.
|
|
2
|
+
# Stubs for methods defined in ext/carray_attribute.c.
|
|
3
|
+
# See yard-stubs/README.md and yard-stubs/STYLE.md.
|
|
4
|
+
|
|
5
|
+
class CArray
|
|
6
|
+
# @!group Attributes
|
|
7
|
+
|
|
8
|
+
# @overload obj_type
|
|
9
|
+
# Returns the object-type integer of `self` (e.g. `CA_OBJ_ARRAY`,
|
|
10
|
+
# `CA_OBJ_BLOCK`).
|
|
11
|
+
#
|
|
12
|
+
# Rarely needed in user code; the same information is available
|
|
13
|
+
# from `self.class`.
|
|
14
|
+
# @return [Integer]
|
|
15
|
+
def obj_type; end
|
|
16
|
+
|
|
17
|
+
# @!group Type inquiry
|
|
18
|
+
|
|
19
|
+
# @overload data_type
|
|
20
|
+
# Returns the data type of each element as a Symbol (e.g. `:int32`,
|
|
21
|
+
# `:float64`).
|
|
22
|
+
# @return [Symbol]
|
|
23
|
+
def data_type; end
|
|
24
|
+
|
|
25
|
+
# @overload data_type_name
|
|
26
|
+
# Returns the String name of `data_type` (e.g. `"int32"`,
|
|
27
|
+
# `"fixlen"`).
|
|
28
|
+
# @return [String]
|
|
29
|
+
def data_type_name; end
|
|
30
|
+
|
|
31
|
+
# @!group Attributes
|
|
32
|
+
|
|
33
|
+
# @overload ndim
|
|
34
|
+
# Returns the number of dimensions of `self`.
|
|
35
|
+
# @return [Integer]
|
|
36
|
+
def ndim; end
|
|
37
|
+
|
|
38
|
+
# @overload rank
|
|
39
|
+
# @deprecated Use {#ndim}.
|
|
40
|
+
# @return [Integer]
|
|
41
|
+
def rank; end
|
|
42
|
+
|
|
43
|
+
# @overload bytes
|
|
44
|
+
# Returns the byte size of one element. Equals
|
|
45
|
+
# `CArray.sizeof(data_type)` for numeric types; for fixed-length
|
|
46
|
+
# types this method is the only way to obtain the size.
|
|
47
|
+
# @return [Integer]
|
|
48
|
+
def bytes; end
|
|
49
|
+
|
|
50
|
+
# @overload flags
|
|
51
|
+
# Returns the raw internal flag bitset (`ca->flags`) as an Integer.
|
|
52
|
+
# The bits record structural facts about the array (scalar, Face,
|
|
53
|
+
# view, read-only, …). This is a low-level provenance value with no
|
|
54
|
+
# stable public meaning; it is exposed mainly so the `_CARRAY3`
|
|
55
|
+
# serializer can snapshot it into a saved file's header.
|
|
56
|
+
# @return [Integer]
|
|
57
|
+
def flags; end
|
|
58
|
+
|
|
59
|
+
# @overload elements
|
|
60
|
+
# Returns the total number of elements (product of `shape`).
|
|
61
|
+
# @return [Integer]
|
|
62
|
+
def elements; end
|
|
63
|
+
|
|
64
|
+
# @overload size
|
|
65
|
+
# Alias of {#elements}.
|
|
66
|
+
# @return [Integer]
|
|
67
|
+
def size; end
|
|
68
|
+
|
|
69
|
+
# @overload length
|
|
70
|
+
# @deprecated Use {#elements} or {#size}.
|
|
71
|
+
# @return [Integer]
|
|
72
|
+
def length; end
|
|
73
|
+
|
|
74
|
+
# @overload shape
|
|
75
|
+
# Returns a freshly allocated Array containing the dimensional
|
|
76
|
+
# shape of `self` (e.g. `[2, 3]` for a 2×3 array).
|
|
77
|
+
#
|
|
78
|
+
# This is the recommended accessor. {#dim} is a legacy alias.
|
|
79
|
+
# @return [Array<Integer>]
|
|
80
|
+
# @example
|
|
81
|
+
# CArray.float64(2, 3).shape # => [2, 3]
|
|
82
|
+
def shape; end
|
|
83
|
+
|
|
84
|
+
# @overload dim
|
|
85
|
+
# @deprecated Use {#shape}.
|
|
86
|
+
# @return [Array<Integer>]
|
|
87
|
+
def dim; end
|
|
88
|
+
|
|
89
|
+
# @overload dim0
|
|
90
|
+
# Returns `shape[0]`.
|
|
91
|
+
# @return [Integer]
|
|
92
|
+
def dim0; end
|
|
93
|
+
|
|
94
|
+
# @overload dim1
|
|
95
|
+
# Returns `shape[1]`, or `nil` if `ndim < 2`.
|
|
96
|
+
# @return [Integer, nil]
|
|
97
|
+
def dim1; end
|
|
98
|
+
|
|
99
|
+
# @overload dim2
|
|
100
|
+
# Returns `shape[2]`, or `nil` if `ndim < 3`.
|
|
101
|
+
# @return [Integer, nil]
|
|
102
|
+
def dim2; end
|
|
103
|
+
|
|
104
|
+
# @overload dim3
|
|
105
|
+
# Returns `shape[3]`, or `nil` if `ndim < 4`.
|
|
106
|
+
# @return [Integer, nil]
|
|
107
|
+
def dim3; end
|
|
108
|
+
|
|
109
|
+
# @overload parent
|
|
110
|
+
# Returns the parent CArray of `self`, or `nil` if `self` has no
|
|
111
|
+
# parent (i.e. is an entity).
|
|
112
|
+
# @return [CArray, nil]
|
|
113
|
+
def parent; end
|
|
114
|
+
|
|
115
|
+
# @overload root_array
|
|
116
|
+
# Returns the array at the root of the view chain (the entity).
|
|
117
|
+
# Returns `self` if `self` is already an entity.
|
|
118
|
+
# @return [CArray]
|
|
119
|
+
def root_array; end
|
|
120
|
+
|
|
121
|
+
# @overload ancestors
|
|
122
|
+
# Returns the list of arrays in the view chain, ordered from root
|
|
123
|
+
# to `self`.
|
|
124
|
+
# @return [Array<CArray>]
|
|
125
|
+
def ancestors; end
|
|
126
|
+
|
|
127
|
+
# @!group Type inquiry
|
|
128
|
+
|
|
129
|
+
# @overload data_class
|
|
130
|
+
# Returns the `data_class` of `self` if it is a Face that carries
|
|
131
|
+
# one (e.g. `CARecord`). Returns `nil` for non-Face arrays.
|
|
132
|
+
# @return [Class, nil]
|
|
133
|
+
def data_class; end
|
|
134
|
+
|
|
135
|
+
# @overload data_class=(klass)
|
|
136
|
+
# Always raises. `data_class` now lives on the Face tail
|
|
137
|
+
# (`CARecord`); use `CARecord.new(klass, *shape)` or
|
|
138
|
+
# `CARecord.wrap(entity, klass)` instead.
|
|
139
|
+
# @param klass [Class] unused.
|
|
140
|
+
# @return [void]
|
|
141
|
+
# @raise [ArgumentError] always.
|
|
142
|
+
def data_class=(klass); end
|
|
143
|
+
|
|
144
|
+
# @!endgroup
|
|
145
|
+
|
|
146
|
+
# @!group State inquiry
|
|
147
|
+
|
|
148
|
+
# @overload scalar?
|
|
149
|
+
# Returns `true` if `self` is a {CScalar}.
|
|
150
|
+
# @return [Boolean]
|
|
151
|
+
def scalar?; end
|
|
152
|
+
|
|
153
|
+
# @overload entity?
|
|
154
|
+
# Returns `true` if `self` is an entity array (not a virtual
|
|
155
|
+
# view).
|
|
156
|
+
# @return [Boolean]
|
|
157
|
+
def entity?; end
|
|
158
|
+
|
|
159
|
+
# @overload virtual?
|
|
160
|
+
# Returns `true` if `self` is a virtual array (a view, not an
|
|
161
|
+
# entity).
|
|
162
|
+
# @return [Boolean]
|
|
163
|
+
def virtual?; end
|
|
164
|
+
|
|
165
|
+
# @overload attached?
|
|
166
|
+
# Returns `true` if `self` is currently attached
|
|
167
|
+
# (`ptr != NULL`).
|
|
168
|
+
# @return [Boolean]
|
|
169
|
+
def attached?; end
|
|
170
|
+
|
|
171
|
+
# @overload empty?
|
|
172
|
+
# Returns `true` if `self` has zero elements.
|
|
173
|
+
# @return [Boolean]
|
|
174
|
+
def empty?; end
|
|
175
|
+
|
|
176
|
+
# @overload read_only?
|
|
177
|
+
# Returns `true` if `self` is read-only.
|
|
178
|
+
# @return [Boolean]
|
|
179
|
+
def read_only?; end
|
|
180
|
+
|
|
181
|
+
# @overload mask_array?
|
|
182
|
+
# Returns `true` if `self` is itself a mask array. (Not the same
|
|
183
|
+
# as "a masked array"; for that see {#has_mask?}.)
|
|
184
|
+
# @return [Boolean]
|
|
185
|
+
def mask_array?; end
|
|
186
|
+
|
|
187
|
+
# @overload value_array?
|
|
188
|
+
# Returns `true` if `self` is a value array (the `.value` view of
|
|
189
|
+
# a masked array).
|
|
190
|
+
# @return [Boolean]
|
|
191
|
+
def value_array?; end
|
|
192
|
+
|
|
193
|
+
# @!group Type inquiry
|
|
194
|
+
|
|
195
|
+
# @overload face?
|
|
196
|
+
# Returns `true` if `self` is a Face view (`CA_FLAG_IS_FACE`
|
|
197
|
+
# set).
|
|
198
|
+
# @return [Boolean]
|
|
199
|
+
def face?; end
|
|
200
|
+
|
|
201
|
+
# @overload has_data_class?
|
|
202
|
+
# Returns `true` if `self` carries a `data_class` (i.e. is a Face
|
|
203
|
+
# such as `CARecord`).
|
|
204
|
+
# @return [Boolean]
|
|
205
|
+
def has_data_class?; end
|
|
206
|
+
|
|
207
|
+
# @overload fixlen?
|
|
208
|
+
# Returns `true` if `self` is a fixed-length type array.
|
|
209
|
+
# @return [Boolean]
|
|
210
|
+
def fixlen?; end
|
|
211
|
+
|
|
212
|
+
# @overload boolean?
|
|
213
|
+
# Returns `true` if `self` is a boolean type array.
|
|
214
|
+
# @return [Boolean]
|
|
215
|
+
def boolean?; end
|
|
216
|
+
|
|
217
|
+
# @overload numeric?
|
|
218
|
+
# Returns `true` if `self` is a numeric type array (any integer,
|
|
219
|
+
# float, or complex type).
|
|
220
|
+
# @return [Boolean]
|
|
221
|
+
def numeric?; end
|
|
222
|
+
|
|
223
|
+
# @overload integer?
|
|
224
|
+
# Returns `true` if `self` is an integer type array (signed or
|
|
225
|
+
# unsigned, any width).
|
|
226
|
+
# @return [Boolean]
|
|
227
|
+
def integer?; end
|
|
228
|
+
|
|
229
|
+
# @overload float?
|
|
230
|
+
# Returns `true` if `self` is a floating-point type array.
|
|
231
|
+
# @return [Boolean]
|
|
232
|
+
def float?; end
|
|
233
|
+
|
|
234
|
+
# @overload complex?
|
|
235
|
+
# Returns `true` if `self` is a complex type array.
|
|
236
|
+
# @return [Boolean]
|
|
237
|
+
def complex?; end
|
|
238
|
+
|
|
239
|
+
# @overload object?
|
|
240
|
+
# Returns `true` if `self` is an object type array
|
|
241
|
+
# (`data_type == :object`).
|
|
242
|
+
# @return [Boolean]
|
|
243
|
+
def object?; end
|
|
244
|
+
|
|
245
|
+
# @!endgroup
|
|
246
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# DOCUMENTATION ONLY — DO NOT REQUIRE.
|
|
2
|
+
# Stubs for methods defined in ext/carray_broadcast.c.
|
|
3
|
+
# See yard-stubs/README.md and yard-stubs/STYLE.md.
|
|
4
|
+
|
|
5
|
+
class CArray
|
|
6
|
+
# @!group Views
|
|
7
|
+
|
|
8
|
+
# @overload broadcast_to(*shape)
|
|
9
|
+
# Returns a read-only `CARepeat` view of `self` whose shape is
|
|
10
|
+
# `shape`. Axes are paired right-to-left:
|
|
11
|
+
#
|
|
12
|
+
# - matching extents reuse the source stride
|
|
13
|
+
# - target extent `> 1` against source extent `1` repeats with
|
|
14
|
+
# stride `0`
|
|
15
|
+
# - extra leading target axes require the corresponding source
|
|
16
|
+
# axis to be `1` (otherwise raises)
|
|
17
|
+
#
|
|
18
|
+
# `CScalar` sources broadcast to any target shape with all
|
|
19
|
+
# strides `0`.
|
|
20
|
+
#
|
|
21
|
+
# The result is read-only because writes against a stride-0
|
|
22
|
+
# axis would be ambiguous.
|
|
23
|
+
# @param shape [Array<Integer>] target shape, with
|
|
24
|
+
# `length >= self.ndim`.
|
|
25
|
+
# @return [CArray]
|
|
26
|
+
# @raise [RuntimeError] if a source axis cannot be paired with a
|
|
27
|
+
# target axis (cross-ndim expansion is intentionally strict —
|
|
28
|
+
# see {CArray.broadcast} for the explicit-`:_` / `:*` axis
|
|
29
|
+
# declaration form).
|
|
30
|
+
# @example
|
|
31
|
+
# a = CArray.float64(3) { [1.0, 2.0, 3.0] }
|
|
32
|
+
# a.broadcast_to(2, 3).to_a
|
|
33
|
+
# # => [[1.0, 2.0, 3.0], [1.0, 2.0, 3.0]]
|
|
34
|
+
def broadcast_to(*shape); end
|
|
35
|
+
|
|
36
|
+
# @!endgroup
|
|
37
|
+
end
|