numru 0.1.3 → 0.1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2f5c42c4a6670682ec3160d69931e3a711e3f343
4
- data.tar.gz: 3d41e1128d695249d6ebd3a5b40671f2ff2796a6
3
+ metadata.gz: 9a715fb989185e9d112bf586b1ac0475ea773982
4
+ data.tar.gz: 2b570def06cc8697a4c066835dc6c637367f4133
5
5
  SHA512:
6
- metadata.gz: 512e168425f6b89bdb3acd76f076778d16e382a332110f608f3b92933636a9f625e42f7f43c0cbbf2bcc363c273f2b0f1eae848bfab1ef5e3b75f2b2a96be895
7
- data.tar.gz: 31ac0374c60f60a714a21e26f231b97a8c1365eeb4e4d5834a80b9717b00f86dac5f2bc9e7cf5e8f847b65caca14b637b1aa9312073eb9e859e89dd7461cf9e8
6
+ metadata.gz: 8c84e8f6663e79ace46ab6bd866c3fdfeb0b232c793041656d73a68a0f17f36832d0c8fa9cfc64ca25c069c878179c643a0af2529ad1b222e9e1dfc0a959c2eb
7
+ data.tar.gz: f2357e77771aafc6574e0d1818533223c5ffea97491d337f40342e599736bcc6d86fbb052fbd3597b01f4007381e756072c19e91a65e433b4563b91b33d7fa5c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- NumRu (0.1.1)
4
+ numru (0.1.3)
5
5
  rubypython
6
6
 
7
7
  GEM
@@ -37,8 +37,8 @@ PLATFORMS
37
37
  ruby
38
38
 
39
39
  DEPENDENCIES
40
- NumRu!
41
40
  bundler (~> 1.16)
41
+ numru!
42
42
  pry (~> 0.11)
43
43
  rake (~> 10.0)
44
44
  rspec (~> 3.0)
data/README.md CHANGED
@@ -20,7 +20,7 @@ And then execute:
20
20
 
21
21
  Or install it yourself as:
22
22
 
23
- $ gem install NumRu
23
+ $ gem install numru
24
24
 
25
25
  ## Usage
26
26
 
data/lib/numru/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Numru
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
data/lib/numru.rb CHANGED
@@ -1,10 +1,4 @@
1
1
  require "numru/version"
2
-
3
- # module Numru
4
- # # Your code goes here...
5
- # end
6
-
7
-
8
2
  require 'rubypython'
9
3
 
10
4
  RubyPython.start
@@ -21,13 +15,9 @@ class NumRu
21
15
  end
22
16
 
23
17
  def self.return_or_wrap obj
24
- # if obj.respond_to? :class
25
- # obj
26
- # elsif obj.__class__.__name__ == 'ndarray'
27
- NumRu.new obj
28
- # else
29
- # obj
30
- # end
18
+ obj.rubify
19
+ rescue
20
+ NumRu.new obj
31
21
  end
32
22
 
33
23
  def [](*args)
@@ -38,6 +28,9 @@ class NumRu
38
28
  @@blt.slice(i.begin, last)
39
29
  when NumRu
40
30
  i.np_obj
31
+ when String
32
+ a, b, c = i.split(':').map { |x| x == '' ? nil : x.to_i }
33
+ @@blt.slice(a, b, c)
41
34
  else
42
35
  i
43
36
  end
@@ -46,6 +39,41 @@ class NumRu
46
39
  NumRu.return_or_wrap obj
47
40
  end
48
41
 
42
+ def []=(*args)
43
+ args.map! do |i|
44
+ case i
45
+ when Range
46
+ last = i.end == -1 ? nil : i.end + 1
47
+ @@blt.slice(i.begin, last)
48
+ when NumRu
49
+ i.np_obj
50
+ when String
51
+ a, b, c = i.split(':').map { |x| x == '' ? nil : x.to_i }
52
+ @@blt.slice(a, b, c)
53
+ else
54
+ i
55
+ end
56
+ end
57
+ obj = @np_obj.__send__('__setitem__', args[0..-2], args[-1])
58
+ NumRu.return_or_wrap obj
59
+ end
60
+
61
+ def self.extract_np_obj obj
62
+ obj.respond_to?(:class) && obj.class == NumRu ? obj.np_obj : obj
63
+ end
64
+
65
+ def ==(arg)
66
+ @np_obj.__send__('__eq__', NumRu.extract_np_obj(arg))
67
+ end
68
+
69
+ def < arg
70
+ @np_obj.__send__('__lt__', NumRu.extract_np_obj(arg))
71
+ end
72
+
73
+ def > arg
74
+ @np_obj.__send__('__gt__', NumRu.extract_np_obj(arg))
75
+ end
76
+
49
77
  def self.arg_to_s arg
50
78
  case arg
51
79
  when Hash
@@ -57,13 +85,13 @@ class NumRu
57
85
  end
58
86
 
59
87
  def method_missing(m, *args)
60
- args.map! { |i| i.respond_to?(:class) && i.class == NumRu ? i.np_obj : i }
88
+ args.map! { |i| NumRu.extract_np_obj i }
61
89
  obj = @np_obj.__send__ "#{m}!", *args
62
90
  NumRu.return_or_wrap obj
63
91
  end
64
92
 
65
93
  def self.method_missing(m, *args)
66
- args.map! { |i| i.respond_to?(:class) && i.class == NumRu ? i.np_obj : i }
94
+ args.map! { |i| NumRu.extract_np_obj i }
67
95
  obj = @@np.__send__ "#{m}!", *args
68
96
  return_or_wrap obj
69
97
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: numru
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - lokeshh