This is an automated email from the git hooks/post-receive script. uwabami-guest pushed a commit to branch upstream in repository narray-miss.
commit a582b7724f42c7926243f94c9a4aa6294c650869 Author: Youhei SASAKI <[email protected]> Date: Tue Mar 1 18:20:00 2016 +0900 Imported Upstream version 1.3.0 --- LICENSE.txt | 2 +- README.rdoc | 4 +- lib/narray_miss/narray_miss.rb | 153 ++++++++++++++++++++++++----------------- lib/narray_miss/version.rb | 2 +- metadata.yml | 24 +++---- narray_miss.gemspec | 18 +++-- test/test_narray_miss.rb | 1 + 7 files changed, 121 insertions(+), 83 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index fc237ef..0a8b77e 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,7 +1,7 @@ NArrayMiss is copyrighted free software by Seiya Nishizawa and GFD Dennou Club (http://www.gfd-dennou.org/). -Copyright 2001-2012 (C) Seiya Nishizawa and GFD Dennou Club +Copyright 2001-2016 (C) Seiya Nishizawa and GFD Dennou Club (http://www.gfd-dennou.org/) All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/README.rdoc b/README.rdoc index 2b4a252..54c8d69 100644 --- a/README.rdoc +++ b/README.rdoc @@ -13,7 +13,9 @@ The URL of the NArrayMiss home-page is: = Requires * Ruby (http://www.ruby-lang.org/) -* NArray (http://narray.rubyforge.org/index.html.en) +* NumRu-NArray or NArray + * NumRu-NArray: https://github.com/seiya/numru-narray/ + * NArray: http://narray.rubyforge.org/index.html.en = Install diff --git a/lib/narray_miss/narray_miss.rb b/lib/narray_miss/narray_miss.rb index c7138df..0071431 100644 --- a/lib/narray_miss/narray_miss.rb +++ b/lib/narray_miss/narray_miss.rb @@ -34,7 +34,19 @@ To use NArrayMiss class, you need invoking "require 'narray_miss.rb'" in your sc =end -require 'narray' +begin + require 'numru/narray' + NARRAY = NumRu::NArray +rescue LoadError + err = $! + begin + require 'narray' + NARRAY = NArray + rescue LoadError + STDERR.puts "You should install numru-narray or narray" + raise err + end +end class NArrayMiss @@ -45,7 +57,7 @@ class NArrayMiss type code for 1 byte unsigned integer. --- NArrayMiss::SINT type code for 2 byte signed integer. ---- NArrayMiss::INT +--- NArrayMiss::LINT type code for 4 byte signed integer. --- NArrayMiss::SFLOAT type code for single precision float. @@ -61,14 +73,23 @@ class NArrayMiss go back to ((<Index>)) =end - BYTE = NArray::BYTE - SINT = NArray::SINT - INT = NArray::INT - SFLOAT = NArray::SFLOAT - FLOAT = NArray::FLOAT - SCOMPLEX = NArray::SCOMPLEX - COMPLEX = NArray::COMPLEX - OBJECT = NArray::OBJECT + BYTE = NARRAY::BYTE + SINT = NARRAY::SINT + INT = NARRAY::INT + LINT = NARRAY::LINT + if NARRAY.const_defined?(:LLINT) + LLINT = NARRAY::LINT + MINT = LLINT # int for mask operations + @@llint = true + else + MINT = LINT # int for mask operations + @@llint = false + end + SFLOAT = NARRAY::SFLOAT + FLOAT = NARRAY::FLOAT + SCOMPLEX = NARRAY::SCOMPLEX + COMPLEX = NARRAY::COMPLEX + OBJECT = NARRAY::OBJECT class << self alias :__new__ :new @@ -94,7 +115,7 @@ go back to ((<Index>)) --- NArrayMiss.sint(size, ...) same as NArrayMiss.new(NArrayMiss::SINT, ((|size|)), ...). --- NArrayMiss.int(size, ...) - same as NArrayMiss.new(NArrayMiss::INT, ((|size|)), ...). + same as NArrayMiss.new(NArrayMiss::LINT, ((|size|)), ...). --- NArrayMiss.sfloat(size, ...) same as NArrayMiss.new(NArrayMiss::SFLOAT, ((|size|)), ...). --- NArrayMiss.float(size, ...) @@ -117,8 +138,8 @@ go back to ((<Index>)) =end def self.new(*arg) - array = NArray.new(*arg) - mask = NArray.byte(*arg[1..-1]) + array = NARRAY.new(*arg) + mask = NARRAY.byte(*arg[1..-1]) __new__(array, mask) end def self.byte(*arg) @@ -130,6 +151,14 @@ go back to ((<Index>)) def self.int(*arg) NArrayMiss.new(INT,*arg) end + def self.lint(*arg) + NArrayMiss.new(LINT,*arg) + end + if @@llint + def self.llint(*arg) + NArrayMiss.new(LLINT,*arg) + end + end def self.sfloat(*arg) NArrayMiss.new(SFLOAT,*arg) end @@ -146,7 +175,7 @@ go back to ((<Index>)) NArrayMiss.new(OBJECT,*arg) end def self.[](*arg) - NArrayMiss.to_nam(NArray[*arg]) + NArrayMiss.to_nam(NARRAY[*arg]) end def self.to_nam_no_dup(*arg) if arg.length > 2 || arg.length==0 then @@ -154,9 +183,9 @@ go back to ((<Index>)) end array = arg[0] - if Numeric===array then array = NArray[array] end - if Array===array then array = NArray.to_na(array) end - if !array.is_a?(NArray) then + if Numeric===array then array = NARRAY[array] end + if Array===array then array = NARRAY.to_na(array) end + if !array.is_a?(NARRAY) then raise("argument must be Numeric, NArray or Array") end @@ -164,27 +193,27 @@ go back to ((<Index>)) mask = arg[1] if Numeric===mask then mask = array.ne(mask) end if Array===mask then - mask = NArray.to_na(mask).ne(0) + mask = NARRAY.to_na(mask).ne(0) end if mask.class == FalseClass then - mask = NArray.byte(*array.shape) + mask = NARRAY.byte(*array.shape) end if mask.class == TrueClass then - mask = NArray.byte(*array.shape).fill(1) + mask = NARRAY.byte(*array.shape).fill(1) end - if !(NArray===mask && mask.typecode==BYTE) then + if !(NARRAY===mask && mask.typecode==BYTE) then raise("mask must be Numeric, Array, true, false or NArray(byte)") end if mask.length!=array.length raise "mask.length must be same as array.length" end else - mask = NArray.byte(*array.shape).fill(1) + mask = NARRAY.byte(*array.shape).fill(1) end __new__(array,mask) end def self.to_nam(*arg) - if !(Numeric===arg[0]) && !(Array===arg[0]) && !arg[0].is_a?(NArray) + if !(Numeric===arg[0]) && !(Array===arg[0]) && !arg[0].is_a?(NARRAY) raise "first argument must be Numeric, NArray or Array" end arg[0] = arg[0].dup if !(Numeric===arg[0]) @@ -551,7 +580,7 @@ go back to ((<Index>)) array = @array.dup array[@mask.not] = 0 return NArrayMiss.to_nam_no_dup(array.accum(*arg), - @mask.to_type(NArray::INT).accum(*arg).ne(0)) + @mask.to_type(MINT).accum(*arg).ne(0)) end end @@ -588,7 +617,7 @@ go back to ((<Index>)) def mean(*dims) min_count = NArrayMiss.check_options(dims, 1) # 整数型の場合は浮動小数型へ変換 - ary0 = self.integer? ? self.to_type(NArray::DFLOAT) : self + ary0 = self.integer? ? self.to_type(NARRAY::DFLOAT) : self NArrayMiss.reduction(@mask, rank, min_count, dims, true, typecode) do |count_sum, count_accum| ary0.sum(*dims)/count_sum end @@ -596,7 +625,7 @@ go back to ((<Index>)) def stddev(*dims) min_count = NArrayMiss.check_options(dims, 2) # 整数型の場合は浮動小数型へ変換 - ary0 = self.integer? ? self.to_type(NArray::DFLOAT) : self + ary0 = self.integer? ? self.to_type(NARRAY::DFLOAT) : self NArrayMiss.reduction(@mask, rank, min_count, dims, true, typecode) do |count_sum, count_accum| ary0 = ary0 - ary0.accum(*dims)/count_accum ary0 = ary0.abs if ary0.complex? @@ -607,7 +636,7 @@ go back to ((<Index>)) def rms(*dims) min_count = NArrayMiss.check_options(dims, 1) # 整数型の場合は浮動小数型へ変換 - ary0 = self.integer? ? self.to_type(NArray::DFLOAT) : self + ary0 = self.integer? ? self.to_type(NARRAY::DFLOAT) : self NArrayMiss.reduction(@mask, rank, min_count, dims, true, typecode) do |count_sum, count_accum| ary0 = ary0.abs if ary0.complex? ary0 = (ary0**2).sum(*dims) / count_sum @@ -617,7 +646,7 @@ go back to ((<Index>)) def rmsdev(*dims) min_count = NArrayMiss.check_options(dims, 1) # 整数型の場合は浮動小数型へ変換 - ary0 = self.integer? ? self.to_type(NArray::DFLOAT) : self + ary0 = self.integer? ? self.to_type(NARRAY::DFLOAT) : self NArrayMiss.reduction(@mask, rank, min_count, dims, true, typecode) do |count_sum, count_accum| ary0 = ary0 - ary0.accum(*dims)/count_accum ary0 = ary0.abs if ary0.complex? @@ -630,17 +659,17 @@ go back to ((<Index>)) if arg.length==0 then return @array[@mask].median else - nshape = NArray.to_na(@array.shape) + nshape = NARRAY.to_na(@array.shape) nshape[arg]=1 nslice = nshape[nshape.ne(1).where] - index = NArray.object(@mask.rank) + index = NARRAY.object(@mask.rank) index[nshape.eq(1).where] = true obj = NArrayMiss.new(@array.typecode,*nslice.to_a) total = 1 nslice.each{|n| total *= n} for i in 0...total index[nshape.ne(1).where] = pos(i,nslice) - mask = NArray.byte(*@array.shape).fill(0) + mask = NARRAY.byte(*@array.shape).fill(0) mask[*index] = 1 mask = @mask&mask if mask.count_true != 0 then @@ -668,17 +697,17 @@ go back to ((<Index>)) obj[@mask] = @array[@mask].#{operator} return obj else - nshape = NArray.to_na(@array.shape) + nshape = NARRAY.to_na(@array.shape) nshape[arg]=1 nslice = nshape[nshape.ne(1).where] - index = NArray.object(@mask.rank) + index = NARRAY.object(@mask.rank) index[nshape.eq(1).where] = true obj = NArrayMiss.new(@array.typecode,*@array.shape) total = 1 nslice.each{|n| total *= n} for i in 0...total index[nshape.ne(1).where] = pos(i,nslice) - mask = NArray.byte(*@array.shape).fill(0) + mask = NARRAY.byte(*@array.shape).fill(0) mask[*index] = 1 mask = @mask&mask if mask.count_true != 0 then @@ -807,7 +836,7 @@ go back to ((<Index>)) self.set_missing_value!(arg[0]) return @array else - raise(ArgumentError, "Usage: NArray#to_na([missing_value])") + raise(ArgumentError, "Usage: NArrayMiss#to_na([missing_value])") end end def to_na(*arg) @@ -1048,14 +1077,14 @@ go back to ((<Index>)) end def set_mask(mask) if mask.class == Array then - tmp = NArray.byte(*@mask.shape) + tmp = NARRAY.byte(*@mask.shape) tmp[true] = mask mask = tmp end if mask.class == NArrayMiss then mask = mask.to_na(0) end - if mask.class == NArray then + if mask.class == NARRAY then if mask.typecode != BYTE then raise("mask must be NArrayMiss.byte, NArray.byte or Array") end @@ -1124,15 +1153,15 @@ go back to ((<Index>)) if arg.length==0 then return @mask.count_true else - return @mask.to_type(NArray::INT).sum(*arg) + return @mask.to_type(MINT).sum(*arg) end end def count_invalid(*arg) if arg.length==0 then return @mask.count_false else - return NArray.int(*@mask.shape).fill(1).sum(*arg)- - @mask.to_type(NArray::INT).sum(*arg) + return NARRAY.int(*@mask.shape).fill(1).sum(*arg)- + @mask.to_type(MINT).sum(*arg) end end @@ -1172,8 +1201,8 @@ go back to ((<Index>)) def coerce(x) if Numeric===x then - return [NArrayMiss.new(NArray[x].typecode,*self.shape).fill(x),self] - elsif x.class==Array || x.class==NArray then + return [NArrayMiss.new(NARRAY[x].typecode,*self.shape).fill(x),self] + elsif x.class==Array || x.class==NARRAY then return [NArrayMiss.to_nam(x), self] else raise("donnot know how to cange #{x.class} to NArrayMiss") @@ -1188,7 +1217,7 @@ go back to ((<Index>)) max_col = 80 sep = ", " const = Hash.new - NArray.constants.each{|c| const[NArray.const_get(c)] = c} + NARRAY.constants.each{|c| const[NARRAY.const_get(c)] = c} str_ret = "NArrayMiss."+const[typecode].to_s.downcase+"("+shape.join(",")+"):" if rank == 0 then str_ret << " []" @@ -1250,8 +1279,8 @@ go back to ((<Index>)) end def self._load(o) ary, mask = Marshal::load(o) - ary = NArray._load(ary) - mask = NArray._load(mask) + ary = NARRAY._load(ary) + mask = NARRAY._load(mask) NArrayMiss.to_nam_no_dup(ary,mask) end @@ -1262,7 +1291,7 @@ go back to ((<Index>)) private def pos(n,shape) rank = shape.length - result = NArray.int(rank) + result = NARRAY.int(rank) m=n for i in 0..rank-2 j = rank-1-i @@ -1281,11 +1310,11 @@ go back to ((<Index>)) term1 = @array term2 = arg mask = @mask - when Array, NArray + when Array, NARRAY term1 = @array.dup term1[@mask.not] = dummy # 欠損部分に dummy を代入 - term2 = arg.kind_of?(NArray) ? arg : NArray.to_na(arg) # Array -> NArray - mask = NArray.byte(*term2.shape).fill(1) # 2項目は欠損無し + term2 = arg.kind_of?(NARRAY) ? arg : NARRAY.to_na(arg) # Array -> NArray + mask = NARRAY.byte(*term2.shape).fill(1) # 2項目は欠損無し mask = @mask & mask when NArrayMiss term1 = @array.dup @@ -1307,13 +1336,13 @@ go back to ((<Index>)) def self.reduction(mask, rank, min_count, dims, flag, typecode) # flag: リダクションを行う次元方向の有効な値の個数で、割り算を行うかどうかのフラグ - count_sum = mask.to_type(NArray::LINT).sum(*dims) + count_sum = mask.to_type(MINT).sum(*dims) # 返り値が配列か、スカラーかによって分岐 - if count_sum.kind_of?(NArray) + if count_sum.kind_of?(NARRAY) mask = count_sum.ge(min_count) # すべての要素が欠損値にならないかチェック if mask.any? - count_accum = NArray.ref(count_sum) + count_accum = NARRAY.ref(count_sum) dims.collect{|d|d<0 ? d+rank : d}.sort.each do |d| count_accum.newdim!(d) end @@ -1326,13 +1355,13 @@ go back to ((<Index>)) ary = NArrayMiss.to_nam_no_dup(ary, mask) unless flag else # すべての要素が欠損値の NArrayMiss を返す - na = NArray.new(typecode, *mask.shape) + na = NARRAY.new(typecode, *mask.shape) ary = NArrayMiss.to_nam_no_dup(na, false) end else # 有効な要素数があるかチェック if count_sum >= min_count - count_accum = NArray.int(*([1]*mask.rank)).fill!(count_sum) + count_accum = NARRAY.int(*([1]*mask.rank)).fill!(count_sum) ary = yield(count_sum, count_accum) else # 有効な要素数が足りない場合は nil を返す @@ -1383,7 +1412,7 @@ module NMMath eval <<-EOL,nil,__FILE__,__LINE__+1 def #{operator}(x) case x - when Numeric, Array, NArray + when Numeric, Array, NARRAY NMath::#{operator}(x) when NArrayMiss obj = NArrayMiss.new(x.typecode,*x.shape) @@ -1405,7 +1434,7 @@ module NMMath def #{operator}(x,y) obj = nil case x - when Numeric, Array, NArray + when Numeric, Array, NARRAY mask1 = nil when NArrayMiss obj = NArrayMiss.new(x.typecode,*x.shape) @@ -1414,7 +1443,7 @@ module NMMath raise ArgumentError, "argument is invalid class" end case y - when Numeric, Array, NArray + when Numeric, Array, NARRAY mask2 = nil when NArrayMiss obj ||= NArrayMiss.new(y.typecode,*y.shape) @@ -1460,7 +1489,7 @@ module NMMath def #{name}(ary0,ary1,*dims) min_count = NArrayMiss.check_options(dims, 2) case ary0 - when Numeric, Array, NArray + when Numeric, Array, NARRAY mask0 = nil when NArrayMiss mask0 = ary0.get_mask! @@ -1468,7 +1497,7 @@ module NMMath raise ArgumentError, "argument is invalid class" end case ary1 - when Numeric, Array, NArray + when Numeric, Array, NARRAY mask1 = nil when NArrayMiss mask1 = ary1.get_mask! @@ -1489,12 +1518,12 @@ module NMMath if ary1.shape != ary1.shape raise "shape is different" end - ary0 = ary0.to_type(NArray::DFLOAT) - ary1 = ary1.to_type(NArray::DFLOAT) + ary0 = ary0.to_type(NARRAY::DFLOAT) + ary1 = ary1.to_type(NARRAY::DFLOAT) mask = mask0.nil? ? mask1 : mask1.nil? ? mask0 : mask0&mask1 ary0.set_mask(mask) ary1.set_mask(mask) - NArrayMiss.reduction(mask, ary0.rank, min_count, dims, true, NArray::DFLOAT) do |count_sum, count_accum| + NArrayMiss.reduction(mask, ary0.rank, min_count, dims, true, NARRAY::DFLOAT) do |count_sum, count_accum| #{hash[:post]} end end diff --git a/lib/narray_miss/version.rb b/lib/narray_miss/version.rb index 888c8fe..b9eca9b 100644 --- a/lib/narray_miss/version.rb +++ b/lib/narray_miss/version.rb @@ -1,3 +1,3 @@ class NArrayMiss - VERSION = "1.2.8" + VERSION = "1.3.0" end diff --git a/metadata.yml b/metadata.yml index 0f32349..d94c8e6 100644 --- a/metadata.yml +++ b/metadata.yml @@ -1,30 +1,27 @@ --- !ruby/object:Gem::Specification name: narray_miss version: !ruby/object:Gem::Version - version: 1.2.8 - prerelease: + version: 1.3.0 platform: ruby authors: - Seiya Nishizawa autorequire: bindir: bin cert_chain: [] -date: 2012-07-09 00:00:00.000000000 Z +date: 2016-02-15 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency - name: narray + name: numru-narray requirement: !ruby/object:Gem::Requirement - none: false requirements: - - - ! '>=' + - - ">=" - !ruby/object:Gem::Version version: '0' type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement - none: false requirements: - - - ! '>=' + - - ">=" - !ruby/object:Gem::Version version: '0' description: NArrayMiss is an additional class with processing of missing value to @@ -46,27 +43,26 @@ files: - test/test_narray_miss.rb homepage: http://ruby.gfd-dennou.org/products/narray_miss/ licenses: [] +metadata: {} post_install_message: rdoc_options: [] require_paths: - lib required_ruby_version: !ruby/object:Gem::Requirement - none: false requirements: - - - ! '>=' + - - ">=" - !ruby/object:Gem::Version version: '0' required_rubygems_version: !ruby/object:Gem::Requirement - none: false requirements: - - - ! '>=' + - - ">=" - !ruby/object:Gem::Version version: '0' requirements: [] rubyforge_project: narray_miss -rubygems_version: 1.8.24 +rubygems_version: 2.4.8 signing_key: -specification_version: 3 +specification_version: 4 summary: Additional class with processing of missing value to NArray test_files: - test/test_narray_miss.rb diff --git a/narray_miss.gemspec b/narray_miss.gemspec index daa6165..f8582db 100644 --- a/narray_miss.gemspec +++ b/narray_miss.gemspec @@ -13,13 +13,23 @@ Gem::Specification.new do |s| s.rubyforge_project = "narray_miss" - s.files = `git ls-files`.split("\n") - s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") - s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } + s.files = [ + "Gemfile", + "LICENSE.txt", + "README.rdoc", + "Rakefile", + "lib/narray_miss.rb", + "lib/narray_miss/narray_miss.rb", + "lib/narray_miss/version.rb", + "narray_miss.gemspec", + "test/test_narray_miss.rb" + ] + s.test_files = [ "test/test_narray_miss.rb" ] + s.executables = [] s.require_paths = ["lib"] #s.extensions << "ext/extconf.rb" # specify any dependencies here; for example: #s.add_development_dependency "rspec" - s.add_runtime_dependency "narray" + s.add_runtime_dependency "numru-narray" end diff --git a/test/test_narray_miss.rb b/test/test_narray_miss.rb index eee1cf0..eda37c7 100644 --- a/test/test_narray_miss.rb +++ b/test/test_narray_miss.rb @@ -1,6 +1,7 @@ $:.unshift File.join(File.dirname(__FILE__), "..", "lib") require "narray_miss" require "test/unit" +include NumRu if defined?(:NumRu) class NArrayMissTest < Test::Unit::TestCase -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/narray-miss.git _______________________________________________ Pkg-grass-devel mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-grass-devel

