lib/matplotlib.rb in matplotlib-0.1.0.alpha.20170226 vs lib/matplotlib.rb in matplotlib-0.1.0.alpha.20170302
- old
+ new
@@ -3,19 +3,23 @@
module Matplotlib
@matplotlib = PyCall.import_module('matplotlib')
PyCall.dir(@matplotlib).each do |name|
obj = PyCall.getattr(@matplotlib, name)
- next unless obj.kind_of? PyCall::PyObject
- next unless obj.kind_of? PyCall::LibPython.PyFunction_Type
+ next unless obj.kind_of?(PyCall::PyObject) || obj.kind_of?(PyCall::PyObjectWrapper)
+ next unless PyCall.callable?(obj)
define_singleton_method(name) do |*args, **kwargs|
obj.(*args, **kwargs)
end
end
class << self
+ def __pyobj__
+ @matplotlib
+ end
+
def method_missing(name, *args, **kwargs)
return super unless PyCall.hasattr?(@matplotlib, name)
PyCall.getattr(@matplotlib, name)
end
end
@@ -26,10 +30,9 @@
Matplotlib.use('TkAgg')
end
class Error < StandardError
end
-
- class Figure
- include PyCall::PyObjectWrapper
- end
end
+
+require 'matplotlib/axes'
+require 'matplotlib/figure'