class GraphKit::AxisKit
Constants
- AXES
Public Class Methods
autocreate(hash)
click to toggle source
# File lib/graphkit.rb, line 871 def self.autocreate(hash) new_kit = new(hash) new_kit.label = "#{new_kit.title} (#{new_kit.units})" new_kit end
new(hash = {})
click to toggle source
attr_accessor :labels, :ranges, :has_legend, :units, :dimensions
Calls superclass method
# File lib/graphkit.rb, line 851 def initialize(hash = {}) super() self.title = "" self.units = "" self. absorb hash end
Public Instance Methods
check_integrity()
click to toggle source
# File lib/graphkit.rb, line 859 def check_integrity check(['units.class', [String]], ['scaling.class', [Float, NilClass]], ['label.class', [String, NilClass]], ['title.class', [String]]) check(['data.to_a.class', Array]) end
dup()
click to toggle source
# File lib/graphkit.rb, line 864 def dup # puts 'i was called' new = self.class.new(self) new.data = data.dup new end
extend_using(other)
click to toggle source
def data_for_gnuplot(rank)
case rank when 0, 1 return data when Fixnum if shape.size == 1 return SparseTensor.diagonal(rank, data) else return data end else raise TypeError("Bad Rank") end
end
# File lib/graphkit.rb, line 906 def extend_using(other) raise TypeError.new("Can only extend axes if data have the same ranks: #{shape.size}, #{other.shape.size}") unless shape.size == other.shape.size raise TypeError.new("Can only extend axes if data have the same class") unless data.class == other.data.class case shape.size when 1 desired_length = shape[0] + other.shape[0] if data.methods.include? :connect self.data = data.connect(other.data) elsif data.methods.include? "+".to_sym data += other else raise TypeError("Extending this type of data is currently not implemented.") end raise "Something went wrong: the length of the extended data #{shape[0]} is not the sum of the lengths of the two original pieces of data #{desired_length}." unless shape[0] == desired_length else raise TypeError("Extending data with this rank: #{shape.size} is currently not implemented.") end end
shape()
click to toggle source
# File lib/graphkit.rb, line 877 def shape logf :shape if data.methods.include? :shape ans = data.shape elsif data.methods.include? :size ans = [data.size] elsif data.methods.include? :dimensions ans = data.dimensions else raise 'data does not implement size or shape or dimensions methods' end logfc :shape return ans end