spec/shortcuts_spec.rb in nmatrix-0.0.6 vs spec/shortcuts_spec.rb in nmatrix-0.0.7
- old
+ new
@@ -163,33 +163,31 @@
m = NMatrix.random(3)
m.column(2).is_a?(NMatrix).should be_true
end
- it "column() accepts a second parameter (only :copy or :reference)" do
- m = NMatrix.random(3)
-
- expect { m.column(1, :copy) }.to_not raise_error
- expect { m.column(1, :reference) }.to_not raise_error
-
- expect { m.column(1, :derp) }.to raise_error
- end
-
it "row() returns a NMatrix" do
m = NMatrix.random(3)
m.row(2).is_a?(NMatrix).should be_true
end
- it "row() accepts a second parameter (only :copy or :reference)" do
- m = NMatrix.random(3)
+ it "diagonals() creates an NMatrix" do
+ arr = [1,2,3,4]
+ m = NMatrix.diagonals(arr)
+ m.is_a?(NMatrix).should be_true
+ end
- expect { m.row(1, :copy) }.to_not raise_error
- expect { m.row(1, :reference) }.to_not raise_error
-
- expect { m.row(1, :derp) }.to raise_error
+ it "diagonals() contains the seeded values on the diagonal" do
+ arr = [1,2,3,4]
+ m = NMatrix.diagonals(arr)
+ m[0,0].should eq(arr[0])
+ m[1,1].should eq(arr[1])
+ m[2,2].should eq(arr[2])
+ m[3,3].should eq(arr[3])
end
+
end
describe "NVector" do
it "zeros() creates a vector of zeros" do
@@ -259,10 +257,10 @@
describe "Inline constructor" do
it "creates a NMatrix with the given values" do
m = NMatrix.new([2, 2], [1, 4, 6, 7])
- n = N[[1, 4], [6, 7]]
+ n = NMatrix[[1, 4], [6, 7]]
m.should.eql? n
end
end