1- require " matplotlib/version"
2- require 'pycall/import '
1+ require ' matplotlib/version'
2+ require 'pycall'
33
4- module Matplotlib
5- @matplotlib = PyCall . import_module ( 'matplotlib' )
6- PyCall . dir ( @matplotlib ) . each do |name |
7- obj = PyCall . getattr ( @matplotlib , name )
8- next unless obj . kind_of? ( PyCall ::PyObject ) || obj . kind_of? ( PyCall ::PyObjectWrapper )
9- next unless PyCall . callable? ( obj )
10-
11- define_singleton_method ( name ) do |*args , **kwargs |
12- obj . ( *args , **kwargs )
13- end
14- end
4+ Matplotlib = PyCall . import_module ( 'matplotlib' )
155
16- class << self
17- def __pyobj__
18- @matplotlib
19- end
20-
21- def method_missing ( name , *args , **kwargs )
22- return super unless PyCall . hasattr? ( @matplotlib , name )
23- PyCall . getattr ( @matplotlib , name )
24- end
25- end
6+ module Matplotlib
7+ VERSION = MATPLOTLIB_VERSION
8+ Object . class_eval { remove_const :MATPLOTLIB_VERSION }
269
2710 # FIXME: MacOSX backend is unavailable via pycall.
2811 # I don't know why it is.
29- if Matplotlib . get_backend ( ) == 'MacOSX'
30- Matplotlib . use ( 'TkAgg' )
12+ if get_backend == 'MacOSX'
13+ use ( 'TkAgg' )
3114 end
3215
3316 class Error < StandardError
@@ -40,4 +23,4 @@ class Error < StandardError
4023require 'matplotlib/figure'
4124require 'matplotlib/spines'
4225
43- PyCall . append_sys_path ( File . expand_path ( '../matplotlib/python' , __FILE__ ) )
26+ PyCall . sys . path . insert ( 0 , File . expand_path ( '../matplotlib/python' , __FILE__ ) )
0 commit comments