spec/02_slice_spec.rb in nmatrix-0.2.3 vs spec/02_slice_spec.rb in nmatrix-0.2.4
- old
+ new
@@ -42,10 +42,12 @@
expect(stype_matrix.row(1, :copy).to_flat_array).to eq([12,13,0])
end
if stype == :yale
it "should binary search for the left boundary of a partial row of stored indices correctly" do
+ #FIXME
+ pending("not yet implemented for sparse matrices for NMatrix-JRuby") if jruby?
n = NMatrix.new(10, stype: :yale, dtype: :int32)
n[3,0] = 1
#n[3,2] = 2
n[3,3] = 3
n[3,4] = 4
@@ -85,11 +87,12 @@
end
end
unless stype == :dense
it "should iterate across a row of stored indices" do
-
+ #FIXME
+ pending("not yet implemented for sparse matrices for NMatrix-JRuby") if jruby?
vs = []
is = []
js = []
stype_matrix[2,0..2].each_stored_with_indices do |v,i,j|
vs << v
@@ -100,10 +103,12 @@
expect(is).to eq([0,0,0])
expect(js).to eq(stype == :yale ? [2,0,1] : [0,1,2])
end
it "should iterate across a submatrix of stored indices" do
+ #FIXME
+ pending("not yet implemented for sparse matrices for NMatrix-JRuby") if jruby?
vs = []
is = []
js = []
stype_matrix[0..1,1..2].each_stored_with_indices do |v,i,j|
vs << v
@@ -116,17 +121,19 @@
expect(js).to eq(stype == :yale ? [0,0,1,1] : [0,1,0,1])
end
end
it "should return correct supershape" do
+ pending("not yet implemented for sparse matrices for NMatrix-JRuby") if jruby?
x = NMatrix.random([10,12])
y = x[0...8,5...12]
expect(y.shape).to eq([8,7])
expect(y.supershape).to eq([10,12])
end
it "should have #is_ref? method" do
+ pending("not yet implemented for sparse matrices for NMatrix-JRuby") if jruby?
a = stype_matrix[0..1, 0..1]
b = stype_matrix.slice(0..1, 0..1)
expect(stype_matrix.is_ref?).to be false
expect(a.is_ref?).to be true
expect(b.is_ref?).to be false
@@ -143,19 +150,22 @@
n = stype_matrix.slice(0..1,0..1)
expect(nm_eql(n, NMatrix.new([2,2], [0,1,3,4], dtype: :int32))).to be true
end
it 'should return a copy of 2x2 matrix to self elements' do
+ pending("not yet implemented for sparse matrices for NMatrix-JRuby") if jruby?
n = stype_matrix.slice(1..2,0..1)
expect(n.shape).to eql([2,2])
expect(n[1,1]).to eq(stype_matrix[2,1])
n[1,1] = -9
expect(stype_matrix[2,1]).to eql(7)
end
it 'should return a 1x2 matrix without refs to self elements' do
+ #FIXME
+ pending("not yet implemented for sparse matrices for NMatrix-JRuby") if jruby?
n = stype_matrix.slice(0,1..2)
expect(n.shape).to eql([1,2])
expect(n[0]).to eq(stype_matrix[0,1])
expect(n[1]).to eq(stype_matrix[0,2])
@@ -163,10 +173,11 @@
expect(stype_matrix[0,1]).to eql(1)
expect(stype_matrix[0,2]).to eql(2)
end
it 'should return a 2x1 matrix without refs to self elements' do
+ pending("not yet implemented for sparse matrices for NMatrix-JRuby") if jruby?
stype_matrix.extend NMatrix::YaleFunctions
n = stype_matrix.slice(0..1,1)
expect(n.shape).to eql([2,1])
@@ -216,28 +227,33 @@
n = stype_matrix[0..1,0..1]
expect(nm_eql(n, NMatrix.new([2,2], [0,1,3,4], dtype: :int32))).to be true
end
it 'should return a 2x2 matrix with refs to self elements' do
+ #FIXME
+ pending("not yet implemented for sparse matrices for NMatrix-JRuby") if jruby? # and :cast_type != :dense
n = stype_matrix[1..2,0..1]
expect(n.shape).to eql([2,2])
expect(n[0,0]).to eq(stype_matrix[1,0])
n[0,0] = -9
expect(stype_matrix[1,0]).to eql(-9)
end
it 'should return a 1x2 vector with refs to self elements' do
+ #FIXME
+ pending("not yet implemented for sparse matrices for NMatrix-JRuby") if jruby? # and :cast_type != :dense
n = stype_matrix[0,1..2]
expect(n.shape).to eql([1,2])
expect(n[0]).to eq(stype_matrix[0,1])
n[0] = -9
expect(stype_matrix[0,1]).to eql(-9)
end
it 'should return a 2x1 vector with refs to self elements' do
+ pending("not yet implemented for sparse matrices for NMatrix-JRuby") if jruby?
n = stype_matrix[0..1,1]
expect(n.shape).to eql([2,1])
expect(n[0]).to eq(stype_matrix[0,1])
n[0] = -9
@@ -318,9 +334,11 @@
it "scalar adds to slices" do
expect(stype_matrix[1,0..2]+1).to eq NMatrix[[4, 5, 6]]
end
it "compares slices to scalars" do
+ #FIXME
+ pending("not yet implemented for sparse matrices for NMatrix-JRuby") if jruby?
(stype_matrix[1, 0..2] > 2).each { |e| expect(e != 0).to be true }
end
it "iterates only over elements in the slice" do
els = []