Sha256: 681a031f7591c503c962172a747041ff674f9690f17983f3f9c1cf5fc5bbf589

Contents?: true

Size: 857 Bytes

Versions: 1

Compression:

Stored size: 857 Bytes

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
    next unless obj.kind_of? PyCall::LibPython.PyFunction_Type

    define_singleton_method(name) do |*args, **kwargs|
      obj.(*args, **kwargs)
    end
  end

  class << self
    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

  class Figure
    include PyCall::PyObjectWrapper
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
matplotlib-0.1.0.alpha.20170226 lib/matplotlib.rb