rserve-simpler 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
@@ -15,7 +15,8 @@ module Rserve
15
15
  # takes an array of structs and returns a data frame object
16
16
  def self.from_structs(array)
17
17
  names = array.first.members
18
- lengthwise_arrays = names.map { Array.new(names.size) }
18
+ size = array.length
19
+ lengthwise_arrays = names.map { Array.new(size) } # This is where the nil value is created!!
19
20
  array.each_with_index do |struct,m|
20
21
  struct.values.each_with_index do |val,n|
21
22
  lengthwise_arrays[n][m] = val
@@ -103,6 +103,9 @@ if RUBY_VERSION > '1.9'
103
103
  @hash = {:fac1 => [1,2,3,4], :var1 => [4,5,6,7], :res1 => [8,9,10,11]}
104
104
  @colnames = %w(fac1 var1 res1).map(&:to_sym)
105
105
  @ar_of_structs = [Row.new(1,4,8), Row.new(2,5,9), Row.new(3,6,10), Row.new(4,7,11)]
106
+ @ar_of_structs_makes_nils = [Row.new(1,4,8), Row.new(2,5,9)]
107
+ @hash2 = {:fac1 => [1,2], :var1 => [4,5], :res1 => [8,9]}
108
+
106
109
  end
107
110
 
108
111
  after do
@@ -134,6 +137,11 @@ if RUBY_VERSION > '1.9'
134
137
  df.is @hash.to_dataframe
135
138
  end
136
139
 
140
+ it 'converts an array of parallel structs into a dataframe without generating nils' do
141
+ df = Rserve::DataFrame.from_structs( @ar_of_structs_makes_nils )
142
+ df.is @hash2.to_dataframe
143
+ end
144
+
137
145
  it 'accepts simple dataframes when conversing with R' do
138
146
  @r.converse(:df => @hash.to_dataframe) { "names(df)" }.is %w(fac1 var1 res1)
139
147
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 3
9
- version: 0.0.3
8
+ - 4
9
+ version: 0.0.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - John Prince
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-02-15 00:00:00 -07:00
17
+ date: 2011-03-03 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -127,7 +127,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
127
127
  requirements:
128
128
  - - ">="
129
129
  - !ruby/object:Gem::Version
130
- hash: 3062815084109637570
130
+ hash: -406521964708249853
131
131
  segments:
132
132
  - 0
133
133
  version: "0"