Sha256: 25c7fc63b28fe3166b7da3de5a527031538a44b2791728265a4aacffab4dd793

Contents?: true

Size: 668 Bytes

Versions: 5

Compression:

Stored size: 668 Bytes

Contents

require 'matplotlib'

module Matplotlib
  module Pyplot
    @pyplot = PyCall.import_module('matplotlib.pyplot')
    PyCall.dir(@pyplot).each do |name|
      obj = PyCall.getattr(@pyplot, 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__
        @pyplot
      end

      def method_missing(name, *args, **kwargs)
        return super unless PyCall.hasattr?(@pyplot, name)
        PyCall.getattr(@pyplot, name)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
matplotlib-0.1.0.alpha.20170419a lib/matplotlib/pyplot.rb
matplotlib-0.1.0.alpha.20170311 lib/matplotlib/pyplot.rb
matplotlib-0.1.0.alpha.20170309 lib/matplotlib/pyplot.rb
matplotlib-0.1.0.alpha.20170307 lib/matplotlib/pyplot.rb
matplotlib-0.1.0.alpha.20170302 lib/matplotlib/pyplot.rb