multiarray 0.9.0 → 0.10.1

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.9.0'
9
+ PKG_VERSION = '0.10.1'
10
10
  RB_FILES = FileList[ 'lib/**/*.rb' ]
11
11
  TC_FILES = FileList[ 'test/tc_*.rb' ]
12
12
  TS_FILES = FileList[ 'test/ts_*.rb' ]
@@ -362,6 +362,10 @@ module Hornetseye
362
362
  array_type.size
363
363
  end
364
364
 
365
+ def storage_size
366
+ array_type.storage_size
367
+ end
368
+
365
369
  def memory
366
370
  nil
367
371
  end
@@ -252,6 +252,27 @@ module Hornetseye
252
252
  min .. max
253
253
  end
254
254
 
255
+ def normalise( range = 0 .. 0xFF )
256
+ if range.exclude_end?
257
+ raise "Normalisation does not support ranges with end value " +
258
+ "excluded (such as #{range})"
259
+ end
260
+ lower, upper = min, max
261
+ if lower.is_a? RGB or upper.is_a? RGB
262
+ current = [ lower.r, lower.g, lower.b ].min ..
263
+ [ upper.r, upper.g, upper.b ].max
264
+ else
265
+ current = min .. max
266
+ end
267
+ if current.last != current.first
268
+ factor =
269
+ ( range.last - range.first ).to_f / ( current.last - current.first )
270
+ self * factor + ( range.first - current.first * factor )
271
+ else
272
+ self + ( range.first - current.first )
273
+ end
274
+ end
275
+
255
276
  def fill!( value = typecode.default )
256
277
  self[] = value
257
278
  self
data/test/tc_sequence.rb CHANGED
@@ -302,6 +302,11 @@ class TC_Sequence < Test::Unit::TestCase
302
302
  assert_equal C( 3, 2, 3 ), S[ C( 1, 2, 3 ), C( 3, 2, 1 ) ].max
303
303
  end
304
304
 
305
+ def test_normalise
306
+ assert_equal [ 0.0, 85.0, 255.0 ], S[ 1, 2, 4 ].normalise.to_a
307
+ assert_equal [ C( 0.0, 85.0, 255.0 ) ], S[ C( 1, 2, 4 ) ].normalise.to_a
308
+ end
309
+
305
310
  def test_sum
306
311
  [ S( O, 3 ), S( I, 3 ) ].each do |t|
307
312
  assert_equal 9, t[ 4, 2, 3 ].sum
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 9
8
- - 0
9
- version: 0.9.0
7
+ - 10
8
+ - 1
9
+ version: 0.10.1
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-12 00:00:00 +01:00
17
+ date: 2010-10-13 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency