narray_miss 1.2.7 → 1.2.8
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/narray_miss/narray_miss.rb +10 -10
- data/lib/narray_miss/version.rb +1 -1
- data/test/test_narray_miss.rb +4 -0
- metadata +36 -51
@@ -560,7 +560,7 @@ go back to ((<Index>))
|
|
560
560
|
# 欠損値に 0 を入れて普通に sum する
|
561
561
|
ary0 = @array.dup
|
562
562
|
ary0[@mask.not] = 0
|
563
|
-
NArrayMiss.reduction(@mask, min_count, dims, false, typecode) do
|
563
|
+
NArrayMiss.reduction(@mask, rank, min_count, dims, false, typecode) do
|
564
564
|
ary0.sum(*dims)
|
565
565
|
end
|
566
566
|
end
|
@@ -570,7 +570,7 @@ go back to ((<Index>))
|
|
570
570
|
# byte,sint,int,sfloat,float の MAX の値を入れるように変更すべき
|
571
571
|
ary0 = @array.dup
|
572
572
|
ary0[@mask.not] = @array.max
|
573
|
-
NArrayMiss.reduction(@mask, min_count, dims, false, typecode) do
|
573
|
+
NArrayMiss.reduction(@mask, rank, min_count, dims, false, typecode) do
|
574
574
|
ary0.min(*dims)
|
575
575
|
end
|
576
576
|
end
|
@@ -580,7 +580,7 @@ go back to ((<Index>))
|
|
580
580
|
# byte,sint,int,sfloat,float の MIN の値を入れるように変更すべき
|
581
581
|
ary0 = @array.dup
|
582
582
|
ary0[@mask.not] = @array.min
|
583
|
-
NArrayMiss.reduction(@mask, min_count, dims, false, typecode) do
|
583
|
+
NArrayMiss.reduction(@mask, rank, min_count, dims, false, typecode) do
|
584
584
|
ary0.max(*dims)
|
585
585
|
end
|
586
586
|
end
|
@@ -589,7 +589,7 @@ go back to ((<Index>))
|
|
589
589
|
min_count = NArrayMiss.check_options(dims, 1)
|
590
590
|
# 整数型の場合は浮動小数型へ変換
|
591
591
|
ary0 = self.integer? ? self.to_type(NArray::DFLOAT) : self
|
592
|
-
NArrayMiss.reduction(@mask, min_count, dims, true, typecode) do |count_sum, count_accum|
|
592
|
+
NArrayMiss.reduction(@mask, rank, min_count, dims, true, typecode) do |count_sum, count_accum|
|
593
593
|
ary0.sum(*dims)/count_sum
|
594
594
|
end
|
595
595
|
end
|
@@ -597,7 +597,7 @@ go back to ((<Index>))
|
|
597
597
|
min_count = NArrayMiss.check_options(dims, 2)
|
598
598
|
# 整数型の場合は浮動小数型へ変換
|
599
599
|
ary0 = self.integer? ? self.to_type(NArray::DFLOAT) : self
|
600
|
-
NArrayMiss.reduction(@mask, min_count, dims, true, typecode) do |count_sum, count_accum|
|
600
|
+
NArrayMiss.reduction(@mask, rank, min_count, dims, true, typecode) do |count_sum, count_accum|
|
601
601
|
ary0 = ary0 - ary0.accum(*dims)/count_accum
|
602
602
|
ary0 = ary0.abs if ary0.complex?
|
603
603
|
ary0 = (ary0**2).sum(*dims) / (count_sum-1)
|
@@ -608,7 +608,7 @@ go back to ((<Index>))
|
|
608
608
|
min_count = NArrayMiss.check_options(dims, 1)
|
609
609
|
# 整数型の場合は浮動小数型へ変換
|
610
610
|
ary0 = self.integer? ? self.to_type(NArray::DFLOAT) : self
|
611
|
-
NArrayMiss.reduction(@mask, min_count, dims, true, typecode) do |count_sum, count_accum|
|
611
|
+
NArrayMiss.reduction(@mask, rank, min_count, dims, true, typecode) do |count_sum, count_accum|
|
612
612
|
ary0 = ary0.abs if ary0.complex?
|
613
613
|
ary0 = (ary0**2).sum(*dims) / count_sum
|
614
614
|
NMMath.sqrt(ary0)
|
@@ -618,7 +618,7 @@ go back to ((<Index>))
|
|
618
618
|
min_count = NArrayMiss.check_options(dims, 1)
|
619
619
|
# 整数型の場合は浮動小数型へ変換
|
620
620
|
ary0 = self.integer? ? self.to_type(NArray::DFLOAT) : self
|
621
|
-
NArrayMiss.reduction(@mask, min_count, dims, true, typecode) do |count_sum, count_accum|
|
621
|
+
NArrayMiss.reduction(@mask, rank, min_count, dims, true, typecode) do |count_sum, count_accum|
|
622
622
|
ary0 = ary0 - ary0.accum(*dims)/count_accum
|
623
623
|
ary0 = ary0.abs if ary0.complex?
|
624
624
|
ary0 = (ary0**2).sum(*dims) / count_sum
|
@@ -1305,7 +1305,7 @@ go back to ((<Index>))
|
|
1305
1305
|
end
|
1306
1306
|
|
1307
1307
|
|
1308
|
-
def self.reduction(mask, min_count, dims, flag, typecode)
|
1308
|
+
def self.reduction(mask, rank, min_count, dims, flag, typecode)
|
1309
1309
|
# flag: リダクションを行う次元方向の有効な値の個数で、割り算を行うかどうかのフラグ
|
1310
1310
|
count_sum = mask.to_type(NArray::LINT).sum(*dims)
|
1311
1311
|
# 返り値が配列か、スカラーかによって分岐
|
@@ -1314,7 +1314,7 @@ go back to ((<Index>))
|
|
1314
1314
|
# すべての要素が欠損値にならないかチェック
|
1315
1315
|
if mask.any?
|
1316
1316
|
count_accum = NArray.ref(count_sum)
|
1317
|
-
dims.collect{|d|d<0 ? d+
|
1317
|
+
dims.collect{|d|d<0 ? d+rank : d}.sort.each do |d|
|
1318
1318
|
count_accum.newdim!(d)
|
1319
1319
|
end
|
1320
1320
|
# 割り算を行う場合は、先に count_sum を NArrayMiss 化
|
@@ -1494,7 +1494,7 @@ module NMMath
|
|
1494
1494
|
mask = mask0.nil? ? mask1 : mask1.nil? ? mask0 : mask0&mask1
|
1495
1495
|
ary0.set_mask(mask)
|
1496
1496
|
ary1.set_mask(mask)
|
1497
|
-
NArrayMiss.reduction(mask, min_count, dims, true, NArray::DFLOAT) do |count_sum, count_accum|
|
1497
|
+
NArrayMiss.reduction(mask, ary0.rank, min_count, dims, true, NArray::DFLOAT) do |count_sum, count_accum|
|
1498
1498
|
#{hash[:post]}
|
1499
1499
|
end
|
1500
1500
|
end
|
data/lib/narray_miss/version.rb
CHANGED
data/test/test_narray_miss.rb
CHANGED
@@ -17,12 +17,14 @@ EOF
|
|
17
17
|
|
18
18
|
def setup
|
19
19
|
@n = 4
|
20
|
+
@m = 3
|
20
21
|
@mask = NArray.byte(@n,@n)
|
21
22
|
@mask[true,0] = 1
|
22
23
|
@mask[1..-1,1] = 1
|
23
24
|
@mask[-1,2] = 1
|
24
25
|
@float = NArrayMiss.float(@n,@n).indgen; @float.set_mask(@mask)
|
25
26
|
@int = NArrayMiss.int(@n,@n).indgen; @int.set_mask(@mask)
|
27
|
+
@float3d = NArrayMiss.float(@n,@m,@n).indgen
|
26
28
|
=begin
|
27
29
|
@float #=>
|
28
30
|
NArrayMiss.dfloat(4,4):
|
@@ -94,6 +96,8 @@ NArrayMiss.dfloat(4,4):
|
|
94
96
|
ary = [0, NArray[1,5].stddev, NArray[2,6].stddev, NArray[3,7,11].stddev]
|
95
97
|
assert_equal(NArrayMiss.to_nam(ary,[0,1,1,1]), @float.stddev(1))
|
96
98
|
assert_equal(NArrayMiss.to_nam(ary,[0,0,0,1]), @float.stddev(1, "min_count"=>3))
|
99
|
+
|
100
|
+
assert_equal(NArrayMiss.to_nam(NArray.float(@n,@m,@n).indgen.stddev(-1)), @float3d.stddev(-1))
|
97
101
|
end
|
98
102
|
|
99
103
|
def test_rms
|
metadata
CHANGED
@@ -1,46 +1,40 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: narray_miss
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.2.8
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 2
|
9
|
-
- 7
|
10
|
-
version: 1.2.7
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Seiya Nishizawa
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-07-09 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: narray
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
version: "0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
32
22
|
type: :runtime
|
33
|
-
|
34
|
-
|
35
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
description: NArrayMiss is an additional class with processing of missing value to
|
31
|
+
NArray which is a numeric multi-dimensional array class.
|
32
|
+
email:
|
36
33
|
- seiya@gfd-dennou.org
|
37
34
|
executables: []
|
38
|
-
|
39
35
|
extensions: []
|
40
|
-
|
41
36
|
extra_rdoc_files: []
|
42
|
-
|
43
|
-
files:
|
37
|
+
files:
|
44
38
|
- Gemfile
|
45
39
|
- LICENSE.txt
|
46
40
|
- README.rdoc
|
@@ -52,36 +46,27 @@ files:
|
|
52
46
|
- test/test_narray_miss.rb
|
53
47
|
homepage: http://ruby.gfd-dennou.org/products/narray_miss/
|
54
48
|
licenses: []
|
55
|
-
|
56
49
|
post_install_message:
|
57
50
|
rdoc_options: []
|
58
|
-
|
59
|
-
require_paths:
|
51
|
+
require_paths:
|
60
52
|
- lib
|
61
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
54
|
none: false
|
63
|
-
requirements:
|
64
|
-
- -
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
|
67
|
-
|
68
|
-
- 0
|
69
|
-
version: "0"
|
70
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ! '>='
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
60
|
none: false
|
72
|
-
requirements:
|
73
|
-
- -
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
|
76
|
-
segments:
|
77
|
-
- 0
|
78
|
-
version: "0"
|
61
|
+
requirements:
|
62
|
+
- - ! '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
79
65
|
requirements: []
|
80
|
-
|
81
66
|
rubyforge_project: narray_miss
|
82
|
-
rubygems_version: 1.8.
|
67
|
+
rubygems_version: 1.8.24
|
83
68
|
signing_key:
|
84
69
|
specification_version: 3
|
85
70
|
summary: Additional class with processing of missing value to NArray
|
86
|
-
test_files:
|
71
|
+
test_files:
|
87
72
|
- test/test_narray_miss.rb
|