multiarray 0.10.1 → 0.10.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/multiarray/gccvalue.rb +22 -0
- data/lib/multiarray/operations.rb +4 -3
- data/lib/multiarray/rgb.rb +4 -0
- data/test/tc_multiarray.rb +3 -0
- data/test/tc_sequence.rb +4 -0
- metadata +3 -3
data/Rakefile
CHANGED
data/lib/multiarray/gccvalue.rb
CHANGED
@@ -173,6 +173,28 @@ module Hornetseye
|
|
173
173
|
GCCValue.new @function, "( #{self} ) ? ( #{a} ) : ( #{b} )"
|
174
174
|
end
|
175
175
|
|
176
|
+
def conditional_with_rgb( a, b )
|
177
|
+
if a.is_a?( RGB ) or b.is_a?( RGB )
|
178
|
+
Hornetseye::RGB( conditional( a.r, b.r ), conditional( a.g, b.g ),
|
179
|
+
conditional( a.b, b.b ) )
|
180
|
+
else
|
181
|
+
conditional_without_rgb a, b
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
alias_method_chain :conditional, :rgb
|
186
|
+
|
187
|
+
def conditional_with_complex( a, b )
|
188
|
+
if a.is_a?( InternalComplex ) or b.is_a?( InternalComplex )
|
189
|
+
InternalComplex.new conditional( a.real, b.real ),
|
190
|
+
conditional( a.imag, b.imag )
|
191
|
+
else
|
192
|
+
conditional_without_complex a, b
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
alias_method_chain :conditional, :complex
|
197
|
+
|
176
198
|
define_unary_op :not, '!'
|
177
199
|
define_unary_op :~
|
178
200
|
define_unary_op :-@, :-
|
@@ -423,9 +423,10 @@ module Hornetseye
|
|
423
423
|
raise "#{i+1}th dimension of index must be in 0 ... #{table.shape[i]} " +
|
424
424
|
"(but was #{range.begin})"
|
425
425
|
end
|
426
|
-
|
427
|
-
|
428
|
-
|
426
|
+
offset = table.dimension - source.shape.first
|
427
|
+
if range.end >= table.shape[ i + offset ]
|
428
|
+
raise "#{i+1}th dimension of index must be in 0 ... " +
|
429
|
+
"#{table.shape[ i + offset ]} (but was #{range.end})"
|
429
430
|
end
|
430
431
|
end
|
431
432
|
end
|
data/lib/multiarray/rgb.rb
CHANGED
data/test/tc_multiarray.rb
CHANGED
@@ -442,11 +442,14 @@ class TC_MultiArray < Test::Unit::TestCase
|
|
442
442
|
M[ [ 0, 1 ], [ 2, 0 ] ].lut( S[ 1, 2, 3, 4 ] )
|
443
443
|
assert_equal M[ 1, 3, 4 ],
|
444
444
|
M[ [ 0, 0 ], [ 0, 1 ], [ 1, 1 ] ].lut( M[ [ 1, 2 ], [ 3, 4 ] ] )
|
445
|
+
assert_equal M[ [ 3, 4 ], [ 1, 2 ] ],
|
446
|
+
M[ [ 1 ], [ 0 ] ].lut( M[ [ 1, 2 ], [ 3, 4 ] ] )
|
445
447
|
assert_raise( RuntimeError ) { S[ 0, 1, 2 ].lut M[ [ 1, 2 ], [ 3, 4 ] ] }
|
446
448
|
assert_raise( RuntimeError ) { M[ [ -1, 0 ] ].lut M[ [ 1, 2 ] ] }
|
447
449
|
assert_raise( RuntimeError ) { M[ [ 0, -1 ] ].lut M[ [ 1, 2 ] ] }
|
448
450
|
assert_raise( RuntimeError ) { M[ [ 2, 0 ] ].lut M[ [ 1, 2 ] ] }
|
449
451
|
assert_raise( RuntimeError ) { M[ [ 0, 1 ] ].lut M[ [ 1, 2 ] ] }
|
452
|
+
assert_raise( RuntimeError ) { M[ [ 1 ], [ 2 ] ].lut M[ [ 1, 2 ], [ 3, 4 ] ] }
|
450
453
|
end
|
451
454
|
|
452
455
|
def test_zero
|
data/test/tc_sequence.rb
CHANGED
@@ -580,6 +580,10 @@ class TC_Sequence < Test::Unit::TestCase
|
|
580
580
|
assert_equal S[ -1, 2 ], S[ false, true ].conditional( S[ 1, 2 ], -1 )
|
581
581
|
assert_equal S[ -1, 1 ], S[ false, true ].conditional( 1, S[ -1, -2 ] )
|
582
582
|
assert_equal S[ -1, 2 ], S[ false, true ].conditional( S[ 1, 2 ], S[ -1, -2 ] )
|
583
|
+
assert_equal S[ C( 4, 5, 6 ), C( 1, 2, 3 ) ],
|
584
|
+
S[ false, true ].conditional( C( 1, 2, 3 ), C( 4, 5, 6 ) )
|
585
|
+
assert_equal S[ X( 3, 4 ), X( 1, 2 ) ],
|
586
|
+
S[ false, true ].conditional( X( 1, 2 ), X( 3, 4 ) )
|
583
587
|
assert_raise( RuntimeError ) { S[ false, true ].conditional( S[ 1, 2 ], S[ 1 ] ) }
|
584
588
|
assert_raise( RuntimeError ) { S[ false, true ].conditional( S[ 1 ], S[ 1, 2 ] ) }
|
585
589
|
assert_raise( RuntimeError ) { S[ false ].conditional( S[ 1, 2 ], S[ 1, 2 ] ) }
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 10
|
8
|
-
-
|
9
|
-
version: 0.10.
|
8
|
+
- 2
|
9
|
+
version: 0.10.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Jan Wedekind
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-10-
|
17
|
+
date: 2010-10-14 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|