rbbt-util 5.35.2 → 5.35.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: 7fc87aa89e132735c535df80f34cfd0f31fb44475d55d08fb194ee50e045f884
4
- data.tar.gz: e1c380d68af04bd683a3a06e675b6e8744497869d95ac96620e7864f05e8aeb7
3
+ metadata.gz: b3a214b340c407e61c0cc227b8872c4b0c71463affcf6bf84f9d4ed66486435c
4
+ data.tar.gz: d62735c060afe4507cc69363280d76e24c88ed89063531e526fe5a03ecfd6386
5
5
  SHA512:
6
- metadata.gz: dd65fb3be5c880288fa1718d6a2327d1e799f7c9b415785cdcb5f1cd9d18d02664347e6dc16dde2a78d727ab86ab292d272fc2a608ea7a9a1eb7c0e88f213131
7
- data.tar.gz: 603ca603814e8405dcc88ed0a499ddb92658d2831887d8c8110ba60737a83317ee7d68e00a3b51a48734a6bb90f2539d654169b07a8609a60fe02351d8426394
6
+ metadata.gz: f8fd64ecb9abc0a5bf519fa294196e8b1082a4ef358106806bc7c18dadfb361bd22b2b14aca96f3dd32c276461fa6616d3613a7de7aca87ceaddc7db74d57e23
7
+ data.tar.gz: baa4182336b92c09eead8fed9a28b2bc6d84aea7e2e9e98c4597ae3373ac31ff27feb62e1dbd73817ac69f7986a00ceb2bf404d38fb739919882fea684053bfa
@@ -46,7 +46,9 @@ module Persist
46
46
  end
47
47
 
48
48
  def delete(key)
49
- out(key)
49
+ self.write_lock do
50
+ out(key)
51
+ end
50
52
  end
51
53
 
52
54
  def lock
@@ -54,6 +54,20 @@ module RbbtPython
54
54
  RbbtPython.method(method_name)
55
55
  end
56
56
 
57
+ def self.call_method(module_name, method_name, *args)
58
+ RbbtPython.import_method(module_name, method_name).call(*args)
59
+ end
60
+
61
+ def self.get_class(module_name, class_name)
62
+ save_module_name = module_name.gsub(".", "_")
63
+ RbbtPython.pyimport(module_name, as: save_module_name)
64
+ RbbtPython.send(save_module_name).send(class_name)
65
+ end
66
+
67
+ def self.class_new_obj(module_name, class_name, args)
68
+ RbbtPython.get_class(module_name, class_name).new(**args)
69
+ end
70
+
57
71
  def self.exec(script)
58
72
  PyCall.exec(script)
59
73
  end
@@ -131,5 +131,10 @@ def python_print():
131
131
  random = RbbtPython.import_method :torch, :rand, :random
132
132
  assert random.call(1).numpy.to_f > 0
133
133
  end
134
+
135
+ def test_class_new_obj
136
+ obj = RbbtPython.class_new_obj("torch.nn", "Module")
137
+ assert_equal "Module()", obj.to_s
138
+ end
134
139
  end
135
140
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbbt-util
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.35.2
4
+ version: 5.35.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-04 00:00:00.000000000 Z
11
+ date: 2023-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake