narray_miss 1.2.3 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/narray_miss/narray_miss.rb +19 -11
- data/lib/narray_miss/version.rb +1 -1
- data/test/test_narray_miss.rb +9 -0
- metadata +5 -5
@@ -1010,8 +1010,9 @@ go back to ((<Index>))
|
|
1010
1010
|
return (({NArray})) as data.
|
1011
1011
|
--- NArrayMiss#get_array
|
1012
1012
|
return (({NArray})) as data.
|
1013
|
-
--- NArrayMiss#valid?
|
1014
|
-
return (({Array})) whose elements are true or false
|
1013
|
+
--- NArrayMiss#valid?(index)
|
1014
|
+
return (({Array})) whose elements are true or false,
|
1015
|
+
or (({True}))/(({False})) corresponding to validity of the specified element(s) by the ((|index|))
|
1015
1016
|
--- NArrayMiss#all_valid?
|
1016
1017
|
return true if all elements are valid, else false.
|
1017
1018
|
--- NArrayMiss#none_valid?
|
@@ -1090,16 +1091,23 @@ go back to ((<Index>))
|
|
1090
1091
|
@array.dup
|
1091
1092
|
end
|
1092
1093
|
|
1093
|
-
def valid?
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1094
|
+
def valid?(*arg)
|
1095
|
+
if arg.any?
|
1096
|
+
# For the subset specified by the argument(s) (in the same way as for []).
|
1097
|
+
# Returns true or false if a single value is specified.
|
1098
|
+
# Otherwise, returns an Array of true of false
|
1099
|
+
mask = @mask[*arg]
|
1100
|
+
if mask.is_a?(Numeric)
|
1101
|
+
return mask == 1 # true if mask (==1); false if not
|
1102
|
+
end
|
1103
|
+
else
|
1104
|
+
# no argument
|
1105
|
+
mask = @mask
|
1101
1106
|
end
|
1102
|
-
|
1107
|
+
ary = mask.to_a
|
1108
|
+
ary.flatten!
|
1109
|
+
ary.map!{|i| i==1} # true if element == 1; false if not
|
1110
|
+
return ary
|
1103
1111
|
end
|
1104
1112
|
def all_valid?
|
1105
1113
|
@mask.all?
|
data/lib/narray_miss/version.rb
CHANGED
data/test/test_narray_miss.rb
CHANGED
@@ -34,6 +34,15 @@ NArrayMiss.dfloat(4,4):
|
|
34
34
|
=end
|
35
35
|
end
|
36
36
|
|
37
|
+
def test_valid?
|
38
|
+
assert_equal([true,true,true,true,false,true,true,true,false,false,false,true,false,false,false,false], @int.valid?)
|
39
|
+
assert_equal([true,true,true,true], @int.valid?(true,0))
|
40
|
+
assert_equal([false,true,true,true], @int.valid?(true,1))
|
41
|
+
assert_equal([true,true,true,false], @int.valid?(3,true))
|
42
|
+
assert_equal(true, @int.valid?[7])
|
43
|
+
assert_equal(false, @int.valid?[10])
|
44
|
+
end
|
45
|
+
|
37
46
|
def test_add
|
38
47
|
ary = NArrayMiss.float(@n,@n)
|
39
48
|
ary[true,0] = [0, 2, 4, 6]
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: narray_miss
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 1.2.
|
9
|
+
- 4
|
10
|
+
version: 1.2.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Seiya Nishizawa
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-12-
|
18
|
+
date: 2011-12-16 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: narray
|
@@ -79,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
79
|
requirements: []
|
80
80
|
|
81
81
|
rubyforge_project: narray_miss
|
82
|
-
rubygems_version: 1.8.
|
82
|
+
rubygems_version: 1.8.11
|
83
83
|
signing_key:
|
84
84
|
specification_version: 3
|
85
85
|
summary: Additional class with processing of missing value to NArray
|