Skip to content

Commit 2ee7fdc

Browse files
committed
Use wrap_class
1 parent 3fbf41e commit 2ee7fdc

File tree

2 files changed

+2
-46
lines changed

2 files changed

+2
-46
lines changed

lib/matplotlib/axes.rb

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,6 @@
11
module Matplotlib
22
class Axes
33
include PyCall::PyObjectWrapper
4-
5-
@__pyobj__ = PyCall.import_module('matplotlib.axes').Axes
6-
7-
PyCall.dir(@__pyobj__).each do |name|
8-
obj = PyCall.getattr(@__pyobj__, name)
9-
next unless obj.kind_of?(PyCall::PyObject) || obj.kind_of?(PyCall::PyObjectWrapper)
10-
next unless PyCall.callable?(obj)
11-
12-
define_method(name) do |*args, **kwargs|
13-
PyCall.getattr(__pyobj__, name).(*args, **kwargs)
14-
end
15-
end
16-
17-
class << self
18-
attr_reader :__pyobj__
19-
20-
def method_missing(name, *args, **kwargs)
21-
return super unless PyCall.hasattr?(__pyobj__, name)
22-
PyCall.getattr(__pyobj__, name)
23-
end
24-
end
25-
26-
PyCall::Conversions.python_type_mapping(__pyobj__, self)
4+
wrap_class PyCall.import_module('matplotlib.axes').Axes
275
end
286
end

lib/matplotlib/axes_3d.rb

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,6 @@
11
module Matplotlib
22
class Axes3D
33
include PyCall::PyObjectWrapper
4-
5-
@__pyobj__ = PyCall.import_module('mpl_toolkits.mplot3d').Axes3D
6-
7-
PyCall.dir(@__pyobj__).each do |name|
8-
obj = PyCall.getattr(@__pyobj__, name)
9-
next unless obj.kind_of?(PyCall::PyObject) || obj.kind_of?(PyCall::PyObjectWrapper)
10-
next unless PyCall.callable?(obj)
11-
12-
define_method(name) do |*args, **kwargs|
13-
PyCall.getattr(__pyobj__, name).(*args, **kwargs)
14-
end
15-
end
16-
17-
class << self
18-
attr_reader :__pyobj__
19-
20-
def method_missing(name, *args, **kwargs)
21-
return super unless PyCall.hasattr?(__pyobj__, name)
22-
PyCall.getattr(__pyobj__, name)
23-
end
24-
end
25-
26-
PyCall::Conversions.python_type_mapping(__pyobj__, self)
4+
wrap_class PyCall.import_module('mpl_toolkits.mplot3d').Axes3D
275
end
286
end

0 commit comments

Comments
 (0)