Class: CALazyMarker

Inherits:
CAView show all
Defined in:
yard-stubs/carray_lazy.rb,
lib/carray/lazy.rb,
yard-stubs/carray_lazy.rb

Overview

Zero-cost marker view that dispatches subsequent element-wise ops into the lazy CAMonOp / CABinOp tree instead of evaluating eagerly. Read-only; .to_ca materialises.

Constant Summary

Constants inherited from CArray

CArray::HAVE_COMPLEX, CArray::LAZY_BINCMP_OP_IDS, CArray::LAZY_BINCMP_TOL_OP_IDS, CArray::LAZY_BINOP_OP_IDS, CArray::LAZY_MONOP_OP_IDS, CArray::LAZY_TRIOP_OP_IDS, CArray::UNSPECIFIED, CArray::VERSION

Copy and conversion collapse

Methods inherited from CArray

#convert, #dump_binary, #load_binary, #template

Instance Method Summary collapse

Methods inherited from CArray

#%, #&, #*, #**, #+, #-, #-@, #/, #<, #<<, #<=, #<=>, #==, #>, #>=, #>>, #T, #[], #[]=, #^, _scan_float, _scan_int, #abs, #abs!, #abs_i, #abs_i!, #acos, #acos!, #acosh, #acosh!, #add, #add!, #addr2index, addr2index, #address, align_addr, align_nearest_addr, #all, #all_masked?, #ancestors, #and, #and!, #any, #any_masked?, #arg, #arg!, #as_boolean, #as_byte, #as_cmplx128, #as_cmplx256, #as_cmplx64, #as_complex, #as_dcomplex, #as_double, #as_fixlen, #as_float, #as_float128, #as_float32, #as_float64, #as_int, #as_int16, #as_int32, #as_int64, #as_int8, #as_object, #as_short, #as_strided, #as_type, #as_uint16, #as_uint32, #as_uint64, #as_uint8, #asin, #asin!, #asinh, #asinh!, #atan, #atan!, #atan2, #atan2!, #atanh, #atanh!, #attached?, #attr, #attrs, #axis2addr, #axis_group, big_endian?, #bin, #bin_to, #bincount, #bincount_nd, #bit_and, #bit_lshift, #bit_lshift!, #bit_neg, #bit_neg!, #bit_or, #bit_rshift, #bit_rshift!, #bit_xor, #bitarray, #bitfield, #bits, #block_view, #blocks, #boolean, boolean, #boolean?, #broadcast_to, #bsearch, #bsearch_addr, byte, #byte, #bytes, cast, #cast_with, #categorize, #ceil, #ceil!, #choose, #clip, #clip_int16, #clip_int32, #clip_int64, #clip_int8, #clip_uint16, #clip_uint32, #clip_uint64, #clip_uint8, cmplx128, #cmplx128, cmplx64, #cmplx64, #coerce, #collect!, #collect_addr!, #collect_index!, #collect_with_addr!, #collect_with_index!, #complex, complex, #complex?, concatenate, #concatenate, #conditional, #conj, #conj!, const_string, #copysign, #copysign!, #cos, #cos!, #cosh, #cosh!, #count, #count_masked, #count_not_masked, #crop, #data_class, #data_class=, #data_type, data_type_code, data_type_name, #data_type_name, dcomplex, #dcomplex, #deg, #deg!, #deg_180, #deg_180!, #deg_360, #deg_360!, #delete_block, #diagonal, #difference, #dim, #dim0, #dim1, #dim2, #dim3, #dim_view, #div, #div!, #divmod, #double, double, #drop_axis, dump, #each_addr, each_index, #each_index, #each_slab, #each_with_addr, #each_with_index, #elem_copy, #elem_decr, #elem_fetch, #elem_incr, #elem_mask, #elem_masked?, #elem_max, #elem_min, #elem_store, #elem_swap, #elem_unmask, #elements, empty, #empty?, endian, #endian, #entity?, #eq, #eql?, #exp, #exp!, #exp10, #exp10!, #exp2, #exp2!, #expm1, #expm1!, #face?, #factorize, #fake, #false, #farray, #feq, #field, #fields, #fields_at, #fill, #fill_copy, #first, #fixlen, fixlen, #fixlen?, fixlen_string, #flags, #flatten, #flip, #float, float, #float32, float32, #float64, float64, #float?, #floor, #floor!, #fma, #fma!, #fmax, #fmin, #fmod, #fmod!, #fms, #fms!, format, #format, #frac, #freeze, from_bit_string, #from_bit_string, from_memory_view, fuse, #gather_nd, #ge, #grid, #group_by_category, #group_by_run, #gt, guard_undef, guess_type_and_bytes, #has_attr?, #has_data_class?, #has_mask?, #hash, #histogram, #histogram1d, #histogram2d, #hypot, #hypot!, #imag, #imag=, #imag_i, #imag_i!, #index, index2addr, #index2addr, #indices, #inherit_mask, #inherit_mask_replace, #initialize, #initialize_copy, #insert_axis, #insert_block, #inspect_full, #int, int, #int16, int16, #int32, int32, int64, #int64, #int8, int8, #integer?, #intersection, #invert_mask, #is_close, #is_equiv, #is_finite, #is_in, #is_inf, #is_invalid, #is_masked, #is_mode, #is_nan, #is_not_masked, #is_real, #join, #last, #lazy, #le, #length, #linear_fetch, #linear_section, little_endian?, load, load_arrow_tensor, #locate_addr, #locate_nearest_addr, #log, #log!, #log10, #log10!, #log1p, #log1p!, #log2, #log2!, #logaddexp, #logaddexp!, #logb, #logb!, #lookup, #lt, #map!, #map_addr!, #map_index!, #map_slab, #map_with_addr!, #map_with_index!, #marshal_dump, #marshal_load, #mask, #mask=, #mask_array?, #mask_duplicates, #mask_eq, #mask_invalid, #mask_where, #maximum, #maximum!, #median, meld, #meld, #members, memory_view_available?, memory_view_reject_reason, meshgrid, #minimum, #minimum!, #mod, #mod!, #mode, montage, mosaic, #mul, #mul!, #ndim, #ne, #neg, #neg!, #nextafter, #nextafter!, #none, #normalize_axes, #normalize_axis, normalize_axis, #normalize_index, #not, #not!, #numeric?, #nunique, #obj_type, #object, object, #object?, #one, #one!, #or, #or!, #order, #pack_bits, #parent, #partition, #partition_copy, #paste, #percentile, #pmax, #pmax!, #pmin, #pmin!, #pow, #power, #power!, #project, promote_list, #put_nd, #quantile, #rad, #rad!, #rad_2pi, #rad_2pi!, #rad_pi, #rad_pi!, #random, #random!, #randomn, #randomn!, #rank, #rcp, #rcp!, #rcp_mul, #rcp_mul!, #read_only?, #real, #real=, #real?, #reduce_slab, #refer, #repeat, #replace_where, #reshape, #resize, result_type, #roll, #root_array, #round, #rsqrt, #rsqrt!, #same_shape?, save, #save_arrow_tensor, #scalar?, #scale, #scale!, #scatter_add!, #scatter_max!, #scatter_min!, #scatter_mul!, #scatter_replace!, #scatter_sub!, #search, #search_addr, #search_nearest, #search_nearest_addr, select, #seq, #seq!, #set_attr, #set_read_only_flag, #shape, #shift, short, #short, #shuffle, #shuffle!, #sign, #sign!, #signbit, #sin, #sin!, #sinh, #sinh!, #size, sizeof, #sliding_windows, #snap, #snap_to, #sort, #sort_addr, sort_addr, #sort_copy, #source_code, #span, #span!, #split, #sqrt, #sqrt!, #square, #square!, #st, #stack, stack, string, #strip_mask, struct, #sub, #sub!, #swap_bytes, tabulate, #tan, #tan!, #tanh, #tanh!, #then_else, #tile, #time, time, time_range, time_series, #timedelta, #to_bit_string, #to_type, #transpose, #true, #trunc, #trunc!, uint16, #uint16, uint32, #uint32, uint64, #uint64, uint8, #uint8, #unfold, #union, union, #unique, #unmask, #valid_addr?, #valid_index?, #validity_bits, #value, #value_array?, #value_counts, #virtual?, #where, #window, #windows, wrap, wrap_memory_view, wrap_readonly, wrap_writable, #xor, #xor!, #zero, #zero!, #|, #~

Methods included from CArray::DataTypeExtension

#arange, #empty, #eye, #full, #identity, #linspace, #ones, #zeros

Constructor Details

This class inherits a constructor from CArray

Instance Method Details

#copy ⇒ CArray

Evaluates the expression and returns the result as a new entity.

If an expression evaluator is registered through CArray.expression_evaluator it is asked first; the ordinary element-wise walk is what happens when it declines, when none is registered, or when the array is small enough that walking is the faster answer.

Returns:

  • (CArray) —

    a newly evaluated entity.



224
# File 'yard-stubs/carray_lazy.rb', line 224

def copy; end

#dump_tree(indent = 0) ⇒ String

Returns an ASCII summary of the marker and its parent entity.

Returns:

  • (String)


753
754
755
756
757
# File 'lib/carray/lazy.rb', line 753

def dump_tree(indent = 0)
  pad = "  " * indent
  "#{pad}lazy(marker)\n" \
    "#{"  " * (indent + 1)}#{parent.class}(#{parent.data_type_name}, #{parent.shape.inspect})\n"
end

#each({ |value| ... }) ⇒ Object

Yields each element of the wrapped entity (no materialise needed).

Returns:

  • (Object)


763
764
765
# File 'lib/carray/lazy.rb', line 763

def each(&block)
  parent.each(&block)
end

#inspect ⇒ String

Returns a short summary showing the wrapped entity.

Returns:

  • (String)


739
740
741
# File 'lib/carray/lazy.rb', line 739

def inspect
  "#<CALazyMarker over #{parent.inspect}>"
end

#to_a ⇒ Array

Returns the wrapped entity's Array.

Returns:



770
771
772
# File 'lib/carray/lazy.rb', line 770

def to_a
  parent.to_a
end

#to_ca ⇒ CArray

Evaluates the expression and returns the result as a new entity.

A lazy marker holds no data of its own, so there is nothing to hand over unevaluated: unlike CArray#to_ca, which returns self, this materialises -- the Ruby Enumerable#to_a / lazy force convention.

The entity is detached from the operands, so writes to it reach nothing. writable: true is therefore refused rather than answered with a result that would swallow them.

Parameters:

  • writable (Boolean) —

    whether the caller needs writes to land back in the source; only false can be satisfied.

Returns:

  • (CArray) —

    a newly evaluated entity.

Raises:

  • (RuntimeError) —

    when writable: true is requested.



213
# File 'yard-stubs/carray_lazy.rb', line 213

def to_ca(writable: false); end

#to_memory_view ⇒ Object

Not supported: markers do not own a backing buffer.

Raises:

  • (TypeError) —

    always; call .copy first.

Raises:

  • (TypeError)


777
778
779
780
781
782
# File 'lib/carray/lazy.rb', line 777

def to_memory_view
  raise TypeError,
        "lazy marker (CALazyMarker) has no backing buffer; call " \
        "`.copy` first to materialise into an entity before " \
        "exporting via MemoryView."
end

#to_s ⇒ String

Alias of #inspect.

Returns:

  • (String)


746
747
748
# File 'lib/carray/lazy.rb', line 746

def to_s
  inspect
end