spec/elementwise_spec.rb in nmatrix-atlas-0.2.3 vs spec/elementwise_spec.rb in nmatrix-atlas-0.2.4
- old
+ new
@@ -29,23 +29,24 @@
describe NMatrix do
context "yale" do
before :each do
@n = NMatrix.new(3, stype: :yale, dtype: :int64)
- @n.extend NMatrix::YaleFunctions
+ @n.extend NMatrix::YaleFunctions unless jruby?
@m = NMatrix.new(3, stype: :yale, dtype: :int64)
@n[0,0] = 52
@n[0,2] = 5
@n[1,1] = 40
@n[0,1] = 30
@n[2,0] = 6
@m[1,1] = -48
@m[0,2] = -5
- @n.extend NMatrix::YaleFunctions
+ @n.extend NMatrix::YaleFunctions unless jruby?
end
it "should perform scalar math" do
+ pending("not yet implemented for sparse matrices for NMatrix-JRuby") if jruby?
x = @n * 3
expect(x[0,0]).to eq(52 * 3)
expect(x[0,1]).to eq(30 * 3)
expect(x[0,2]).to eq(5 * 3)
expect(x[1,1]).to eq(40 * 3)
@@ -55,10 +56,11 @@
y = r + 3
expect(y[0,0]).to eq(3)
end
it "should refuse to perform a dot operation on a yale with non-zero default" do
+ pending("not yet implemented for sparse matrices for NMatrix-JRuby") if jruby?
r = NMatrix.new(3, stype: :yale, dtype: :int64)
y = r + 3
expect { y.dot(r) }.to raise_error
expect { r.dot(y) }.to raise_error
end
@@ -76,15 +78,17 @@
m = NMatrix.new(2, stype: :yale, dtype: :int64)
expect(@n*@m).to eq(r)
end
it "should perform element-wise division" do
+ pending("not yet implemented for sparse matrices for NMatrix-JRuby") if jruby?
r = NMatrix.new(:dense, 3, [52, 30, -2, 0, -1, 0, 6, 0, 0], :int64).cast(:yale, :int64)
expect(@n/(@m+1)).to eq(r)
end
it "should perform element-wise modulo" do
+ pending("not yet implemented for sparse matrices for NMatrix-JRuby") if jruby?
m = NMatrix.new(3, stype: :yale, dtype: :int64, default: 0) + 5
expect(@n % m).to eq(NMatrix.new(:dense, 3, [2,0,0,0,0,0,1,0,0], :int64).cast(:yale, :int64))
end
it "should handle element-wise equality (=~)" do
@@ -122,10 +126,11 @@
@m[1,1] = -48
@n[1,1] = 40
end
it "should perform scalar math" do
+ pending("not yet implemented for sparse matrices for NMatrix-JRuby") if jruby?
x = @n * 3
expect(x[0,0]).to eq(52 * 3)
expect(x[1,1]).to eq(40 * 3)
expect(x[0,1]).to eq(0)
@@ -160,10 +165,11 @@
r = NMatrix.new(:dense, 2, [52, 0, 0, 20], :int64).cast(:list, :int64)
expect(@n/m).to eq(r)
end
it "should perform element-wise modulo" do
+ pending("not yet implemented for sparse matrices for NMatrix-JRuby") if jruby?
m = NMatrix.new(:list, 2, 1, :int64)
m[0,0] = 50
m[1,1] = 40
(@n % m)
end
@@ -243,10 +249,11 @@
r = @n*@m
expect(r).to eq(NMatrix.new(:dense, [2,2], [-4, -2, 0, 264], :int64))
end
it "divides in the Ruby way" do
+ pending("not yet implemented int dtype for NMatrix-JRuby") if jruby?
m = @m.clone
m[1,0] = 3
r = @n/m
expect(r).to eq(NMatrix.new(:dense, [2,2], [-1, -2, 1, 0], :int64))
end
@@ -256,9 +263,10 @@
# TODO: We might have problems with the dtype.
expect(r).to eq(NMatrix.new(:dense, [2,2], [1, 4, 9, 16], :int64))
end
it "modulo" do
+ pending("not yet implemented int dtype for NMatrix-JRuby") if jruby?
expect(@n % (@m + 2)).to eq(NMatrix.new(:dense, [2,2], [-1, 0, 1, 4], :int64))
end
end
context "elementwise comparisons" do