rserve-client 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/History.txt +3 -0
- data/lib/rserve.rb +1 -1
- data/lib/rserve/packet.rb +1 -0
- data/lib/rserve/protocol.rb +1 -0
- data/lib/rserve/protocol/rexpfactory.rb +11 -2
- data/lib/rserve/rexp/double.rb +3 -1
- data/spec/rserve_connection_spec.rb +28 -0
- data/spec/rserve_double_spec.rb +0 -3
- data/spec/rserve_rexp_wrapper_spec.rb +0 -1
- data/spec/rserve_rexpfactory_spec.rb +2 -2
- metadata +3 -3
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/History.txt
CHANGED
data/lib/rserve.rb
CHANGED
data/lib/rserve/packet.rb
CHANGED
data/lib/rserve/protocol.rb
CHANGED
@@ -209,6 +209,7 @@ module Rserve
|
|
209
209
|
def longBitsToDouble(bits)
|
210
210
|
(bits==LONG_NA) ? Rserve::REXP::Double::NA : [bits].pack("Q").unpack("d")[0]
|
211
211
|
end
|
212
|
+
|
212
213
|
# Complete version of longBitsToDouble, as Java documentation established
|
213
214
|
def longBitsToDouble_old(bits) # :nodoc:
|
214
215
|
s = ((bits >> 63) == 0) ? 1 : -1;
|
@@ -80,6 +80,7 @@ module Rserve
|
|
80
80
|
STDERR.puts("Warning: #{type} SEXP size mismatch")
|
81
81
|
end
|
82
82
|
def initialize(*args)
|
83
|
+
@attr=nil
|
83
84
|
if args.size==0
|
84
85
|
|
85
86
|
elsif
|
@@ -563,6 +564,7 @@ module Rserve
|
|
563
564
|
elsif(rxt==XT_INT)
|
564
565
|
set_int(cont.as_integer, buf, off)
|
565
566
|
elsif(rxt==XT_DOUBLE)
|
567
|
+
|
566
568
|
set_long(doubleToRawLongBits(cont.as_double), buf, off)
|
567
569
|
elsif(rxt==XT_ARRAY_INT)
|
568
570
|
ia=cont.as_integers
|
@@ -585,10 +587,17 @@ module Rserve
|
|
585
587
|
end
|
586
588
|
|
587
589
|
elsif(rxt==XT_ARRAY_DOUBLE)
|
588
|
-
da=cont.
|
590
|
+
da=cont.payload
|
589
591
|
io=off
|
590
592
|
da.each do |v|
|
591
|
-
|
593
|
+
# HACK
|
594
|
+
# On i686, NA returns [162, 7, 0, 0, 0, 0, 240, 127]
|
595
|
+
# So if we got a Double::NA, we should set mannualy this array
|
596
|
+
if v==REXP::Double::NA
|
597
|
+
buf[io,8]=REXP::Double::NA_ARRAY
|
598
|
+
else
|
599
|
+
set_long(doubleToRawLongBits(v), buf, io)
|
600
|
+
end
|
592
601
|
io+=8
|
593
602
|
end
|
594
603
|
elsif(rxt==XT_RAW)
|
data/lib/rserve/rexp/double.rb
CHANGED
@@ -10,7 +10,9 @@ module Rserve
|
|
10
10
|
else
|
11
11
|
NA = 0x100000000007a2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
|
+
NA_ARRAY=[162, 7, 0, 0, 0, 0, 240, 127]
|
15
|
+
|
14
16
|
def initialize(data, attrs=nil)
|
15
17
|
@payload=case data
|
16
18
|
when Numeric
|
@@ -50,6 +50,11 @@ describe Rserve::Connection do
|
|
50
50
|
@r.assign("x","a string")
|
51
51
|
@r.eval("x").to_ruby.should=="a string"
|
52
52
|
end
|
53
|
+
it "should assign an array with nils values" do
|
54
|
+
|
55
|
+
@r.assign('x',[1.0,2.5,nil])
|
56
|
+
@r.eval('x').to_ruby.should==[1.0,2.5,nil]
|
57
|
+
end
|
53
58
|
|
54
59
|
end
|
55
60
|
describe "assign using REXPs" do
|
@@ -64,7 +69,30 @@ describe Rserve::Connection do
|
|
64
69
|
@r.assign("x", rexp)
|
65
70
|
@r.eval("x").should==rexp
|
66
71
|
end
|
72
|
+
it "should assign a double with nils and set correctly the nils" do
|
73
|
+
rexp=Rserve::REXP::Double.new([1.5, Rserve::REXP::Double::NA, -1.5])
|
74
|
+
@r.assign("x", rexp)
|
75
|
+
@r.eval('is.na(x)').to_ruby.should==[false,true,false]
|
76
|
+
end
|
77
|
+
it "should assign a integer with nils and set correctly the nils" do
|
78
|
+
rexp=Rserve::REXP::Integer.new([1, Rserve::REXP::Integer::NA, 2])
|
79
|
+
@r.assign("x", rexp)
|
80
|
+
@r.eval('is.na(x)').to_ruby.should==[false,true,false]
|
81
|
+
end
|
67
82
|
|
83
|
+
|
84
|
+
it "should assign a double with nils and return correct values" do
|
85
|
+
rexp=Rserve::REXP::Double.new([1.5,Rserve::REXP::Double::NA, -1.5])
|
86
|
+
@r.assign("x", rexp)
|
87
|
+
rexp_out=@r.eval("x")
|
88
|
+
rexp_out.payload.should==rexp.payload
|
89
|
+
end
|
90
|
+
it "should assign a integer with nils and return correct values" do
|
91
|
+
rexp=Rserve::REXP::Integer.new([1,Rserve::REXP::Integer::NA, 2])
|
92
|
+
@r.assign("x", rexp)
|
93
|
+
rexp_out=@r.eval("x")
|
94
|
+
rexp_out.payload.should==rexp.payload
|
95
|
+
end
|
68
96
|
it "should assign a null" do
|
69
97
|
rexp=Rserve::REXP::Null.new
|
70
98
|
@r.assign("x", rexp)
|
data/spec/rserve_double_spec.rb
CHANGED
@@ -55,9 +55,9 @@ 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,NA)")
|
58
|
+
la=@r.eval("c(1.0,2.0, NA)")
|
59
59
|
la.should be_instance_of(Rserve::REXP::Double)
|
60
|
-
la.na?.should==[false,true]
|
60
|
+
la.na?.should==[false,false,true]
|
61
61
|
|
62
62
|
end
|
63
63
|
it "should process string vector" do
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 3
|
9
|
+
version: 0.2.3
|
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-
|
38
|
+
date: 2010-07-02 00:00:00 -04:00
|
39
39
|
default_executable:
|
40
40
|
dependencies:
|
41
41
|
- !ruby/object:Gem::Dependency
|
metadata.gz.sig
CHANGED
Binary file
|