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 CHANGED
@@ -6,7 +6,7 @@ require 'rake/packagetask'
6
6
  require 'rbconfig'
7
7
 
8
8
  PKG_NAME = 'multiarray'
9
- PKG_VERSION = '0.10.1'
9
+ PKG_VERSION = '0.10.2'
10
10
  RB_FILES = FileList[ 'lib/**/*.rb' ]
11
11
  TC_FILES = FileList[ 'test/tc_*.rb' ]
12
12
  TS_FILES = FileList[ 'test/ts_*.rb' ]
@@ -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
- if range.end >= table.shape[ i ]
427
- raise "#{i+1}th dimension of index must be in 0 ... #{table.shape[i]} " +
428
- "(but was #{range.end})"
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
@@ -179,6 +179,10 @@ module Hornetseye
179
179
 
180
180
  end
181
181
 
182
+ end
183
+
184
+ module Hornetseye
185
+
182
186
  class RGB_ < Composite
183
187
 
184
188
  class << self
@@ -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
- - 1
9
- version: 0.10.1
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-13 00:00:00 +01:00
17
+ date: 2010-10-14 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency