rserve-client 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,6 @@
1
+ === 0.2.4 / 2010-07-06
2
+ * Bug fixes: double vector with NaN crash to_ruby. Data frame with string row_names crash to_rubyC
3
+
1
4
  === 0.2.3 / 2010-07-02
2
5
  * Bug fix: assignation of double vector with NA doesn't work right
3
6
 
@@ -1,7 +1,7 @@
1
1
  require 'socket'
2
2
  require 'rbconfig'
3
3
  module Rserve
4
- VERSION = '0.2.3'
4
+ VERSION = '0.2.4'
5
5
  ON_WINDOWS=RbConfig::CONFIG['arch']=~/mswin|mingw/
6
6
  end
7
7
 
@@ -406,7 +406,7 @@ module Rserve
406
406
  end
407
407
 
408
408
  # Hack: change attribute row.names according to spec
409
- if !attr.nil? and attr.as_list.has_name? 'class' and attr.as_list['class'].as_string=='data.frame' and attr.as_list['row.names'].as_integers[0]==REXP::Integer::NA
409
+ if !attr.nil? and attr.as_list.has_name? 'class' and attr.as_list['class'].as_string=='data.frame' and (attr.as_list['row.names'].is_a?(REXP::Integer)) and attr.as_list['row.names'].as_integers[0]==REXP::Integer::NA
410
410
  v.attributes['row.names']=(1..(-attr.as_list['row.names'].as_integers[1])).to_a
411
411
  end
412
412
 
@@ -49,8 +49,8 @@ module Rserve
49
49
  #else
50
50
  # value.respond_to? :nan? and value.nan?
51
51
  #end
52
- return value.to_i == NA unless value.nil?
53
- @payload.map {|v| v.to_i==NA}
52
+ return ((value.is_a? Float and value.nan?) or value.to_i==NA) unless value.nil?
53
+ @payload.map {|v| ((v.is_a? Float and v.nan?) or v.to_i==NA)}
54
54
  end
55
55
  def to_debug_string
56
56
  t=super
@@ -55,9 +55,21 @@ describe Rserve::Protocol::REXPFactory do
55
55
  la.as_integers.should==(-10..10).to_a
56
56
  end
57
57
  it "should process double vector with NA" do
58
- la=@r.eval("c(1.0,2.0, NA)")
58
+ la=@r.eval("c(0.03091136, NA, 0.07456851, 0.90000000)")
59
59
  la.should be_instance_of(Rserve::REXP::Double)
60
- la.na?.should==[false,false,true]
60
+ la.na?.should==[false,true, false, false]
61
+ end
62
+ it "should process double vector with NaN" do
63
+ la=@r.eval("c(NaN,1.3)")
64
+ la.should be_instance_of(Rserve::REXP::Double)
65
+ la.na?.should==[true,false]
66
+ end
67
+ it "should process list with double vectors with NA" do
68
+ la=@r.eval("list(RMSE=c(0.03091136, NA, 0.07456851, 0.90000000))")
69
+ vector=la.as_list[0]
70
+ vector.should be_instance_of(Rserve::REXP::Double)
71
+ vector.na?.should==[false,true, false, false]
72
+
61
73
 
62
74
  end
63
75
  it "should process string vector" do
@@ -121,6 +133,16 @@ describe Rserve::Protocol::REXPFactory do
121
133
  la.attr.as_list['class'].to_ruby.should=="data.frame"
122
134
  la.attr.as_list['row.names'].to_ruby.should==[nil,-10]
123
135
  end
136
+ it "should process data.frame with string row.names" do
137
+ @r.void_eval("df<-data.frame(a=1:10,b=1:10);
138
+ attr(df,'row.names')<-c('a','b','c',4,5,6,7,8,9,10);")
139
+ la=@r.eval("df")
140
+ la.should be_true
141
+ la.attr.as_list['names'].to_ruby.should==%w{a b}
142
+ la.attr.as_list['class'].to_ruby.should=="data.frame"
143
+ la.attr.as_list['row.names'].to_ruby.should==%w{a b c 4 5 6 7 8 9 10}
144
+ end
145
+
124
146
  it "should process a nested array" do
125
147
  @r.void_eval("c=1:8; attr(c,'dim')<-c(2,2,2)")
126
148
  la=@r.eval("c")
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 3
9
- version: 0.2.3
8
+ - 4
9
+ version: 0.2.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Claudio Bustos
@@ -35,7 +35,7 @@ cert_chain:
35
35
  rpP0jjs0
36
36
  -----END CERTIFICATE-----
37
37
 
38
- date: 2010-07-02 00:00:00 -04:00
38
+ date: 2010-07-06 00:00:00 -04:00
39
39
  default_executable:
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
metadata.gz.sig CHANGED
Binary file