daru 0.1.1 → 0.1.2

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/spec/io/io_spec.rb CHANGED
@@ -85,8 +85,41 @@ describe Daru::IO do
85
85
  end
86
86
 
87
87
  context ".from_sql" do
88
- it "loads data from an SQL database" do
89
- # TODO: write these tests
88
+ include_context 'with accounts table in sqlite3 database'
89
+
90
+ context 'with a database handler of DBI' do
91
+ let(:db) do
92
+ DBI.connect("DBI:SQLite3:#{db_name}")
93
+ end
94
+
95
+ subject { Daru::DataFrame.from_sql(db, "select * from accounts") }
96
+
97
+ it "loads data from an SQL database" do
98
+ accounts = subject
99
+ expect(accounts.class).to eq Daru::DataFrame
100
+ expect(accounts.nrows).to eq 2
101
+ expect(accounts.row[0][:id]).to eq 1
102
+ expect(accounts.row[0][:name]).to eq "Homer"
103
+ end
104
+ end
105
+
106
+ context 'with a database connection of ActiveRecord' do
107
+ let(:connection) do
108
+ Daru::RSpec::Account.establish_connection "sqlite3:#{db_name}"
109
+ Daru::RSpec::Account.connection
110
+ end
111
+
112
+ subject do
113
+ Daru::DataFrame.from_sql(connection, "select * from accounts")
114
+ end
115
+
116
+ it "loads data from an SQL database" do
117
+ accounts = subject
118
+ expect(accounts.class).to eq Daru::DataFrame
119
+ expect(accounts.nrows).to eq 2
120
+ expect(accounts.row[0][:id]).to eq 1
121
+ expect(accounts.row[0][:name]).to eq "Homer"
122
+ end
90
123
  end
91
124
  end
92
125
 
@@ -96,6 +129,51 @@ describe Daru::IO do
96
129
  end
97
130
  end
98
131
 
132
+ context '.from_activerecord' do
133
+ include_context 'with accounts table in sqlite3 database'
134
+
135
+ context 'with ActiveRecord::Relation' do
136
+ before do
137
+ Daru::RSpec::Account.establish_connection "sqlite3:#{db_name}"
138
+ end
139
+
140
+ let(:relation) do
141
+ Daru::RSpec::Account.all
142
+ end
143
+
144
+ context 'without specifying field names' do
145
+ subject do
146
+ Daru::DataFrame.from_activerecord(relation)
147
+ end
148
+
149
+ it 'loads data from an AR::Relation object' do
150
+ accounts = subject
151
+ expect(accounts.class).to eq Daru::DataFrame
152
+ expect(accounts.nrows).to eq 2
153
+ expect(accounts.vectors.to_a).to eq [:id, :name, :age]
154
+ expect(accounts.row[0][:id]).to eq 1
155
+ expect(accounts.row[0][:name]).to eq 'Homer'
156
+ expect(accounts.row[0][:age]).to eq 20
157
+ end
158
+ end
159
+
160
+ context 'with specifying field names in parameters' do
161
+ subject do
162
+ Daru::DataFrame.from_activerecord(relation, :name, :age)
163
+ end
164
+
165
+ it 'loads data from an AR::Relation object' do
166
+ accounts = subject
167
+ expect(accounts.class).to eq Daru::DataFrame
168
+ expect(accounts.nrows).to eq 2
169
+ expect(accounts.vectors.to_a).to eq [:name, :age]
170
+ expect(accounts.row[0][:name]).to eq 'Homer'
171
+ expect(accounts.row[0][:age]).to eq 20
172
+ end
173
+ end
174
+ end
175
+ end
176
+
99
177
  context ".from_plaintext" do
100
178
  it "reads data from plain text files" do
101
179
  df = Daru::DataFrame.from_plaintext 'spec/fixtures/bank2.dat', [:v1,:v2,:v3,:v4,:v5,:v6]
@@ -0,0 +1,67 @@
1
+ require 'spec_helper'
2
+ require 'daru/io/sql_data_source'
3
+ require 'sqlite3'
4
+ require 'dbi'
5
+ require 'active_record'
6
+
7
+ RSpec.describe Daru::IO::SqlDataSource do
8
+ include_context 'with accounts table in sqlite3 database'
9
+ let(:dbi_handle) do
10
+ DBI.connect("DBI:SQLite3:#{db_name}")
11
+ end
12
+
13
+ let(:active_record_connection) do
14
+ ActiveRecord::Base.establish_connection("sqlite3:#{db_name}")
15
+ ActiveRecord::Base.connection
16
+ end
17
+
18
+ let(:query) do
19
+ 'select * from accounts'
20
+ end
21
+
22
+ describe '.make_dataframe' do
23
+ context 'with DBI::DatabaseHandle' do
24
+ it 'returns a dataframe' do
25
+ result = Daru::IO::SqlDataSource.make_dataframe(dbi_handle, query)
26
+ expect(result).to be_a(Daru::DataFrame)
27
+ expect(result.nrows).to eq(2)
28
+ expect(result.row[0][:id]).to eq(1)
29
+ expect(result.row[0][:name]).to eq('Homer')
30
+ end
31
+
32
+ context 'with an object not a string as a query' do
33
+ it 'raises ArgumentError' do
34
+ expect {
35
+ Daru::IO::SqlDataSource.make_dataframe(dbi_handle, Object.new)
36
+ }.to raise_error(ArgumentError)
37
+ end
38
+ end
39
+ end
40
+
41
+ context 'with ActiveRecord::Connection' do
42
+ it 'returns a dataframe' do
43
+ result = Daru::IO::SqlDataSource.make_dataframe(active_record_connection, query)
44
+ expect(result).to be_a(Daru::DataFrame)
45
+ expect(result.nrows).to eq(2)
46
+ expect(result.row[0][:id]).to eq(1)
47
+ expect(result.row[0][:name]).to eq('Homer')
48
+ end
49
+
50
+ context 'with an object not a string as a query' do
51
+ it 'raises ArgumentError' do
52
+ expect {
53
+ Daru::IO::SqlDataSource.make_dataframe(active_record_connection, Object.new)
54
+ }.to raise_error(ArgumentError)
55
+ end
56
+ end
57
+ end
58
+
59
+ context 'with an object not a database connection' do
60
+ it 'raises ArgumentError' do
61
+ expect {
62
+ Daru::IO::SqlDataSource.make_dataframe(Object.new, query)
63
+ }.to raise_error(ArgumentError)
64
+ end
65
+ end
66
+ end
67
+ end
data/spec/spec_helper.rb CHANGED
@@ -16,7 +16,7 @@ end
16
16
  if jruby?
17
17
  require 'mdarray'
18
18
  else
19
- require 'nmatrix'
19
+ require 'nmatrix/nmatrix'
20
20
  end
21
21
 
22
22
  RSpec::Expectations.configuration.warn_about_potential_false_positives = false
@@ -40,4 +40,6 @@ def expect_correct_df_in_delta df1, df2, delta
40
40
  df1.each_vector_with_index do |vector, i|
41
41
  expect_correct_vector_in_delta vector, df2[i], delta
42
42
  end
43
- end
43
+ end
44
+
45
+ Dir[File.expand_path('../support/**/*.rb', __FILE__)].each {|f| require f }
@@ -0,0 +1,30 @@
1
+ require 'sqlite3'
2
+ require 'dbi'
3
+ require 'active_record'
4
+
5
+ module Daru::RSpec
6
+ class Account < ActiveRecord::Base
7
+ self.table_name = 'accounts'
8
+ end
9
+ end
10
+
11
+ shared_context 'with accounts table in sqlite3 database' do
12
+ let(:db_name) do
13
+ 'daru_test'
14
+ end
15
+
16
+ before do
17
+ # just in case
18
+ FileUtils.rm(db_name) if File.file?(db_name)
19
+
20
+ SQLite3::Database.new(db_name).tap do |db|
21
+ db.execute "create table accounts(id integer, name varchar, age integer, primary key(id))"
22
+ db.execute "insert into accounts values(1, 'Homer', 20)"
23
+ db.execute "insert into accounts values(2, 'Marge', 30)"
24
+ end
25
+ end
26
+
27
+ after do
28
+ FileUtils.rm(db_name)
29
+ end
30
+ end
data/spec/vector_spec.rb CHANGED
@@ -5,16 +5,16 @@ describe Daru::Vector do
5
5
  describe dtype.to_s do
6
6
  before do
7
7
  @common_all_dtypes = Daru::Vector.new(
8
- [5, 5, 5, 5, 5, 6, 6, 7, 8, 9, 10, 1, 2, 3, 4, 11, -99, -99],
8
+ [5, 5, 5, 5, 5, 6, 6, 7, 8, 9, 10, 1, 2, 3, 4, 11, -99, -99],
9
9
  dtype: dtype, name: :common_all_dtypes)
10
10
  end
11
11
 
12
12
  context "#initialize" do
13
13
  before do
14
14
  @tuples = [
15
- [:a, :one, :foo],
16
- [:a, :two, :bar],
17
- [:b, :one, :bar],
15
+ [:a, :one, :foo],
16
+ [:a, :two, :bar],
17
+ [:b, :one, :bar],
18
18
  [:b, :two, :baz]
19
19
  ]
20
20
 
@@ -22,7 +22,7 @@ describe Daru::Vector do
22
22
  end
23
23
 
24
24
  it "initializes from an Array" do
25
- dv = Daru::Vector.new [1,2,3,4,5], name: :ravan,
25
+ dv = Daru::Vector.new [1,2,3,4,5], name: :ravan,
26
26
  index: [:ek, :don, :teen, :char, :pach], dtype: dtype
27
27
 
28
28
  expect(dv.name) .to eq(:ravan)
@@ -51,7 +51,7 @@ describe Daru::Vector do
51
51
 
52
52
  expect {
53
53
  idx = Daru::Index.new [:i, :j, :k]
54
- dv = Daru::Vector.new [1,2,3,4,5], name: :yoda, index: idx, dtype: dtype
54
+ dv = Daru::Vector.new [1,2,3,4,5], name: :yoda, index: idx, dtype: dtype
55
55
  }.to raise_error
56
56
  end
57
57
 
@@ -122,7 +122,7 @@ describe Daru::Vector do
122
122
  context "#[]" do
123
123
  context Daru::Index do
124
124
  before :each do
125
- @dv = Daru::Vector.new [1,2,3,4,5], name: :yoga,
125
+ @dv = Daru::Vector.new [1,2,3,4,5], name: :yoga,
126
126
  index: [:yoda, :anakin, :obi, :padme, :r2d2], dtype: dtype
127
127
  end
128
128
 
@@ -135,22 +135,22 @@ describe Daru::Vector do
135
135
  end
136
136
 
137
137
  it "returns a vector with given indices for multiple indices" do
138
- expect(@dv[:yoda, :anakin]).to eq(Daru::Vector.new([1,2], name: :yoda,
138
+ expect(@dv[:yoda, :anakin]).to eq(Daru::Vector.new([1,2], name: :yoda,
139
139
  index: [:yoda, :anakin], dtype: dtype))
140
140
  end
141
141
 
142
142
  it "returns a vector with given indices for multiple numeric indices" do
143
- expect(@dv[0,1]).to eq(Daru::Vector.new([1,2], name: :yoda,
143
+ expect(@dv[0,1]).to eq(Daru::Vector.new([1,2], name: :yoda,
144
144
  index: [:yoda, :anakin], dtype: dtype))
145
145
  end
146
146
 
147
147
  it "returns a vector when specified symbol Range" do
148
- expect(@dv[:yoda..:anakin]).to eq(Daru::Vector.new([1,2],
148
+ expect(@dv[:yoda..:anakin]).to eq(Daru::Vector.new([1,2],
149
149
  index: [:yoda, :anakin], name: :yoga, dtype: dtype))
150
150
  end
151
151
 
152
152
  it "returns a vector when specified numeric Range" do
153
- expect(@dv[3..4]).to eq(Daru::Vector.new([4,5], name: :yoga,
153
+ expect(@dv[3..4]).to eq(Daru::Vector.new([4,5], name: :yoga,
154
154
  index: [:padme, :r2d2], dtype: dtype))
155
155
  end
156
156
 
@@ -181,7 +181,7 @@ describe Daru::Vector do
181
181
  ]
182
182
  @multi_index = Daru::MultiIndex.from_tuples(@tuples)
183
183
  @vector = Daru::Vector.new(
184
- Array.new(12) { |i| i }, index: @multi_index,
184
+ Array.new(12) { |i| i }, index: @multi_index,
185
185
  dtype: dtype, name: :mi_vector)
186
186
  end
187
187
 
@@ -199,7 +199,7 @@ describe Daru::Vector do
199
199
  [:one,:baz],
200
200
  [:two,:bar],
201
201
  [:two,:baz]])
202
- expect(@vector[:a]).to eq(Daru::Vector.new([0,1,2,3], index: mi,
202
+ expect(@vector[:a]).to eq(Daru::Vector.new([0,1,2,3], index: mi,
203
203
  dtype: dtype, name: :sub_vector))
204
204
  end
205
205
 
@@ -230,7 +230,7 @@ describe Daru::Vector do
230
230
  context "#[]=" do
231
231
  context Daru::Index do
232
232
  before :each do
233
- @dv = Daru::Vector.new [1,2,3,4,5], name: :yoga,
233
+ @dv = Daru::Vector.new [1,2,3,4,5], name: :yoga,
234
234
  index: [:yoda, :anakin, :obi, :padme, :r2d2], dtype: dtype
235
235
  end
236
236
 
@@ -260,7 +260,7 @@ describe Daru::Vector do
260
260
  v[3] = 666
261
261
  expect(v[3]).to eq(666)
262
262
 
263
- expect(v).to eq(Daru::Vector.new([666,2,666,666],
263
+ expect(v).to eq(Daru::Vector.new([666,2,666,666],
264
264
  index: ['a',:a,0,66]))
265
265
  end
266
266
  end
@@ -282,7 +282,7 @@ describe Daru::Vector do
282
282
  [:c,:two,:bar]
283
283
  ]
284
284
  @multi_index = Daru::MultiIndex.from_tuples(@tuples)
285
- @vector = Daru::Vector.new Array.new(12) { |i| i }, index: @multi_index,
285
+ @vector = Daru::Vector.new Array.new(12) { |i| i }, index: @multi_index,
286
286
  dtype: dtype, name: :mi_vector
287
287
  end
288
288
 
@@ -315,7 +315,7 @@ describe Daru::Vector do
315
315
 
316
316
  context "#concat" do
317
317
  before :each do
318
- @dv = Daru::Vector.new [1,2,3,4,5], name: :yoga,
318
+ @dv = Daru::Vector.new [1,2,3,4,5], name: :yoga,
319
319
  index: [:warwick, :thompson, :jackson, :fender, :esp], dtype: dtype
320
320
  end
321
321
 
@@ -350,14 +350,14 @@ describe Daru::Vector do
350
350
  context "#delete_at" do
351
351
  context Daru::Index do
352
352
  before :each do
353
- @dv = Daru::Vector.new [1,2,3,4,5], name: :a,
353
+ @dv = Daru::Vector.new [1,2,3,4,5], name: :a,
354
354
  index: [:one, :two, :three, :four, :five], dtype: dtype
355
355
  end
356
356
 
357
357
  it "deletes element of specified index" do
358
358
  @dv.delete_at :one
359
359
 
360
- expect(@dv).to eq(Daru::Vector.new [2,3,4,5], name: :a,
360
+ expect(@dv).to eq(Daru::Vector.new [2,3,4,5], name: :a,
361
361
  index: [:two, :three, :four, :five], dtype: dtype)
362
362
  end
363
363
 
@@ -365,7 +365,7 @@ describe Daru::Vector do
365
365
  pending
366
366
  @dv.delete_at 2
367
367
 
368
- expect(@dv).to eq(Daru::Vector.new [1,2,4,5], name: :a,
368
+ expect(@dv).to eq(Daru::Vector.new [1,2,4,5], name: :a,
369
369
  index: [:one, :two, :four, :five], dtype: dtype)
370
370
  end
371
371
  end
@@ -376,7 +376,7 @@ describe Daru::Vector do
376
376
  v = Daru::Vector.new [1,22,33,45,65,32,524,656,123,99,77], dtype: dtype
377
377
  ret = v.delete_if { |d| d % 11 == 0 }
378
378
  expect(ret).to eq(
379
- Daru::Vector.new([1,45,65,32,524,656,123],
379
+ Daru::Vector.new([1,45,65,32,524,656,123],
380
380
  index: [0,3,4,5,6,7,8], dtype: dtype))
381
381
  expect(ret.dtype).to eq(dtype)
382
382
  end
@@ -396,7 +396,7 @@ describe Daru::Vector do
396
396
  context "#index_of" do
397
397
  context Daru::Index do
398
398
  it "returns index of specified value" do
399
- dv = Daru::Vector.new [1,2,3,4,5], name: :a,
399
+ dv = Daru::Vector.new [1,2,3,4,5], name: :a,
400
400
  index: [:one, :two, :three, :four, :five], dtype: dtype
401
401
 
402
402
  expect(dv.index_of(1)).to eq(:one)
@@ -420,7 +420,7 @@ describe Daru::Vector do
420
420
  context "#to_hash" do
421
421
  context Daru::Index do
422
422
  it "returns the vector as a hash" do
423
- dv = Daru::Vector.new [1,2,3,4,5], name: :a,
423
+ dv = Daru::Vector.new [1,2,3,4,5], name: :a,
424
424
  index: [:one, :two, :three, :four, :five], dtype: dtype
425
425
 
426
426
  expect(dv.to_hash).to eq({one: 1, two: 2, three: 3, four: 4, five: 5})
@@ -485,20 +485,19 @@ describe Daru::Vector do
485
485
  expect(sorted).to eq(Daru::Vector.new(["My", "Jazz", "Guitar", "My Jazz Guitar"], index: [2,1,3,0]))
486
486
  end
487
487
 
488
- it "places nils near the end of the vector" do
489
- pending
488
+ it "places nils near the beginning of the vector" do
490
489
  with_nils = Daru::Vector.new [22,4,nil,111,nil,2]
491
490
 
492
- expect(with_nils.sort).to eq(Daru::Vector.new([2,4,22,111,nil,nil], index: [5,1,0,3,2,4]))
491
+ expect(with_nils.sort).to eq(Daru::Vector.new([nil,nil,2,4,22,111], index: [2,4,5,1,0,3]))
493
492
  end if dtype == :array
494
493
  end
495
494
 
496
495
  context Daru::MultiIndex do
497
496
  before do
498
497
  mi = Daru::MultiIndex.from_tuples([
499
- [:a, :one, :foo],
500
- [:a, :two, :bar],
501
- [:b, :one, :bar],
498
+ [:a, :one, :foo],
499
+ [:a, :two, :bar],
500
+ [:b, :one, :bar],
502
501
  [:b, :two, :baz],
503
502
  [:b, :three, :bar]
504
503
  ])
@@ -520,10 +519,10 @@ describe Daru::Vector do
520
519
 
521
520
  it "sorts in descending" do
522
521
  mi_dsc = Daru::MultiIndex.from_tuples([
523
- [:b, :one, :bar],
524
- [:a, :one, :foo],
525
- [:a, :two, :bar],
526
- [:b, :two, :baz],
522
+ [:b, :one, :bar],
523
+ [:a, :one, :foo],
524
+ [:a, :two, :bar],
525
+ [:b, :two, :baz],
527
526
  [:b, :three, :bar]
528
527
  ])
529
528
  expect(@vector.sort(ascending: false)).to eq(Daru::Vector.new(
@@ -592,7 +591,7 @@ describe Daru::Vector do
592
591
  it "destructively maps" do
593
592
  @common_all_dtypes.map! { |v| v + 1 }
594
593
  expect(@common_all_dtypes).to eq(Daru::Vector.new(
595
- [6, 6, 6, 6, 6, 7, 7, 8, 9, 10, 11, 2, 3, 4, 5, 12, -98, -98],
594
+ [6, 6, 6, 6, 6, 7, 7, 8, 9, 10, 11, 2, 3, 4, 5, 12, -98, -98],
596
595
  dtype: dtype))
597
596
  end
598
597
  end
@@ -623,7 +622,7 @@ describe Daru::Vector do
623
622
  context "#recode!" do
624
623
  before :each do
625
624
  @vector = Daru::Vector.new(
626
- [5, 5, 5, 5, 5, 6, 6, 7, 8, 9, 10, 1, 2, 3, 4, 11, -99, -99],
625
+ [5, 5, 5, 5, 5, 6, 6, 7, 8, 9, 10, 1, 2, 3, 4, 11, -99, -99],
627
626
  dtype: dtype, name: :common_all_dtypes)
628
627
  end
629
628
 
@@ -631,7 +630,7 @@ describe Daru::Vector do
631
630
  @vector.recode! { |v| v == -99 ? 1 : 0 }
632
631
  exp = Daru::Vector.new [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1]
633
632
  expect(@vector).to eq(exp)
634
- expect(@vector.dtype).to eq(dtype)
633
+ expect(@vector.dtype).to eq(dtype)
635
634
  end
636
635
 
637
636
  it "destructively maps and returns a vector of dtype gsl" do
@@ -715,7 +714,7 @@ describe Daru::Vector do
715
714
  [-99, -99, 1, 2, 3, 4, 5, 5, 5, 5, 5, 6, 6, 7, 8, 9, 10]
716
715
  )
717
716
  expect(@common.to_a).to eq(
718
- [5, 5, 5, 5, 5, 6, 6, 7, 8, 9, 10, 1, 2, 3, 4, nil, -99, -99]
717
+ [5, 5, 5, 5, 5, 6, 6, 7, 8, 9, 10, 1, 2, 3, 4, nil, -99, -99]
719
718
  )
720
719
  end
721
720
 
@@ -746,7 +745,7 @@ describe Daru::Vector do
746
745
  expect(vec.clone_structure).to eq(Daru::Vector.new([nil,nil,nil,nil,nil], index: [:a,:b,:c,:d,:e]))
747
746
  end
748
747
  end
749
-
748
+
750
749
  context Daru::MultiIndex do
751
750
  pending
752
751
  end
@@ -782,7 +781,7 @@ describe Daru::Vector do
782
781
  ])
783
782
  vector = Daru::Vector.new([nil,2,4,5,3,nil,2,nil], index: mi)
784
783
  expect(vector.missing_positions).to eq([
785
- ['M',2000],
784
+ ['M',2000],
786
785
  ['F',2001],
787
786
  ['F',2003]
788
787
  ])
@@ -832,7 +831,7 @@ describe Daru::Vector do
832
831
  expect(@multi.type).to eq(:object)
833
832
  @multi[3] = 45
834
833
  @multi[4] = 54
835
- expect(@multi.type).to eq(:numeric)
834
+ expect(@multi.type).to eq(:numeric)
836
835
  end
837
836
 
838
837
  it "reports numeric if nils with number data" do
@@ -866,9 +865,9 @@ describe Daru::Vector do
866
865
 
867
866
  context "#only_valid" do
868
867
  it "returns a Vector of only non-nil data" do
869
- vector = Daru::Vector.new [1,2,3,4,nil,3,nil],
868
+ vector = Daru::Vector.new [1,2,3,4,nil,3,nil],
870
869
  index: [:a, :b, :c, :d, :e, :f, :g]
871
- expect(vector.only_valid).to eq(Daru::Vector.new([1,2,3,4,3],
870
+ expect(vector.only_valid).to eq(Daru::Vector.new([1,2,3,4,3],
872
871
  index: [:a, :b, :c, :d, :f]))
873
872
  end
874
873
  end
@@ -934,7 +933,7 @@ describe Daru::Vector do
934
933
  it "returns the number of ocurrences of tokens" do
935
934
  a = Daru::Vector.new ['a', 'a,b', 'c,d', 'a,d', 10, nil]
936
935
  expect(a.split_by_separator_freq).to eq(
937
- { 'a' => 3, 'b' => 1, 'c' => 1, 'd' => 2, 10 => 1 })
936
+ { 'a' => 3, 'b' => 1, 'c' => 1, 'd' => 2, 10 => 1 })
938
937
  end
939
938
  end
940
939
 
@@ -985,7 +984,7 @@ describe Daru::Vector do
985
984
  it "returns false if block is false for all elements" do
986
985
  expect(@v.any?{ |e| e > 10 }).to eq(false)
987
986
  end
988
- end
987
+ end
989
988
 
990
989
  context "#all?" do
991
990
  before do
@@ -1006,14 +1005,14 @@ describe Daru::Vector do
1006
1005
  v = Daru::Vector.new([1,2,3,4,5,6,4,5,5,4,4,nil,nil,nil])
1007
1006
  v.missing_values = [nil, 5]
1008
1007
 
1009
- expect(v.only_missing).to eq(Daru::Vector.new([5,5,5,nil,nil,nil],
1008
+ expect(v.only_missing).to eq(Daru::Vector.new([5,5,5,nil,nil,nil],
1010
1009
  index: [4,7,8,11,12,13]))
1011
1010
  end
1012
1011
  end
1013
1012
 
1014
1013
  context "#detach_index" do
1015
1014
  it "creates a DataFrame with first Vector as index and second as values of the Vector" do
1016
- v = Daru::Vector.new([1,2,3,4,5,6],
1015
+ v = Daru::Vector.new([1,2,3,4,5,6],
1017
1016
  index: ['a', 'b', 'c', 'd', 'e', 'f'], name: :values)
1018
1017
  expect(v.detach_index).to eq(Daru::DataFrame.new({
1019
1018
  index: ['a', 'b', 'c', 'd', 'e', 'f'],