daru 0.0.3 → 0.0.3.1

Sign up to get free protection for your applications and to get access to all the features.
File without changes
@@ -0,0 +1,5 @@
1
+ require 'spec_helper.rb'
2
+
3
+ describe Daru::DataFrame do
4
+
5
+ end
@@ -0,0 +1,51 @@
1
+ require 'spec_helper.rb'
2
+
3
+ describe Daru::Vector do
4
+ before :each do
5
+ @dv1 = Daru::Vector.new [1,2,3,4], name: :boozy, index: [:bud, :kf, :henie, :corona]
6
+ @dv2 = Daru::Vector.new [1,2,3,4], name: :mayer, index: [:obi, :wan, :kf, :corona]
7
+ end
8
+
9
+ context "#+" do
10
+ it "adds matching indexes of the other vector" do
11
+ expect(@dv1 + @dv2).to eq(Daru::Vector.new([5, 8], name: :boozy, index: [:kf, :corona]))
12
+ end
13
+
14
+ it "adds number to each element of the entire vector" do
15
+ expect(@dv1 + 5).to eq(Daru::Vector.new [6,7,8,9], name: :boozy, index: [:bud, :kf, :henie, :corona])
16
+ end
17
+ end
18
+
19
+ context "#-" do
20
+ it "subtracts matching indexes of the other vector" do
21
+ expect(@dv1 - @dv2).to eq(Daru::Vector.new([-1,0], name: :boozy, index: [:kf, :corona]))
22
+ end
23
+
24
+ it "subtracts number from each element of the entire vector" do
25
+ expect(@dv1 - 5).to eq(Daru::Vector.new [-4,-3,-2,-1], name: :boozy, index: [:bud, :kf, :henie, :corona])
26
+ end
27
+ end
28
+
29
+ context "#*"
30
+ it "multiplies matching indexes of the other vector" do
31
+
32
+ end
33
+
34
+ it "multiplies number to each element of the entire vector" do
35
+
36
+ end
37
+ end
38
+
39
+ context "#\/" do
40
+ it "divides matching indexes of the other vector" do
41
+
42
+ end
43
+
44
+ it "divides number from each element of the entire vector" do
45
+
46
+ end
47
+ end
48
+
49
+ context "#%" do
50
+
51
+ end
@@ -0,0 +1,5 @@
1
+ require 'spec_helper.rb'
2
+
3
+ describe Daru::DataFrame do
4
+
5
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper.rb'
2
+
3
+ describe Daru::Vector do
4
+
5
+ context "#mean" do
6
+
7
+ end
8
+
9
+ context "#median" do
10
+
11
+ end
12
+ end
@@ -3,7 +3,7 @@ require 'spec_helper.rb'
3
3
  describe Daru::Vector do
4
4
  context "#initialize" do
5
5
  it "initializes from an Array" do
6
- dv = Daru::Vector.new :ravan, [1,2,3,4,5], [:ek, :don, :teen, :char, :pach]
6
+ dv = Daru::Vector.new [1,2,3,4,5], name: :ravan, index: [:ek, :don, :teen, :char, :pach]
7
7
 
8
8
  expect(dv.name) .to eq(:ravan)
9
9
  expect(dv.index).to eq(Daru::Index.new [:ek, :don, :teen, :char, :pach])
@@ -12,7 +12,7 @@ describe Daru::Vector do
12
12
  it "accepts Index object" do
13
13
  idx = Daru::Index.new [:yoda, :anakin, :obi, :padme, :r2d2]
14
14
 
15
- dv = Daru::Vector.new :yoga, [1,2,3,4,5], idx
15
+ dv = Daru::Vector.new [1,2,3,4,5], name: :yoga, index: idx
16
16
 
17
17
  expect(dv.name) .to eq(:yoga)
18
18
  expect(dv.index).to eq(idx)
@@ -20,23 +20,23 @@ describe Daru::Vector do
20
20
 
21
21
  it "raises error for improper Index" do
22
22
  expect {
23
- dv = Daru::Vector.new :yoga, [1,2,3,4,5], [:i, :j, :k]
23
+ dv = Daru::Vector.new [1,2,3,4,5], name: :yoga, index: [:i, :j, :k]
24
24
  }.to raise_error
25
25
 
26
26
  expect {
27
27
  idx = Daru::Index.new [:i, :j, :k]
28
- dv = Daru::Vector.new :yoga, [1,2,3,4,5], idx
28
+ dv = Daru::Vector.new [1,2,3,4,5], name: :yoda, index: idx
29
29
  }.to raise_error
30
30
  end
31
31
 
32
32
  it "initializes without specifying an index" do
33
- dv = Daru::Vector.new :vishnu, [1,2,3,4,5]
33
+ dv = Daru::Vector.new [1,2,3,4,5], name: :vishnu
34
34
 
35
35
  expect(dv.index).to eq(Daru::Index.new [0,1,2,3,4])
36
36
  end
37
37
 
38
38
  it "inserts nils for extra indices" do
39
- dv = Daru::Vector.new :yoga, [1,2,3], [0,1,2,3,4]
39
+ dv = Daru::Vector.new [1,2,3], name: :yoga, index: [0,1,2,3,4]
40
40
 
41
41
  expect(dv).to eq([1,2,3,nil,nil].dv(:yoga))
42
42
  end
@@ -44,7 +44,7 @@ describe Daru::Vector do
44
44
 
45
45
  context "#[]" do
46
46
  before :each do
47
- @dv = Daru::Vector.new :yoga, [1,2,3,4,5], [:yoda, :anakin, :obi, :padme, :r2d2]
47
+ @dv = Daru::Vector.new [1,2,3,4,5], name: :yoga, index: [:yoda, :anakin, :obi, :padme, :r2d2]
48
48
  end
49
49
 
50
50
  it "returns an element after passing an index" do
@@ -56,14 +56,14 @@ describe Daru::Vector do
56
56
  end
57
57
 
58
58
  it "returns a vector with given indices for multiple indices" do
59
- expect(@dv[:yoda, :anakin]).to eq(Daru::Vector.new(:yoga, [1,2],
60
- [:yoda, :anakin]))
59
+ expect(@dv[:yoda, :anakin]).to eq(Daru::Vector.new([1,2], name: :yoda,
60
+ index: [:yoda, :anakin]))
61
61
  end
62
62
  end
63
63
 
64
64
  context "#[]=" do
65
65
  before :each do
66
- @dv = Daru::Vector.new :yoga, [1,2,3,4,5], [:yoda, :anakin, :obi, :padme, :r2d2]
66
+ @dv = Daru::Vector.new [1,2,3,4,5], name: :yoga, index: [:yoda, :anakin, :obi, :padme, :r2d2]
67
67
  end
68
68
 
69
69
  it "assigns at the specified index" do
@@ -81,7 +81,7 @@ describe Daru::Vector do
81
81
 
82
82
  context "#concat" do
83
83
  before :each do
84
- @dv = Daru::Vector.new :yoga, [1,2,3,4,5], [:warwick, :thompson, :jackson, :fender, :esp]
84
+ @dv = Daru::Vector.new [1,2,3,4,5], name: :yoga, index: [:warwick, :thompson, :jackson, :fender, :esp]
85
85
  end
86
86
 
87
87
  it "concatenates a new element at the end of vector with index" do
@@ -94,7 +94,7 @@ describe Daru::Vector do
94
94
  end
95
95
 
96
96
  it "concatenates without index if index is default numeric" do
97
- vector = Daru::Vector.new :nums, [1,2,3,4,5]
97
+ vector = Daru::Vector.new [1,2,3,4,5], name: :nums
98
98
 
99
99
  vector.concat 6
100
100
 
@@ -111,35 +111,35 @@ describe Daru::Vector do
111
111
 
112
112
  context "#delete" do
113
113
  it "deletes specified value in the vector" do
114
- dv = Daru::Vector.new :a, [1,2,3,4,5]
114
+ dv = Daru::Vector.new [1,2,3,4,5], name: :a
115
115
 
116
116
  dv.delete 3
117
117
 
118
- expect(dv).to eq(Daru::Vector.new :a, [1,2,4,5])
118
+ expect(dv).to eq(Daru::Vector.new [1,2,4,5], name: :a)
119
119
  end
120
120
  end
121
121
 
122
122
  context "#delete_at" do
123
123
  before :each do
124
- @dv = Daru::Vector.new :a, [1,2,3,4,5], [:one, :two, :three, :four, :five]
124
+ @dv = Daru::Vector.new [1,2,3,4,5], name: :a, index: [:one, :two, :three, :four, :five]
125
125
  end
126
126
 
127
127
  it "deletes element of specified index" do
128
128
  @dv.delete_at :one
129
129
 
130
- expect(@dv).to eq(Daru::Vector.new :a, [2,3,4,5], [:two, :three, :four, :five])
130
+ expect(@dv).to eq(Daru::Vector.new [2,3,4,5], name: :a, index: [:two, :three, :four, :five])
131
131
  end
132
132
 
133
133
  it "deletes element of specified integer index" do
134
134
  @dv.delete_at 2
135
135
 
136
- expect(@dv).to eq(Daru::Vector.new :a, [1,2,4,5], [:one, :two, :four, :five])
136
+ expect(@dv).to eq(Daru::Vector.new [1,2,4,5], name: :a, index: [:one, :two, :four, :five])
137
137
  end
138
138
  end
139
139
 
140
140
  context "#index_of" do
141
141
  it "returns index of specified value" do
142
- dv = Daru::Vector.new :a, [1,2,3,4,5], [:one, :two, :three, :four, :five]
142
+ dv = Daru::Vector.new [1,2,3,4,5], name: :a, index: [:one, :two, :three, :four, :five]
143
143
 
144
144
  expect(dv.index_of(1)).to eq(:one)
145
145
  end
@@ -147,7 +147,7 @@ describe Daru::Vector do
147
147
 
148
148
  context "#to_hash" do
149
149
  it "returns the vector as a hash" do
150
- dv = Daru::Vector.new :a, [1,2,3,4,5], [:one, :two, :three, :four, :five]
150
+ dv = Daru::Vector.new [1,2,3,4,5], name: :a, index: [:one, :two, :three, :four, :five]
151
151
 
152
152
  expect(dv.to_hash).to eq({one: 1, two: 2, three: 3, four: 4, five: 5})
153
153
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: daru
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sameer Deshmukh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-04 00:00:00.000000000 Z
11
+ date: 2014-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -100,11 +100,18 @@ files:
100
100
  - Rakefile
101
101
  - daru.gemspec
102
102
  - lib/daru.rb
103
+ - lib/daru/accessors/array_wrapper.rb
104
+ - lib/daru/accessors/dataframe_by_row.rb
105
+ - lib/daru/accessors/dataframe_by_vector.rb
106
+ - lib/daru/accessors/mdarray_wrapper.rb
107
+ - lib/daru/accessors/nmatrix_wrapper.rb
103
108
  - lib/daru/dataframe.rb
104
- - lib/daru/dataframe_by_row.rb
105
- - lib/daru/dataframe_by_vector.rb
106
109
  - lib/daru/index.rb
107
- - lib/daru/io.rb
110
+ - lib/daru/io/io.rb
111
+ - lib/daru/math/arithmetic/dataframe.rb
112
+ - lib/daru/math/arithmetic/vector.rb
113
+ - lib/daru/math/statistics/dataframe.rb
114
+ - lib/daru/math/statistics/vector.rb
108
115
  - lib/daru/monkeys.rb
109
116
  - lib/daru/vector.rb
110
117
  - lib/version.rb
@@ -112,7 +119,11 @@ files:
112
119
  - spec/fixtures/countries.json
113
120
  - spec/fixtures/matrix_test.csv
114
121
  - spec/index_spec.rb
115
- - spec/io_spec.rb
122
+ - spec/io/io_spec.rb
123
+ - spec/math/arithmetic/dataframe_spec.rb
124
+ - spec/math/arithmetic/vector_spec.rb
125
+ - spec/math/statistics/dataframe_spec.rb
126
+ - spec/math/statistics/vector_spec.rb
116
127
  - spec/monkeys_spec.rb
117
128
  - spec/spec_helper.rb
118
129
  - spec/vector_spec.rb
@@ -145,7 +156,11 @@ test_files:
145
156
  - spec/fixtures/countries.json
146
157
  - spec/fixtures/matrix_test.csv
147
158
  - spec/index_spec.rb
148
- - spec/io_spec.rb
159
+ - spec/io/io_spec.rb
160
+ - spec/math/arithmetic/dataframe_spec.rb
161
+ - spec/math/arithmetic/vector_spec.rb
162
+ - spec/math/statistics/dataframe_spec.rb
163
+ - spec/math/statistics/vector_spec.rb
149
164
  - spec/monkeys_spec.rb
150
165
  - spec/spec_helper.rb
151
166
  - spec/vector_spec.rb
@@ -1,15 +0,0 @@
1
- module Daru
2
- class DataFrameByRow
3
- def initialize data_frame
4
- @data_frame = data_frame
5
- end
6
-
7
- def [](*names)
8
- @data_frame[*names, :row]
9
- end
10
-
11
- def []=(name, vector)
12
- @data_frame[name, :row] = vector
13
- end
14
- end
15
- end
@@ -1,15 +0,0 @@
1
- module Daru
2
- class DataFrameByVector
3
- def initialize data_frame
4
- @data_frame = data_frame
5
- end
6
-
7
- def [](*names)
8
- @data_frame[*names, :vector]
9
- end
10
-
11
- def []=(name, vectors)
12
- @data_frame[name, :vector] = vectors
13
- end
14
- end
15
- end