Skip to content

Commit cfd6c41

Browse files
committed
jruby_port: make tests pending for shortcuts_spec.rb
1 parent a3e0a81 commit cfd6c41

File tree

1 file changed

+36
-23
lines changed

1 file changed

+36
-23
lines changed

spec/shortcuts_spec.rb

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,14 @@
104104
[:dense, :yale, :list].each do |stype|
105105
context "#block_diagonal #{dtype} #{stype}" do
106106
it "block_diagonal() creates a block-diagonal NMatrix" do
107+
pending("not yet implemented for NMatrix-JRuby") if jruby? and dtype == :object
107108
a = NMatrix.new([2,2], [1,2,
108109
3,4])
109110
b = NMatrix.new([1,1], [123.0])
110111
c = NMatrix.new([3,3], [1,2,3,
111112
1,2,3,
112113
1,2,3])
113-
d = Array[ [1,1,1], [2,2,2], [3,3,3] ]
114+
d = Array[ [1,1,1], [2,2,2], [3,3,3] ]
114115
e = 12
115116
m = NMatrix.block_diagonal(a, b, c, d, e, dtype: dtype, stype: stype)
116117
expect(m).to eq(NMatrix.new([10,10], [1, 2, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -158,56 +159,59 @@
158159
expect { NMatrix.random("not an array or integer") }.to raise_error
159160
end
160161
end
161-
162+
162163
context "::magic" do
163-
164+
164165
ALL_DTYPES.each do |dtype|
165166
context dtype do
166167
it "creates a matrix with numbers from 1 to n^n(n squared)" do
168+
pending("not yet implemented for NMatrix-JRuby") if jruby?
167169
a = NMatrix.magic(3, dtype: dtype)
168-
magic3 = NMatrix.new([3,3], [4, 9, 2, 3, 5, 7, 8, 1, 6], dtype: dtype)
170+
magic3 = NMatrix.new([3,3], [4, 9, 2, 3, 5, 7, 8, 1, 6], dtype: dtype)
169171
expect(a).to eq magic3
170-
172+
171173
b = NMatrix.magic(4, dtype: dtype)
172174
magic4 = NMatrix.new([4,4], [1, 15, 14, 4, 12, 6, 7, 9, 8, 10, 11, 5, 13, 3, 2, 16], dtype: dtype)
173175
expect(b).to eq magic4
174-
176+
175177
c = NMatrix.magic(6, dtype: dtype)
176178
magic6 = NMatrix.new([6,6], [31, 9, 2, 22, 27, 20, 3, 32, 7, 21, 23, 25, 35, 1, 6, 26, 19, 24, 4, 36, 29, 13, 18, 11, 30, 5, 34, 12, 14, 16, 8, 28, 33, 17, 10, 15], dtype: dtype)
177-
expect(c).to eq magic6
179+
expect(c).to eq magic6
178180
end
179181
end
180182
end
181-
183+
182184
it "shape of two is not allowed" do
183185
expect { NMatrix.magic(2) }.to raise_error(ArgumentError)
184186
end
185-
186-
it "Only accepts an integer as dimension" do
187+
188+
it "Only accepts an integer as dimension" do
187189
expect { NMatrix.magic(3.0) }.to raise_error(ArgumentError)
188190
end
189191
end
190-
192+
191193
context "::linspace" do
192194
it "creates a row vector when given only one shape parameter" do
195+
pending("not yet implemented for NMatrix-JRuby") if jruby?
193196
v = NMatrix.linspace(1, 10, 4)
194197
#Expect a row vector only
195198
expect(v.shape.length).to eq(1)
196-
199+
197200
ans = [1.0,4.0,7.0,10.0]
198201

199202
expect(v[0]).to be_within(0.000001).of(ans[0])
200203
expect(v[1]).to be_within(0.000001).of(ans[1])
201204
expect(v[2]).to be_within(0.000001).of(ans[2])
202205
expect(v[3]).to be_within(0.000001).of(ans[3])
203206
end
204-
207+
205208
it "creates a matrix of input shape with each entry linearly spaced in row major order" do
209+
pending("not yet implemented for NMatrix-JRuby") if jruby?
206210
v = NMatrix.linspace(1, Math::PI, [2,2])
207211
expect(v.dtype).to eq(:float64)
208212

209213
ans = [1.0, 1.7138642072677612, 2.4277284145355225, 3.1415927410125732]
210-
214+
211215
expect(v[0,0]).to be_within(0.000001).of(ans[0])
212216
expect(v[0,1]).to be_within(0.000001).of(ans[1])
213217
expect(v[1,0]).to be_within(0.000001).of(ans[2])
@@ -217,13 +221,14 @@
217221

218222
context "::logspace" do
219223
it "creates a logarithmically spaced vector" do
224+
pending("not yet implemented for NMatrix-JRuby") if jruby?
220225
v = NMatrix.logspace(1, 2, 10)
221-
226+
222227
expect(v.shape.length).to eq(1)
223-
228+
224229
#Unit test taken from Matlab R2015b output of logspace(1,2,10)
225230
ans = [10.0000, 12.9155, 16.6810, 21.5443, 27.8256, 35.9381, 46.4159, 59.9484, 77.4264, 100.0000]
226-
231+
227232
expect(v[0].round(4)).to be_within(0.000001).of(ans[0])
228233
expect(v[1].round(4)).to be_within(0.000001).of(ans[1])
229234
expect(v[2].round(4)).to be_within(0.000001).of(ans[2])
@@ -235,27 +240,29 @@
235240
expect(v[8].round(4)).to be_within(0.000001).of(ans[8])
236241
expect(v[9].round(4)).to be_within(0.000001).of(ans[9])
237242
end
238-
243+
239244
it "creates a logarithmically spaced vector bounded by Math::PI if :pi is pre-supplied" do
245+
pending("not yet implemented for NMatrix-JRuby") if jruby?
240246
v = NMatrix.logspace(1, :pi, 7)
241-
247+
242248
#Unit test taken from Matlab R2015b output of logspace(1,pi,10)
243249
ans = [10.0000, 8.2450, 6.7980, 5.6050, 4.6213, 3.8103, 3.1416]
244-
250+
245251
expect(v[0].round(4)).to be_within(0.000001).of(ans[0])
246252
expect(v[1].round(4)).to be_within(0.000001).of(ans[1])
247253
expect(v[2].round(4)).to be_within(0.000001).of(ans[2])
248254
expect(v[3].round(4)).to be_within(0.000001).of(ans[3])
249255
expect(v[4].round(4)).to be_within(0.000001).of(ans[4])
250256
expect(v[5].round(4)).to be_within(0.000001).of(ans[5])
251257
expect(v[6].round(4)).to be_within(0.000001).of(ans[6])
252-
end
258+
end
253259

254260
it "creates a matrix of input shape with each entry logarithmically spaced in row major order" do
261+
pending("not yet implemented for NMatrix-JRuby") if jruby?
255262
v = NMatrix.logspace(1, 2, [3,2])
256-
263+
257264
ans = [10.0, 15.8489, 25.1189, 39.8107, 63.0957, 100.0]
258-
265+
259266
expect(v[0,0].round(4)).to be_within(0.000001).of(ans[0])
260267
expect(v[0,1].round(4)).to be_within(0.000001).of(ans[1])
261268
expect(v[1,0].round(4)).to be_within(0.000001).of(ans[2])
@@ -360,6 +367,7 @@
360367
end
361368

362369
it "should create an nmatrix of ones with dimensions and type the same as its argument" do
370+
pending("not yet implemented for NMatrix-JRuby") if jruby?
363371
expect(NMatrix.ones_like(@nm_1d)).to eq NMatrix[1.0, 1.0, 1.0, 1.0, 1.0]
364372
expect(NMatrix.ones_like(@nm_2d)).to eq NMatrix[[1.0, 1.0], [1.0, 1.0]]
365373
end
@@ -383,6 +391,7 @@
383391
end
384392

385393
it "ones() creates a vector of ones" do
394+
pending("not yet implemented for NMatrix-JRuby") if jruby?
386395
v = NVector.ones(3)
387396

388397
3.times do |i|
@@ -391,6 +400,7 @@
391400
end
392401

393402
it "random() creates a vector of random numbers" do
403+
pending("not yet implemented for NMatrix-JRuby") if jruby?
394404
v = NVector.random(4)
395405
expect(v.dtype).to eq(:float64)
396406
expect(v.stype).to eq(:dense)
@@ -424,16 +434,19 @@
424434
end
425435

426436
it "cindgen() creates a vector of complexes, sequentially" do
437+
pending("not yet implemented for NMatrix-JRuby") if jruby?
427438
v = NVector.cindgen(2)
428439
expect(v).to eq(NMatrix.new([2,1], [Complex(0.0, 0.0), Complex(1.0, 0.0)], dtype: :complex64))
429440
end
430441

431442
it "linspace() creates a vector with n values equally spaced between a and b" do
443+
pending("not yet implemented for NMatrix-JRuby") if jruby?
432444
v = NVector.linspace(0, 2, 5)
433445
expect(v).to eq(NMatrix.new([5,1], [0.0, 0.5, 1.0, 1.5, 2.0]))
434446
end
435447

436448
it "logspace() creates a vector with n values logarithmically spaced between decades 10^a and 10^b" do
449+
pending("not yet implemented for NMatrix-JRuby") if jruby?
437450
v = NVector.logspace(0, 3, 4)
438451
expect(v).to eq(NMatrix.new([4,1], [1.0, 10.0, 100.0, 1000.0]))
439452
end

0 commit comments

Comments
 (0)