npy 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/lib/npy.rb +17 -12
- data/lib/npy/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 220dfbefca45a554d1a0f673385f832f11539ad1bc3113f285ae91144defe035
|
4
|
+
data.tar.gz: 923f706a1ea48ec546c0b94b19fbe0db4ef0351538555f1d20c6ea707b381122
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ca365c5f2acc98aedeed97d435c6c2e792a90c944affa2c448a2e19eea052a36165b16858e0e4b4314d2f9bf108ece56f8788931a62b31b140c4934dcca4cc3
|
7
|
+
data.tar.gz: ec7528bfa28dbb45d22275856e87c362d1a814bfdbb45a8fe41b86e960fafcf5d19af0cebf19dab518c642d32a7bf2c6ed27c8cf62d2d673793f3b75947f264e
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,13 @@
|
|
1
|
+
## 0.2.0
|
2
|
+
|
3
|
+
- Added support for loading `bool` type (as `uint8` for now)
|
4
|
+
- Return `NArray` object for rank-0 arrays
|
5
|
+
|
1
6
|
## 0.1.2
|
2
7
|
|
3
8
|
- Added support for saving and loading IO objects
|
4
9
|
- Added `load_npz_string`
|
5
|
-
- Fixed bug with 1
|
10
|
+
- Fixed bug with rank-1 arrays
|
6
11
|
|
7
12
|
## 0.1.1
|
8
13
|
|
data/lib/npy.rb
CHANGED
@@ -27,7 +27,10 @@ module Npy
|
|
27
27
|
"<f4" => Numo::SFloat,
|
28
28
|
"<f8" => Numo::DFloat,
|
29
29
|
"<c8" => Numo::SComplex,
|
30
|
-
"<c16" => Numo::DComplex
|
30
|
+
"<c16" => Numo::DComplex,
|
31
|
+
# must come last
|
32
|
+
# as save uses first match
|
33
|
+
"|b1" => Numo::UInt8
|
31
34
|
}
|
32
35
|
|
33
36
|
class << self
|
@@ -85,18 +88,17 @@ module Npy
|
|
85
88
|
descr, fortran_order, shape = parse_header(header)
|
86
89
|
raise Error, "Fortran order not supported" if fortran_order
|
87
90
|
|
88
|
-
# numo can't handle empty shapes
|
89
|
-
empty_shape = shape.empty?
|
90
|
-
shape = [1] if empty_shape
|
91
|
-
|
92
91
|
klass = TYPE_MAP[descr]
|
93
92
|
raise Error, "Type not supported: #{descr}" unless klass
|
94
93
|
|
95
94
|
# use from_string instead of from_binary for max compatibility
|
96
95
|
# from_binary introduced in 0.9.0.4
|
97
|
-
|
98
|
-
|
99
|
-
|
96
|
+
# numo from_string can't handle rank0
|
97
|
+
if shape.empty?
|
98
|
+
klass.cast(klass.from_string(io.read, [1])[0])
|
99
|
+
else
|
100
|
+
klass.from_string(io.read, shape)
|
101
|
+
end
|
100
102
|
end
|
101
103
|
|
102
104
|
# TODO make private
|
@@ -145,9 +147,13 @@ module Npy
|
|
145
147
|
end
|
146
148
|
|
147
149
|
def save_io(f, arr)
|
148
|
-
|
149
|
-
|
150
|
-
|
150
|
+
unless arr.is_a?(Numo::NArray)
|
151
|
+
begin
|
152
|
+
arr = Numo::NArray.cast(arr)
|
153
|
+
rescue TypeError
|
154
|
+
# do nothing
|
155
|
+
end
|
156
|
+
end
|
151
157
|
|
152
158
|
# desc
|
153
159
|
descr = TYPE_MAP.find { |_, v| arr.is_a?(v) }
|
@@ -155,7 +161,6 @@ module Npy
|
|
155
161
|
|
156
162
|
# shape
|
157
163
|
shape = arr.shape
|
158
|
-
shape = [] if empty_shape
|
159
164
|
|
160
165
|
# header
|
161
166
|
header = "{'descr': '#{descr[0]}', 'fortran_order': False, 'shape': (#{shape.join(", ")}#{shape.size == 1 ? "," : nil}), }".b
|
data/lib/npy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: npy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: numo-narray
|