Sha256: a87568541ddbc7c12a1315b03a29f9d5f3e6ee1a107b4c2b55f776d621ccb1c0

Contents?: true

Size: 1 KB

Versions: 3

Compression:

Stored size: 1 KB

Contents

require "matplotlib/version"
require 'pycall/import'

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) || 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

  # FIXME: MacOSX backend is unavailable via pycall.
  #        I don't know why it is.
  if Matplotlib.get_backend() == 'MacOSX'
    Matplotlib.use('TkAgg')
  end

  class Error < StandardError
  end
end

require 'matplotlib/axes'
require 'matplotlib/polar_axes'
require 'matplotlib/figure'

PyCall.append_sys_path(File.expand_path('../matplotlib/python', __FILE__))

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
matplotlib-0.1.0.alpha.20170311 lib/matplotlib.rb
matplotlib-0.1.0.alpha.20170309 lib/matplotlib.rb
matplotlib-0.1.0.alpha.20170307 lib/matplotlib.rb