Sha256: b377faaa05e7146860490a90f8610d652915f9b5f6b682deab73f5c970d739cb
Contents?: true
Size: 1.15 KB
Versions: 2
Compression:
Stored size: 1.15 KB
Contents
require_relative 'column' class ObjectTable::MaskedColumn < NArray attr_accessor :indices, :parent EMPTY = NArray[] def self.mask(parent, indices) if parent.empty? masked = parent.slice(indices) else masked = parent.slice(false, indices) end if masked.rank <= 0 column = self.new(masked.typecode, 0) else column = self.cast(masked) end column.parent = parent column.indices = indices column end def []=(*keys, value) unless parent.nil? or ((value.is_a?(Array) or value.is_a?(NArray)) and value.empty?) parent[false, indices[*keys]] = value end super end # make destructive methods affect parent %w{ fill! indgen! indgen random! map! collect! conj! imag= mod! add! div! sbt! mul! }.each do |op| define_method(op) do |*args, &block| result = super(*args, &block) parent[false, indices] = result if parent result end end def clone return NArray.new(typecode, 0) if empty? NArray.cast(self).clone end def coerce_rev(other, operator) return other.send(operator, EMPTY) if empty? other.send(operator, NArray.cast(self)) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
object_table-0.3.4 | lib/object_table/masked_column.rb |
object_table-0.3.3 | lib/object_table/masked_column.rb |