red-arrow-numo-narray 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 84a1f4eb838f8640c7f67f3fbdd9446ae769ce7aef16f6b98a9abd5cc8f87bf4
4
- data.tar.gz: a9fed15ebb2b9e034c40d15b45974c06995b9b9dea66c48b25d2f785932d98e5
3
+ metadata.gz: 2a484511f7152fa12df7cc0b356f775c70462b977e0783e5c9d4552f2a1beda7
4
+ data.tar.gz: d569a6d94ba32eb1893d9bc465a2f386ffbc91b7edff0a945bb9bcb2ddf786d2
5
5
  SHA512:
6
- metadata.gz: 28415f30fcc072a07f7d5eef18a1291aa51e4eaa1e5f4a1f8d7f274505d45c624d9c4c6e1dc7749d3c54e837038a5babc57300aa496671253266987ed05f0d30
7
- data.tar.gz: 3cc883a79b281e668b2cf05f9e74ec6989278bd87677d801e3c3c912fcb56f643cca4b7c0050b0269c847525c84818b5f7189a106d16ff9d35f90d60b554ccfa
6
+ metadata.gz: dc715d39ee68ffc7e68ffed95b0b89badc85b83bb37ae7586443d6cd4896c5b823b89bdf5f9128253dc1a65b306db947fb80a0fbddd501b92bc1a3319e339679
7
+ data.tar.gz: 94cf907a219e1623314b48463ea70676995b1661a9f301bc6362970e214f0fd519cf2f2c2dc1d85258b13a5b42a3d102c33db24a0ea817a73a68c2ed51307240
@@ -1,5 +1,16 @@
1
1
  # News
2
2
 
3
+ ## 0.0.4 - 2019-08-19
4
+
5
+ ### Improvements
6
+
7
+ * Added `Arrow::ChunkedArray#to_narray`.
8
+ [GitHub#2][Suggested by Kenta Murata]
9
+
10
+ ### Thanks
11
+
12
+ * Kenta Murata
13
+
3
14
  ## 0.0.3 - 2019-08-07
4
15
 
5
16
  ### Fixes
@@ -85,6 +85,22 @@ module Arrow
85
85
  end
86
86
  end
87
87
 
88
+ class ChunkedArray
89
+ def to_narray
90
+ unless n_nulls.zero?
91
+ message = "can't convert #{self.class} that has null values to NArray"
92
+ raise ArrowNumoNArray::UnconvertibleError, message
93
+ end
94
+ narray = value_data_type.narray_class.new(length)
95
+ data = ""
96
+ chunks.each do |chunk|
97
+ data << chunk.buffer.data.to_s
98
+ end
99
+ narray.store_binary(data)
100
+ narray
101
+ end
102
+ end
103
+
88
104
  class Tensor
89
105
  def to_narray
90
106
  narray = value_data_type.narray_class.new(shape)
@@ -13,5 +13,5 @@
13
13
  # limitations under the License.
14
14
 
15
15
  module ArrowNumoNArray
16
- VERSION = "0.0.3"
16
+ VERSION = "0.0.4"
17
17
  end
@@ -83,6 +83,107 @@ class ToNAarrayTest < Test::Unit::TestCase
83
83
  end
84
84
  end
85
85
 
86
+ sub_test_case("ChunkedArray") do
87
+ test("with NULL") do
88
+ chunked_array = Arrow::ChunkedArray.new([Arrow::Int8Array.new([0, nil])])
89
+ message =
90
+ "can't convert #{chunked_array.class} that has null values to NArray"
91
+ assert_raise(ArrowNumoNArray::UnconvertibleError.new(message)) do
92
+ chunked_array.to_narray
93
+ end
94
+ end
95
+
96
+ test("Int8") do
97
+ arrays = [
98
+ Arrow::Int8Array.new([-(2 ** 7), 0]),
99
+ Arrow::Int8Array.new([2 ** 7 - 1]),
100
+ ]
101
+ assert_equal(Numo::Int8[-(2 ** 7), 0, 2 ** 7 - 1],
102
+ Arrow::ChunkedArray.new(arrays).to_narray)
103
+ end
104
+
105
+ test("Int16") do
106
+ arrays = [
107
+ Arrow::Int16Array.new([-(2 ** 15), 0]),
108
+ Arrow::Int16Array.new([2 ** 15 - 1]),
109
+ ]
110
+ assert_equal(Numo::Int16[-(2 ** 15), 0, 2 ** 15 - 1],
111
+ Arrow::ChunkedArray.new(arrays).to_narray)
112
+ end
113
+
114
+ test("Int32") do
115
+ arrays = [
116
+ Arrow::Int32Array.new([-(2 ** 31), 0]),
117
+ Arrow::Int32Array.new([2 ** 31 - 1]),
118
+ ]
119
+ assert_equal(Numo::Int32[-(2 ** 31), 0, 2 ** 31 - 1],
120
+ Arrow::ChunkedArray.new(arrays).to_narray)
121
+ end
122
+
123
+ test("Int64") do
124
+ arrays = [
125
+ Arrow::Int64Array.new([-(2 ** 63), 0]),
126
+ Arrow::Int64Array.new([2 ** 63 - 1]),
127
+ ]
128
+ assert_equal(Numo::Int64[-(2 ** 63), 0, 2 ** 63 - 1],
129
+ Arrow::ChunkedArray.new(arrays).to_narray)
130
+ end
131
+
132
+ test("UInt8") do
133
+ arrays = [
134
+ Arrow::UInt8Array.new([0]),
135
+ Arrow::UInt8Array.new([2 ** 8 - 1]),
136
+ ]
137
+ assert_equal(Numo::UInt8[0, 2 ** 8 - 1],
138
+ Arrow::ChunkedArray.new(arrays).to_narray)
139
+ end
140
+
141
+ test("UInt16") do
142
+ arrays = [
143
+ Arrow::UInt16Array.new([0]),
144
+ Arrow::UInt16Array.new([2 ** 16 - 1]),
145
+ ]
146
+ assert_equal(Numo::UInt16[0, 2 ** 16 - 1],
147
+ Arrow::ChunkedArray.new(arrays).to_narray)
148
+ end
149
+
150
+ test("UInt32") do
151
+ arrays = [
152
+ Arrow::UInt32Array.new([0]),
153
+ Arrow::UInt32Array.new([2 ** 32 - 1]),
154
+ ]
155
+ assert_equal(Numo::UInt32[0, 2 ** 32 - 1],
156
+ Arrow::ChunkedArray.new(arrays).to_narray)
157
+ end
158
+
159
+ test("UInt64") do
160
+ arrays = [
161
+ Arrow::UInt64Array.new([0]),
162
+ Arrow::UInt64Array.new([2 ** 64 - 1]),
163
+ ]
164
+ assert_equal(Numo::UInt64[0, 2 ** 64 - 1],
165
+ Arrow::ChunkedArray.new(arrays).to_narray)
166
+ end
167
+
168
+ test("Float") do
169
+ arrays = [
170
+ Arrow::FloatArray.new([-1.1, 0]),
171
+ Arrow::FloatArray.new([1.1]),
172
+ ]
173
+ assert_equal(Numo::SFloat[-1.1, 0, 1.1],
174
+ Arrow::ChunkedArray.new(arrays).to_narray)
175
+ end
176
+
177
+ test("Double") do
178
+ arrays = [
179
+ Arrow::DoubleArray.new([-1.1, 0]),
180
+ Arrow::DoubleArray.new([1.1]),
181
+ ]
182
+ assert_equal(Numo::DFloat[-1.1, 0, 1.1],
183
+ Arrow::ChunkedArray.new(arrays).to_narray)
184
+ end
185
+ end
186
+
86
187
  sub_test_case("Tensor") do
87
188
  test("Int8") do
88
189
  data = [
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: red-arrow-numo-narray
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouhei Sutou
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-07 00:00:00.000000000 Z
11
+ date: 2019-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: red-arrow