Class: Rust::RustDatatype
Direct Known Subclasses
ANOVAModel, Call, DataFrame, Environment, Factor, Formula, List, Matrix, Models::Regression::RegressionModel, Null, S4Class, Sequence
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.pull_priority ⇒ Object
39
40
41
|
# File 'lib/rust/core/types/datatype.rb', line 39
def self.pull_priority
0
end
|
.pull_variable(variable, forced_interpreter = nil) ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/rust/core/types/datatype.rb', line 5
def self.pull_variable(variable, forced_interpreter = nil)
r_type = Rust._pull("as.character(typeof(#{variable}))")
r_class = Rust._pull("as.character(class(#{variable}))")
if forced_interpreter
raise ArgumentError, "Expected null or class as forced_interpreter" if forced_interpreter && !forced_interpreter.is_a?(Class)
raise ArgumentError, "Class #{forced_interpreter} can not handle type #{r_type}, class #{r_class}" unless forced_interpreter.can_pull?(r_type, r_class)
return forced_interpreter.pull_variable(variable, r_type, r_class)
end
candidates = []
ObjectSpace.each_object(Class) do |type|
if type < RustDatatype
if type.can_pull?(r_type, r_class)
candidates << type
end
end
end
if candidates.size > 0
type = candidates.max_by { |c| c.pull_priority }
puts "Using #{type} to pull #{variable}" if Rust.debug?
return type.pull_variable(variable, r_type, r_class)
else
if Rust._pull("length(#{variable})") == 0
return []
else
return Rust._pull(variable)
end
end
end
|
Instance Method Details
#load_in_r_as(variable_name) ⇒ Object
43
44
45
|
# File 'lib/rust/core/types/datatype.rb', line 43
def load_in_r_as(variable_name)
raise "Loading #{self.class} in R was not implemented"
end
|
70
71
72
|
# File 'lib/rust/core/types/datatype.rb', line 70
def r_hash
self.hash.to_s
end
|
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/rust/core/types/datatype.rb', line 56
def r_mirror
varname = self.mirrored_R_variable_name
if !Rust._pull("exists(\"#{varname}\")") || Rust._pull("#{varname}.hash") != self.r_hash
puts "Loading #{varname}" if Rust.debug?
Rust[varname] = self
Rust["#{varname}.hash"] = self.r_hash
else
puts "Using cached value for #{varname}" if Rust.debug?
end
return varname
end
|
#r_mirror_to(other_variable) ⇒ Object
47
48
49
50
51
52
53
54
|
# File 'lib/rust/core/types/datatype.rb', line 47
def r_mirror_to(other_variable)
varname = self.mirrored_R_variable_name
Rust._eval("#{varname} = #{other_variable}")
Rust["#{varname}.hash"] = self.r_hash
return varname
end
|