rbbt-util 5.35.3 → 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: 8be0e512e0b2cded02b65df8105bb3504297b703792f86b664d06904443660cd
4
- data.tar.gz: 568516ecd269492e81fb571a8fff377d2d486d30fb37883081f2d2aa8fbe811c
3
+ metadata.gz: b3a214b340c407e61c0cc227b8872c4b0c71463affcf6bf84f9d4ed66486435c
4
+ data.tar.gz: d62735c060afe4507cc69363280d76e24c88ed89063531e526fe5a03ecfd6386
5
5
  SHA512:
6
- metadata.gz: '09a9d4a2508ce0bc3cf9dc7b84071ec35f0fdf9e9ebf7566edb4d302b5af87b393b958475f83969a931a5da23aa82d00ca97ab2c6e63667730049558cf553a75'
7
- data.tar.gz: ea069e4c4c50bf0f71800d45156945485053afe0c2f91378fa58ce9442f222c99ea3f92ef30e6ae38e8ccce1afbef13e1a5b77d67a8ea75743353587be578fb6
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
@@ -58,6 +58,16 @@ module RbbtPython
58
58
  RbbtPython.import_method(module_name, method_name).call(*args)
59
59
  end
60
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
+
61
71
  def self.exec(script)
62
72
  PyCall.exec(script)
63
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.3
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-08 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