Skip to content

Commit

Permalink
Added updated matplotlib package
Browse files Browse the repository at this point in the history
  • Loading branch information
rexissimus committed Oct 13, 2015
1 parent 11db25b commit f0a0417
Show file tree
Hide file tree
Showing 23 changed files with 30,349 additions and 0 deletions.
94 changes: 94 additions & 0 deletions vistrails/packages/matplotlib-1.4/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
This version of the matplotlib package seeks to make the features much
more accessible in VisTrails. Previous versions required users to
type code to generate figures, and this usually required reading
external documentation. Because matplotlib has no standard way to
determine all method and parameter specification automatically. We
can, however, parse method declarations and the docutils documentation
to infer many of the input types. While this generates much of the
package specification, there are many pieces that are unknown without
checking the documentation and/or code manually. To allow both
automated generation and manual fixes to work, we use a multi-step process:

(1) Automated Generation: based on documentation, method
specifications, and heuristics, generate module and port
specifications in XML.

(2?) If a diff of previous edits exists (see step 3 & 4), apply it to
the automated output.

(3) Manual Fixes: Users then can manually edit the XML to fix and add
extra information. They can also specify python code in the mixins.py
file; this is nicer for editing than doing this in XML.

(4) Difference Computation: Find and store the differences in the XML
tree between the automated specs and the manual fixes. These
differences are used in step (2).

(5) Python Code Generation: Generate the VisTrails python wrapper code
from the XML.

This process is iterative as parsing heuristics may be updated and
many manual fixes may be required. The update.py script wraps this
entire process.

== Automated Generation ==

The automated generation scripts consist of a few techniques. First,
for plotting functions, we can parse the function specification using
python's inspect module, extracting argument names and defaults. For
artists (lines, patches, rectangles), the matplotlib authors have
tried to enforce property getters and setters, and they also have
documentation standards where developers specify an "ACCEPTS:" clause
which specifies what type of arguments the setters take. The
ArtistInspector is tasked to grab this information. Second, the
documentation is in docutils format which means we can run it through
the docutils parser to find tables and definition lists which can be
translated to variables and translation dictionaries (e.g. we can show
a user "upper center" but translate it to 9 for matplotlib). In
addition, we can search for certain keywords ("arguments") to find
definition lists that likely correspond to ports. Finally, we can
parse the call signatures which are sometimes present in the
documentation using python's ast module.

== XML Specification ==

The most important piece in updating the specs is understanding the
XML serialization. This serialization is a list of module specs which
in turn have input and output port specs. Input port specs may have
any number of alternate specs which represent alternative types for a
single input argument; for example, the box() method's width may be a
single scalar or a sequence of scalars. Output port specs are usually
used to track internal outputs that permit customization; **they are
not necessarily (nor often) associated with an actual output port**.
Instead, if a boxplot command produces a dictionary of outputs (each a
sequence of lines), the output port specs can specify how each artist
may be customized (colors). This is usually done with an
MplProperties subclass; the user adds the properties module as an
input and the automated compute() method sets those properties on the
artist objects output.

== Mixin Code ==

Users may specify blocks for the init, compute_before, compute_inner,
and compute_after methods. This code is **copied** when the template
is generated; mixins.py **is not imported** when the package is being
used.

== Shortcuts & Keywords ==

-- When specifying alternate input port specs, users need only provide
the port_type field; everything else can be inferred from the
parent port spec.

-- The output_type for a ModuleSpec should be one of "object",
"tuple", or "dict" if there is an output returned. Then, the
property_key for each output spec should be an integer for a tuple
and the key value for a dictionary.

-- When specifying output port specs, name and compute_name are
defaulted using the arg setting

-- The "__property__" output_type on an output port spec specifies
that this port is being used to identify an output of the plotting
command that can be customized according to the property_type
field.
67 changes: 67 additions & 0 deletions vistrails/packages/matplotlib-1.4/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
###############################################################################
##
## Copyright (C) 2014-2015, New York University.
## Copyright (C) 2011-2014, NYU-Poly.
## Copyright (C) 2006-2011, University of Utah.
## All rights reserved.
## Contact: contact@vistrails.org
##
## This file is part of VisTrails.
##
## "Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions are met:
##
## - Redistributions of source code must retain the above copyright notice,
## this list of conditions and the following disclaimer.
## - Redistributions in binary form must reproduce the above copyright
## notice, this list of conditions and the following disclaimer in the
## documentation and/or other materials provided with the distribution.
## - Neither the name of the New York University nor the names of its
## contributors may be used to endorse or promote products derived from
## this software without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
## THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
## OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
## WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
## OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
## ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
##
###############################################################################

"""Matplotlib package for VisTrails.
This package wrap Matplotlib to provide a plotting tool for
VisTrails. We are going to use the 'Qt4Agg' backend of the library.
"""

from __future__ import division

from identifiers import *

def package_dependencies():
import vistrails.core.packagemanager
manager = vistrails.core.packagemanager.get_package_manager()
if manager.has_package('org.vistrails.vistrails.spreadsheet'):
return ['org.vistrails.vistrails.spreadsheet']
else:
return []

def package_requirements():
from vistrails.core.requirements import require_python_module
require_python_module('numpy', {
'pip': 'numpy',
'linux-debian': 'python-numpy',
'linux-ubuntu': 'python-numpy',
'linux-fedora': 'numpy'})
mpl_dict = {'pip': 'matplotlib',
'linux-debian': 'python-matplotlib',
'linux-ubuntu': 'python-matplotlib',
'linux-fedora': 'python-matplotlib'}
require_python_module('matplotlib', mpl_dict)
require_python_module('pylab', mpl_dict)
Loading

0 comments on commit f0a0417

Please sign in to comment.