narray_miss 1.2.8 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +1 -1
- data/README.rdoc +3 -1
- data/lib/narray_miss/narray_miss.rb +91 -62
- data/lib/narray_miss/version.rb +1 -1
- data/narray_miss.gemspec +14 -4
- data/test/test_narray_miss.rb +1 -0
- metadata +10 -14
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0eae189cb0630885345fb435009238c765297353
|
4
|
+
data.tar.gz: 6439d44068f017bab6f17b7853abcc337d614154
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a1679506a1a943f754aeff6bc7a9a3f93373d67bca0f76d5c6fbbf6ff4add65c5c84d798cc42fe61975d80a8c877f3a98425e90100d06366dbcdd24fa3861135
|
7
|
+
data.tar.gz: 4c85b99c69bf120b1e2d21c0de7953dfebe3eb2328cdd1692bdf524ef93a000e4e06c79816cd1f192c6be042f4046e953e6daeff1ef96c05c9b04bdd71bbd769
|
data/LICENSE.txt
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
NArrayMiss is copyrighted free software by Seiya Nishizawa and GFD
|
2
2
|
Dennou Club (http://www.gfd-dennou.org/).
|
3
3
|
|
4
|
-
Copyright 2001-
|
4
|
+
Copyright 2001-2016 (C) Seiya Nishizawa and GFD Dennou Club
|
5
5
|
(http://www.gfd-dennou.org/) All rights reserved.
|
6
6
|
|
7
7
|
Redistribution and use in source and binary forms, with or without
|
data/README.rdoc
CHANGED
@@ -13,7 +13,9 @@ The URL of the NArrayMiss home-page is:
|
|
13
13
|
= Requires
|
14
14
|
|
15
15
|
* Ruby (http://www.ruby-lang.org/)
|
16
|
-
* NArray
|
16
|
+
* NumRu-NArray or NArray
|
17
|
+
* NumRu-NArray: https://github.com/seiya/numru-narray/
|
18
|
+
* NArray: http://narray.rubyforge.org/index.html.en
|
17
19
|
|
18
20
|
|
19
21
|
= Install
|
@@ -34,7 +34,19 @@ To use NArrayMiss class, you need invoking "require 'narray_miss.rb'" in your sc
|
|
34
34
|
|
35
35
|
=end
|
36
36
|
|
37
|
-
|
37
|
+
begin
|
38
|
+
require 'numru/narray'
|
39
|
+
NARRAY = NumRu::NArray
|
40
|
+
rescue LoadError
|
41
|
+
err = $!
|
42
|
+
begin
|
43
|
+
require 'narray'
|
44
|
+
NARRAY = NArray
|
45
|
+
rescue LoadError
|
46
|
+
STDERR.puts "You should install numru-narray or narray"
|
47
|
+
raise err
|
48
|
+
end
|
49
|
+
end
|
38
50
|
|
39
51
|
|
40
52
|
class NArrayMiss
|
@@ -45,7 +57,7 @@ class NArrayMiss
|
|
45
57
|
type code for 1 byte unsigned integer.
|
46
58
|
--- NArrayMiss::SINT
|
47
59
|
type code for 2 byte signed integer.
|
48
|
-
--- NArrayMiss::
|
60
|
+
--- NArrayMiss::LINT
|
49
61
|
type code for 4 byte signed integer.
|
50
62
|
--- NArrayMiss::SFLOAT
|
51
63
|
type code for single precision float.
|
@@ -61,14 +73,23 @@ class NArrayMiss
|
|
61
73
|
go back to ((<Index>))
|
62
74
|
=end
|
63
75
|
|
64
|
-
BYTE =
|
65
|
-
SINT =
|
66
|
-
INT =
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
76
|
+
BYTE = NARRAY::BYTE
|
77
|
+
SINT = NARRAY::SINT
|
78
|
+
INT = NARRAY::INT
|
79
|
+
LINT = NARRAY::LINT
|
80
|
+
if NARRAY.const_defined?(:LLINT)
|
81
|
+
LLINT = NARRAY::LINT
|
82
|
+
MINT = LLINT # int for mask operations
|
83
|
+
@@llint = true
|
84
|
+
else
|
85
|
+
MINT = LINT # int for mask operations
|
86
|
+
@@llint = false
|
87
|
+
end
|
88
|
+
SFLOAT = NARRAY::SFLOAT
|
89
|
+
FLOAT = NARRAY::FLOAT
|
90
|
+
SCOMPLEX = NARRAY::SCOMPLEX
|
91
|
+
COMPLEX = NARRAY::COMPLEX
|
92
|
+
OBJECT = NARRAY::OBJECT
|
72
93
|
|
73
94
|
class << self
|
74
95
|
alias :__new__ :new
|
@@ -94,7 +115,7 @@ go back to ((<Index>))
|
|
94
115
|
--- NArrayMiss.sint(size, ...)
|
95
116
|
same as NArrayMiss.new(NArrayMiss::SINT, ((|size|)), ...).
|
96
117
|
--- NArrayMiss.int(size, ...)
|
97
|
-
same as NArrayMiss.new(NArrayMiss::
|
118
|
+
same as NArrayMiss.new(NArrayMiss::LINT, ((|size|)), ...).
|
98
119
|
--- NArrayMiss.sfloat(size, ...)
|
99
120
|
same as NArrayMiss.new(NArrayMiss::SFLOAT, ((|size|)), ...).
|
100
121
|
--- NArrayMiss.float(size, ...)
|
@@ -117,8 +138,8 @@ go back to ((<Index>))
|
|
117
138
|
=end
|
118
139
|
|
119
140
|
def self.new(*arg)
|
120
|
-
array =
|
121
|
-
mask =
|
141
|
+
array = NARRAY.new(*arg)
|
142
|
+
mask = NARRAY.byte(*arg[1..-1])
|
122
143
|
__new__(array, mask)
|
123
144
|
end
|
124
145
|
def self.byte(*arg)
|
@@ -130,6 +151,14 @@ go back to ((<Index>))
|
|
130
151
|
def self.int(*arg)
|
131
152
|
NArrayMiss.new(INT,*arg)
|
132
153
|
end
|
154
|
+
def self.lint(*arg)
|
155
|
+
NArrayMiss.new(LINT,*arg)
|
156
|
+
end
|
157
|
+
if @@llint
|
158
|
+
def self.llint(*arg)
|
159
|
+
NArrayMiss.new(LLINT,*arg)
|
160
|
+
end
|
161
|
+
end
|
133
162
|
def self.sfloat(*arg)
|
134
163
|
NArrayMiss.new(SFLOAT,*arg)
|
135
164
|
end
|
@@ -146,7 +175,7 @@ go back to ((<Index>))
|
|
146
175
|
NArrayMiss.new(OBJECT,*arg)
|
147
176
|
end
|
148
177
|
def self.[](*arg)
|
149
|
-
NArrayMiss.to_nam(
|
178
|
+
NArrayMiss.to_nam(NARRAY[*arg])
|
150
179
|
end
|
151
180
|
def self.to_nam_no_dup(*arg)
|
152
181
|
if arg.length > 2 || arg.length==0 then
|
@@ -154,9 +183,9 @@ go back to ((<Index>))
|
|
154
183
|
end
|
155
184
|
|
156
185
|
array = arg[0]
|
157
|
-
if Numeric===array then array =
|
158
|
-
if Array===array then array =
|
159
|
-
if !array.is_a?(
|
186
|
+
if Numeric===array then array = NARRAY[array] end
|
187
|
+
if Array===array then array = NARRAY.to_na(array) end
|
188
|
+
if !array.is_a?(NARRAY) then
|
160
189
|
raise("argument must be Numeric, NArray or Array")
|
161
190
|
end
|
162
191
|
|
@@ -164,27 +193,27 @@ go back to ((<Index>))
|
|
164
193
|
mask = arg[1]
|
165
194
|
if Numeric===mask then mask = array.ne(mask) end
|
166
195
|
if Array===mask then
|
167
|
-
mask =
|
196
|
+
mask = NARRAY.to_na(mask).ne(0)
|
168
197
|
end
|
169
198
|
if mask.class == FalseClass then
|
170
|
-
mask =
|
199
|
+
mask = NARRAY.byte(*array.shape)
|
171
200
|
end
|
172
201
|
if mask.class == TrueClass then
|
173
|
-
mask =
|
202
|
+
mask = NARRAY.byte(*array.shape).fill(1)
|
174
203
|
end
|
175
|
-
if !(
|
204
|
+
if !(NARRAY===mask && mask.typecode==BYTE) then
|
176
205
|
raise("mask must be Numeric, Array, true, false or NArray(byte)")
|
177
206
|
end
|
178
207
|
if mask.length!=array.length
|
179
208
|
raise "mask.length must be same as array.length"
|
180
209
|
end
|
181
210
|
else
|
182
|
-
mask =
|
211
|
+
mask = NARRAY.byte(*array.shape).fill(1)
|
183
212
|
end
|
184
213
|
__new__(array,mask)
|
185
214
|
end
|
186
215
|
def self.to_nam(*arg)
|
187
|
-
if !(Numeric===arg[0]) && !(Array===arg[0]) && !arg[0].is_a?(
|
216
|
+
if !(Numeric===arg[0]) && !(Array===arg[0]) && !arg[0].is_a?(NARRAY)
|
188
217
|
raise "first argument must be Numeric, NArray or Array"
|
189
218
|
end
|
190
219
|
arg[0] = arg[0].dup if !(Numeric===arg[0])
|
@@ -551,7 +580,7 @@ go back to ((<Index>))
|
|
551
580
|
array = @array.dup
|
552
581
|
array[@mask.not] = 0
|
553
582
|
return NArrayMiss.to_nam_no_dup(array.accum(*arg),
|
554
|
-
@mask.to_type(
|
583
|
+
@mask.to_type(MINT).accum(*arg).ne(0))
|
555
584
|
end
|
556
585
|
end
|
557
586
|
|
@@ -588,7 +617,7 @@ go back to ((<Index>))
|
|
588
617
|
def mean(*dims)
|
589
618
|
min_count = NArrayMiss.check_options(dims, 1)
|
590
619
|
# 整数型の場合は浮動小数型へ変換
|
591
|
-
ary0 = self.integer? ? self.to_type(
|
620
|
+
ary0 = self.integer? ? self.to_type(NARRAY::DFLOAT) : self
|
592
621
|
NArrayMiss.reduction(@mask, rank, min_count, dims, true, typecode) do |count_sum, count_accum|
|
593
622
|
ary0.sum(*dims)/count_sum
|
594
623
|
end
|
@@ -596,7 +625,7 @@ go back to ((<Index>))
|
|
596
625
|
def stddev(*dims)
|
597
626
|
min_count = NArrayMiss.check_options(dims, 2)
|
598
627
|
# 整数型の場合は浮動小数型へ変換
|
599
|
-
ary0 = self.integer? ? self.to_type(
|
628
|
+
ary0 = self.integer? ? self.to_type(NARRAY::DFLOAT) : self
|
600
629
|
NArrayMiss.reduction(@mask, rank, min_count, dims, true, typecode) do |count_sum, count_accum|
|
601
630
|
ary0 = ary0 - ary0.accum(*dims)/count_accum
|
602
631
|
ary0 = ary0.abs if ary0.complex?
|
@@ -607,7 +636,7 @@ go back to ((<Index>))
|
|
607
636
|
def rms(*dims)
|
608
637
|
min_count = NArrayMiss.check_options(dims, 1)
|
609
638
|
# 整数型の場合は浮動小数型へ変換
|
610
|
-
ary0 = self.integer? ? self.to_type(
|
639
|
+
ary0 = self.integer? ? self.to_type(NARRAY::DFLOAT) : self
|
611
640
|
NArrayMiss.reduction(@mask, rank, min_count, dims, true, typecode) do |count_sum, count_accum|
|
612
641
|
ary0 = ary0.abs if ary0.complex?
|
613
642
|
ary0 = (ary0**2).sum(*dims) / count_sum
|
@@ -617,7 +646,7 @@ go back to ((<Index>))
|
|
617
646
|
def rmsdev(*dims)
|
618
647
|
min_count = NArrayMiss.check_options(dims, 1)
|
619
648
|
# 整数型の場合は浮動小数型へ変換
|
620
|
-
ary0 = self.integer? ? self.to_type(
|
649
|
+
ary0 = self.integer? ? self.to_type(NARRAY::DFLOAT) : self
|
621
650
|
NArrayMiss.reduction(@mask, rank, min_count, dims, true, typecode) do |count_sum, count_accum|
|
622
651
|
ary0 = ary0 - ary0.accum(*dims)/count_accum
|
623
652
|
ary0 = ary0.abs if ary0.complex?
|
@@ -630,17 +659,17 @@ go back to ((<Index>))
|
|
630
659
|
if arg.length==0 then
|
631
660
|
return @array[@mask].median
|
632
661
|
else
|
633
|
-
nshape =
|
662
|
+
nshape = NARRAY.to_na(@array.shape)
|
634
663
|
nshape[arg]=1
|
635
664
|
nslice = nshape[nshape.ne(1).where]
|
636
|
-
index =
|
665
|
+
index = NARRAY.object(@mask.rank)
|
637
666
|
index[nshape.eq(1).where] = true
|
638
667
|
obj = NArrayMiss.new(@array.typecode,*nslice.to_a)
|
639
668
|
total = 1
|
640
669
|
nslice.each{|n| total *= n}
|
641
670
|
for i in 0...total
|
642
671
|
index[nshape.ne(1).where] = pos(i,nslice)
|
643
|
-
mask =
|
672
|
+
mask = NARRAY.byte(*@array.shape).fill(0)
|
644
673
|
mask[*index] = 1
|
645
674
|
mask = @mask&mask
|
646
675
|
if mask.count_true != 0 then
|
@@ -668,17 +697,17 @@ go back to ((<Index>))
|
|
668
697
|
obj[@mask] = @array[@mask].#{operator}
|
669
698
|
return obj
|
670
699
|
else
|
671
|
-
nshape =
|
700
|
+
nshape = NARRAY.to_na(@array.shape)
|
672
701
|
nshape[arg]=1
|
673
702
|
nslice = nshape[nshape.ne(1).where]
|
674
|
-
index =
|
703
|
+
index = NARRAY.object(@mask.rank)
|
675
704
|
index[nshape.eq(1).where] = true
|
676
705
|
obj = NArrayMiss.new(@array.typecode,*@array.shape)
|
677
706
|
total = 1
|
678
707
|
nslice.each{|n| total *= n}
|
679
708
|
for i in 0...total
|
680
709
|
index[nshape.ne(1).where] = pos(i,nslice)
|
681
|
-
mask =
|
710
|
+
mask = NARRAY.byte(*@array.shape).fill(0)
|
682
711
|
mask[*index] = 1
|
683
712
|
mask = @mask&mask
|
684
713
|
if mask.count_true != 0 then
|
@@ -807,7 +836,7 @@ go back to ((<Index>))
|
|
807
836
|
self.set_missing_value!(arg[0])
|
808
837
|
return @array
|
809
838
|
else
|
810
|
-
raise(ArgumentError, "Usage:
|
839
|
+
raise(ArgumentError, "Usage: NArrayMiss#to_na([missing_value])")
|
811
840
|
end
|
812
841
|
end
|
813
842
|
def to_na(*arg)
|
@@ -1048,14 +1077,14 @@ go back to ((<Index>))
|
|
1048
1077
|
end
|
1049
1078
|
def set_mask(mask)
|
1050
1079
|
if mask.class == Array then
|
1051
|
-
tmp =
|
1080
|
+
tmp = NARRAY.byte(*@mask.shape)
|
1052
1081
|
tmp[true] = mask
|
1053
1082
|
mask = tmp
|
1054
1083
|
end
|
1055
1084
|
if mask.class == NArrayMiss then
|
1056
1085
|
mask = mask.to_na(0)
|
1057
1086
|
end
|
1058
|
-
if mask.class ==
|
1087
|
+
if mask.class == NARRAY then
|
1059
1088
|
if mask.typecode != BYTE then
|
1060
1089
|
raise("mask must be NArrayMiss.byte, NArray.byte or Array")
|
1061
1090
|
end
|
@@ -1124,15 +1153,15 @@ go back to ((<Index>))
|
|
1124
1153
|
if arg.length==0 then
|
1125
1154
|
return @mask.count_true
|
1126
1155
|
else
|
1127
|
-
return @mask.to_type(
|
1156
|
+
return @mask.to_type(MINT).sum(*arg)
|
1128
1157
|
end
|
1129
1158
|
end
|
1130
1159
|
def count_invalid(*arg)
|
1131
1160
|
if arg.length==0 then
|
1132
1161
|
return @mask.count_false
|
1133
1162
|
else
|
1134
|
-
return
|
1135
|
-
@mask.to_type(
|
1163
|
+
return NARRAY.int(*@mask.shape).fill(1).sum(*arg)-
|
1164
|
+
@mask.to_type(MINT).sum(*arg)
|
1136
1165
|
end
|
1137
1166
|
end
|
1138
1167
|
|
@@ -1172,8 +1201,8 @@ go back to ((<Index>))
|
|
1172
1201
|
|
1173
1202
|
def coerce(x)
|
1174
1203
|
if Numeric===x then
|
1175
|
-
return [NArrayMiss.new(
|
1176
|
-
elsif x.class==Array || x.class==
|
1204
|
+
return [NArrayMiss.new(NARRAY[x].typecode,*self.shape).fill(x),self]
|
1205
|
+
elsif x.class==Array || x.class==NARRAY then
|
1177
1206
|
return [NArrayMiss.to_nam(x), self]
|
1178
1207
|
else
|
1179
1208
|
raise("donnot know how to cange #{x.class} to NArrayMiss")
|
@@ -1188,7 +1217,7 @@ go back to ((<Index>))
|
|
1188
1217
|
max_col = 80
|
1189
1218
|
sep = ", "
|
1190
1219
|
const = Hash.new
|
1191
|
-
|
1220
|
+
NARRAY.constants.each{|c| const[NARRAY.const_get(c)] = c}
|
1192
1221
|
str_ret = "NArrayMiss."+const[typecode].to_s.downcase+"("+shape.join(",")+"):"
|
1193
1222
|
if rank == 0 then
|
1194
1223
|
str_ret << " []"
|
@@ -1250,8 +1279,8 @@ go back to ((<Index>))
|
|
1250
1279
|
end
|
1251
1280
|
def self._load(o)
|
1252
1281
|
ary, mask = Marshal::load(o)
|
1253
|
-
ary =
|
1254
|
-
mask =
|
1282
|
+
ary = NARRAY._load(ary)
|
1283
|
+
mask = NARRAY._load(mask)
|
1255
1284
|
NArrayMiss.to_nam_no_dup(ary,mask)
|
1256
1285
|
end
|
1257
1286
|
|
@@ -1262,7 +1291,7 @@ go back to ((<Index>))
|
|
1262
1291
|
private
|
1263
1292
|
def pos(n,shape)
|
1264
1293
|
rank = shape.length
|
1265
|
-
result =
|
1294
|
+
result = NARRAY.int(rank)
|
1266
1295
|
m=n
|
1267
1296
|
for i in 0..rank-2
|
1268
1297
|
j = rank-1-i
|
@@ -1281,11 +1310,11 @@ go back to ((<Index>))
|
|
1281
1310
|
term1 = @array
|
1282
1311
|
term2 = arg
|
1283
1312
|
mask = @mask
|
1284
|
-
when Array,
|
1313
|
+
when Array, NARRAY
|
1285
1314
|
term1 = @array.dup
|
1286
1315
|
term1[@mask.not] = dummy # 欠損部分に dummy を代入
|
1287
|
-
term2 = arg.kind_of?(
|
1288
|
-
mask =
|
1316
|
+
term2 = arg.kind_of?(NARRAY) ? arg : NARRAY.to_na(arg) # Array -> NArray
|
1317
|
+
mask = NARRAY.byte(*term2.shape).fill(1) # 2項目は欠損無し
|
1289
1318
|
mask = @mask & mask
|
1290
1319
|
when NArrayMiss
|
1291
1320
|
term1 = @array.dup
|
@@ -1307,13 +1336,13 @@ go back to ((<Index>))
|
|
1307
1336
|
|
1308
1337
|
def self.reduction(mask, rank, min_count, dims, flag, typecode)
|
1309
1338
|
# flag: リダクションを行う次元方向の有効な値の個数で、割り算を行うかどうかのフラグ
|
1310
|
-
count_sum = mask.to_type(
|
1339
|
+
count_sum = mask.to_type(MINT).sum(*dims)
|
1311
1340
|
# 返り値が配列か、スカラーかによって分岐
|
1312
|
-
if count_sum.kind_of?(
|
1341
|
+
if count_sum.kind_of?(NARRAY)
|
1313
1342
|
mask = count_sum.ge(min_count)
|
1314
1343
|
# すべての要素が欠損値にならないかチェック
|
1315
1344
|
if mask.any?
|
1316
|
-
count_accum =
|
1345
|
+
count_accum = NARRAY.ref(count_sum)
|
1317
1346
|
dims.collect{|d|d<0 ? d+rank : d}.sort.each do |d|
|
1318
1347
|
count_accum.newdim!(d)
|
1319
1348
|
end
|
@@ -1326,13 +1355,13 @@ go back to ((<Index>))
|
|
1326
1355
|
ary = NArrayMiss.to_nam_no_dup(ary, mask) unless flag
|
1327
1356
|
else
|
1328
1357
|
# すべての要素が欠損値の NArrayMiss を返す
|
1329
|
-
na =
|
1358
|
+
na = NARRAY.new(typecode, *mask.shape)
|
1330
1359
|
ary = NArrayMiss.to_nam_no_dup(na, false)
|
1331
1360
|
end
|
1332
1361
|
else
|
1333
1362
|
# 有効な要素数があるかチェック
|
1334
1363
|
if count_sum >= min_count
|
1335
|
-
count_accum =
|
1364
|
+
count_accum = NARRAY.int(*([1]*mask.rank)).fill!(count_sum)
|
1336
1365
|
ary = yield(count_sum, count_accum)
|
1337
1366
|
else
|
1338
1367
|
# 有効な要素数が足りない場合は nil を返す
|
@@ -1383,7 +1412,7 @@ module NMMath
|
|
1383
1412
|
eval <<-EOL,nil,__FILE__,__LINE__+1
|
1384
1413
|
def #{operator}(x)
|
1385
1414
|
case x
|
1386
|
-
when Numeric, Array,
|
1415
|
+
when Numeric, Array, NARRAY
|
1387
1416
|
NMath::#{operator}(x)
|
1388
1417
|
when NArrayMiss
|
1389
1418
|
obj = NArrayMiss.new(x.typecode,*x.shape)
|
@@ -1405,7 +1434,7 @@ module NMMath
|
|
1405
1434
|
def #{operator}(x,y)
|
1406
1435
|
obj = nil
|
1407
1436
|
case x
|
1408
|
-
when Numeric, Array,
|
1437
|
+
when Numeric, Array, NARRAY
|
1409
1438
|
mask1 = nil
|
1410
1439
|
when NArrayMiss
|
1411
1440
|
obj = NArrayMiss.new(x.typecode,*x.shape)
|
@@ -1414,7 +1443,7 @@ module NMMath
|
|
1414
1443
|
raise ArgumentError, "argument is invalid class"
|
1415
1444
|
end
|
1416
1445
|
case y
|
1417
|
-
when Numeric, Array,
|
1446
|
+
when Numeric, Array, NARRAY
|
1418
1447
|
mask2 = nil
|
1419
1448
|
when NArrayMiss
|
1420
1449
|
obj ||= NArrayMiss.new(y.typecode,*y.shape)
|
@@ -1460,7 +1489,7 @@ module NMMath
|
|
1460
1489
|
def #{name}(ary0,ary1,*dims)
|
1461
1490
|
min_count = NArrayMiss.check_options(dims, 2)
|
1462
1491
|
case ary0
|
1463
|
-
when Numeric, Array,
|
1492
|
+
when Numeric, Array, NARRAY
|
1464
1493
|
mask0 = nil
|
1465
1494
|
when NArrayMiss
|
1466
1495
|
mask0 = ary0.get_mask!
|
@@ -1468,7 +1497,7 @@ module NMMath
|
|
1468
1497
|
raise ArgumentError, "argument is invalid class"
|
1469
1498
|
end
|
1470
1499
|
case ary1
|
1471
|
-
when Numeric, Array,
|
1500
|
+
when Numeric, Array, NARRAY
|
1472
1501
|
mask1 = nil
|
1473
1502
|
when NArrayMiss
|
1474
1503
|
mask1 = ary1.get_mask!
|
@@ -1489,12 +1518,12 @@ module NMMath
|
|
1489
1518
|
if ary1.shape != ary1.shape
|
1490
1519
|
raise "shape is different"
|
1491
1520
|
end
|
1492
|
-
ary0 = ary0.to_type(
|
1493
|
-
ary1 = ary1.to_type(
|
1521
|
+
ary0 = ary0.to_type(NARRAY::DFLOAT)
|
1522
|
+
ary1 = ary1.to_type(NARRAY::DFLOAT)
|
1494
1523
|
mask = mask0.nil? ? mask1 : mask1.nil? ? mask0 : mask0&mask1
|
1495
1524
|
ary0.set_mask(mask)
|
1496
1525
|
ary1.set_mask(mask)
|
1497
|
-
NArrayMiss.reduction(mask, ary0.rank, min_count, dims, true,
|
1526
|
+
NArrayMiss.reduction(mask, ary0.rank, min_count, dims, true, NARRAY::DFLOAT) do |count_sum, count_accum|
|
1498
1527
|
#{hash[:post]}
|
1499
1528
|
end
|
1500
1529
|
end
|
data/lib/narray_miss/version.rb
CHANGED
data/narray_miss.gemspec
CHANGED
@@ -13,13 +13,23 @@ Gem::Specification.new do |s|
|
|
13
13
|
|
14
14
|
s.rubyforge_project = "narray_miss"
|
15
15
|
|
16
|
-
s.files =
|
17
|
-
|
18
|
-
|
16
|
+
s.files = [
|
17
|
+
"Gemfile",
|
18
|
+
"LICENSE.txt",
|
19
|
+
"README.rdoc",
|
20
|
+
"Rakefile",
|
21
|
+
"lib/narray_miss.rb",
|
22
|
+
"lib/narray_miss/narray_miss.rb",
|
23
|
+
"lib/narray_miss/version.rb",
|
24
|
+
"narray_miss.gemspec",
|
25
|
+
"test/test_narray_miss.rb"
|
26
|
+
]
|
27
|
+
s.test_files = [ "test/test_narray_miss.rb" ]
|
28
|
+
s.executables = []
|
19
29
|
s.require_paths = ["lib"]
|
20
30
|
#s.extensions << "ext/extconf.rb"
|
21
31
|
|
22
32
|
# specify any dependencies here; for example:
|
23
33
|
#s.add_development_dependency "rspec"
|
24
|
-
s.add_runtime_dependency "narray"
|
34
|
+
s.add_runtime_dependency "numru-narray"
|
25
35
|
end
|
data/test/test_narray_miss.rb
CHANGED
metadata
CHANGED
@@ -1,30 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: narray_miss
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.3.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Seiya Nishizawa
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2016-02-15 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
|
-
name: narray
|
14
|
+
name: numru-narray
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
description: NArrayMiss is an additional class with processing of missing value to
|
@@ -46,27 +43,26 @@ files:
|
|
46
43
|
- test/test_narray_miss.rb
|
47
44
|
homepage: http://ruby.gfd-dennou.org/products/narray_miss/
|
48
45
|
licenses: []
|
46
|
+
metadata: {}
|
49
47
|
post_install_message:
|
50
48
|
rdoc_options: []
|
51
49
|
require_paths:
|
52
50
|
- lib
|
53
51
|
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
-
none: false
|
55
52
|
requirements:
|
56
|
-
- -
|
53
|
+
- - ">="
|
57
54
|
- !ruby/object:Gem::Version
|
58
55
|
version: '0'
|
59
56
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
-
none: false
|
61
57
|
requirements:
|
62
|
-
- -
|
58
|
+
- - ">="
|
63
59
|
- !ruby/object:Gem::Version
|
64
60
|
version: '0'
|
65
61
|
requirements: []
|
66
62
|
rubyforge_project: narray_miss
|
67
|
-
rubygems_version:
|
63
|
+
rubygems_version: 2.4.8
|
68
64
|
signing_key:
|
69
|
-
specification_version:
|
65
|
+
specification_version: 4
|
70
66
|
summary: Additional class with processing of missing value to NArray
|
71
67
|
test_files:
|
72
68
|
- test/test_narray_miss.rb
|