rbbt-util 5.35.2 → 5.35.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 +4 -4
- data/lib/rbbt/persist/tsv/adapter.rb +3 -1
- data/lib/rbbt/util/python.rb +14 -0
- data/test/rbbt/util/test_python.rb +5 -0
- 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: b3a214b340c407e61c0cc227b8872c4b0c71463affcf6bf84f9d4ed66486435c
|
4
|
+
data.tar.gz: d62735c060afe4507cc69363280d76e24c88ed89063531e526fe5a03ecfd6386
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8fd64ecb9abc0a5bf519fa294196e8b1082a4ef358106806bc7c18dadfb361bd22b2b14aca96f3dd32c276461fa6616d3613a7de7aca87ceaddc7db74d57e23
|
7
|
+
data.tar.gz: baa4182336b92c09eead8fed9a28b2bc6d84aea7e2e9e98c4597ae3373ac31ff27feb62e1dbd73817ac69f7986a00ceb2bf404d38fb739919882fea684053bfa
|
data/lib/rbbt/util/python.rb
CHANGED
@@ -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.
|
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-
|
11
|
+
date: 2023-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|