numpy 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +4 -0
- data/lib/numpy/ndarray.rb +48 -0
- data/lib/numpy/version.rb +1 -1
- data/numpy.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1d276c3ad0422a4d70644c598d56cfe5796bbf5afd6454732868f594eedcaef
|
4
|
+
data.tar.gz: da4219c7991eb69bc3be277463bd9ece4bebf2b9c1c72d9c49584f308a07b970
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26702a4ed9e3700743cb64623df90b05f5df6996182fc5bfece2af94532efe339407f6486d52054a750ea75ecd435cc79e01064648e869966b30becadff5ba5c
|
7
|
+
data.tar.gz: 5d3ec29e3afb2043fa686806a816d117a1cc266826d949563924850efa5bc0521c728ac7f315933e982c5858c62ed3a6bc48a291a3f06b9a2535e35282cfa028
|
data/CHANGES.md
CHANGED
data/lib/numpy/ndarray.rb
CHANGED
@@ -21,5 +21,53 @@ module Numpy
|
|
21
21
|
end
|
22
22
|
}
|
23
23
|
end
|
24
|
+
|
25
|
+
def to_narray
|
26
|
+
load_numo_narray
|
27
|
+
|
28
|
+
# Suppress warning from PyCall
|
29
|
+
begin
|
30
|
+
save, $VERBOSE = $VERBOSE, nil
|
31
|
+
dtype = self.dtype
|
32
|
+
ensure
|
33
|
+
$VERBOSE = save
|
34
|
+
end
|
35
|
+
|
36
|
+
_, narray_klass = self.class.narray_class_map.find { |dt, kl| dtype == dt }
|
37
|
+
unless narray_klass
|
38
|
+
raise TypeError,
|
39
|
+
"Unable to convert numpy's %p array to Numo::NArray" % dtype
|
40
|
+
end
|
41
|
+
|
42
|
+
# TODO: Use MemoryView feature
|
43
|
+
narray_klass[*to_a]
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.narray_class_map
|
47
|
+
@narray_class_map ||= [
|
48
|
+
[ Numpy.int64 , Numo::Int64 ],
|
49
|
+
[ Numpy.int32 , Numo::Int32 ],
|
50
|
+
[ Numpy.int16 , Numo::Int16 ],
|
51
|
+
[ Numpy.int8 , Numo::Int8 ],
|
52
|
+
[ Numpy.uint64 , Numo::Int64 ],
|
53
|
+
[ Numpy.uint32 , Numo::Int32 ],
|
54
|
+
[ Numpy.uint16 , Numo::Int16 ],
|
55
|
+
[ Numpy.uint8 , Numo::Int8 ],
|
56
|
+
[ Numpy.bool8 , Numo::UInt8 ],
|
57
|
+
[ Numpy.float32 , Numo::SFloat ],
|
58
|
+
[ Numpy.float64 , Numo::DFloat ],
|
59
|
+
[ Numpy.object , Numo::RObject ]
|
60
|
+
].freeze
|
61
|
+
end
|
62
|
+
|
63
|
+
private def load_numo_narray
|
64
|
+
begin
|
65
|
+
require "numo/narray"
|
66
|
+
rescue LoadError
|
67
|
+
raise RuntimeError,
|
68
|
+
"Unable to load numo/narray library; " +
|
69
|
+
"please do gem install numo-narray before use to_narray method"
|
70
|
+
end
|
71
|
+
end
|
24
72
|
end
|
25
73
|
end
|
data/lib/numpy/version.rb
CHANGED
data/numpy.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: numpy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kenta Murata
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pycall
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: numo-narray
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
description: Numpy wrapper for Ruby
|
70
84
|
email:
|
71
85
|
- mrkn@mrkn.jp
|