SourceForge logo
SourceForge logo
Menu

matplotlib-checkins — Commit notification. DO NOT POST to this list, just subscribe to it.

You can subscribe to this list here.

2007 Jan
Feb
Mar
Apr
May
Jun
Jul
(115)
Aug
(120)
Sep
(137)
Oct
(170)
Nov
(461)
Dec
(263)
2008 Jan
(120)
Feb
(74)
Mar
(35)
Apr
(74)
May
(245)
Jun
(356)
Jul
(240)
Aug
(115)
Sep
(78)
Oct
(225)
Nov
(98)
Dec
(271)
2009 Jan
(132)
Feb
(84)
Mar
(74)
Apr
(56)
May
(90)
Jun
(79)
Jul
(83)
Aug
(296)
Sep
(214)
Oct
(76)
Nov
(82)
Dec
(66)
2010 Jan
(46)
Feb
(58)
Mar
(51)
Apr
(77)
May
(58)
Jun
(126)
Jul
(128)
Aug
(64)
Sep
(50)
Oct
(44)
Nov
(48)
Dec
(54)
2011 Jan
(68)
Feb
(52)
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
(1)
2018 Jan
Feb
Mar
Apr
May
(1)
Jun
Jul
Aug
Sep
Oct
Nov
Dec
S M T W T F S





1
(12)
2
(3)
3
(2)
4
(15)
5
(4)
6
(8)
7
(14)
8
(10)
9
(6)
10
(1)
11
(5)
12
(7)
13
(7)
14
(1)
15
16
(1)
17
(2)
18
(4)
19
(2)
20
21
(1)
22
(2)
23
24
25
(2)
26
(1)
27
28
(4)
29
30
(1)
31






Showing results of 115

<< < 1 2 3 4 5 > >> (Page 2 of 5)
From: <md...@us...> - 2008年08月13日 15:00:10
Revision: 6031
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6031&view=rev
Author: mdboom
Date: 2008年08月13日 15:00:05 +0000 (2008年8月13日)
Log Message:
-----------
Raise ImportError rather than SystemExit --
that is, importing an improperly configured matplotlib should not quit the Python console.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/__init__.py
 trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py
 trunk/matplotlib/lib/matplotlib/backends/backend_gdk.py
 trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
 trunk/matplotlib/lib/matplotlib/finance.py
Modified: trunk/matplotlib/lib/matplotlib/__init__.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/__init__.py	2008年08月13日 14:09:04 UTC (rev 6030)
+++ trunk/matplotlib/lib/matplotlib/__init__.py	2008年08月13日 15:00:05 UTC (rev 6031)
@@ -144,12 +144,12 @@
 #else: _have_pkg_resources = True
 
 if not _python24:
- raise SystemExit('matplotlib requires Python 2.4 or later')
+ raise ImportError('matplotlib requires Python 2.4 or later')
 
 import numpy
 nn = numpy.__version__.split('.')
 if not (int(nn[0]) >= 1 and int(nn[1]) >= 1):
- raise SystemExit(
+ raise ImportError(
 'numpy 1.1 or later is required; you have %s' % numpy.__version__)
 
 def is_string_like(obj):
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py	2008年08月13日 14:09:04 UTC (rev 6030)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py	2008年08月13日 15:00:05 UTC (rev 6031)
@@ -28,7 +28,7 @@
 import cairo
 _version_required = (1,2,0)
 if cairo.version_info < _version_required:
- raise SystemExit ("Pycairo %d.%d.%d is installed\n"
+ raise ImportError ("Pycairo %d.%d.%d is installed\n"
 "Pycairo %d.%d.%d or later is required"
 % (cairo.version_info + _version_required))
 backend_version = cairo.version
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gdk.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_gdk.py	2008年08月13日 14:09:04 UTC (rev 6030)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_gdk.py	2008年08月13日 15:00:05 UTC (rev 6031)
@@ -11,7 +11,7 @@
 import pango
 pygtk_version_required = (2,2,0)
 if gtk.pygtk_version < pygtk_version_required:
- raise SystemExit ("PyGTK %d.%d.%d is installed\n"
+ raise ImportError ("PyGTK %d.%d.%d is installed\n"
 "PyGTK %d.%d.%d or later is required"
 % (gtk.pygtk_version + pygtk_version_required))
 del pygtk_version_required
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py	2008年08月13日 14:09:04 UTC (rev 6030)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py	2008年08月13日 15:00:05 UTC (rev 6031)
@@ -8,7 +8,7 @@
 import pango
 pygtk_version_required = (2,2,0)
 if gtk.pygtk_version < pygtk_version_required:
- raise SystemExit ("PyGTK %d.%d.%d is installed\n"
+ raise ImportError ("PyGTK %d.%d.%d is installed\n"
 "PyGTK %d.%d.%d or later is required"
 % (gtk.pygtk_version + pygtk_version_required))
 del pygtk_version_required
Modified: trunk/matplotlib/lib/matplotlib/finance.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/finance.py	2008年08月13日 14:09:04 UTC (rev 6030)
+++ trunk/matplotlib/lib/matplotlib/finance.py	2008年08月13日 15:00:05 UTC (rev 6031)
@@ -14,7 +14,7 @@
 
 try: import datetime
 except ImportError:
- raise SystemExit('The finance module requires datetime support (python2.3)')
+ raise ImportError('The finance module requires datetime support (python2.3)')
 
 import numpy as np
 
@@ -415,7 +415,7 @@
 
 # note this code assumes if any value open, close, low, high is
 # missing they all are missing
- 
+
 delta = width/2.
 barVerts = [ ( (i-delta, open), (i-delta, close), (i+delta, close), (i+delta, open) ) for i, open, close in zip(xrange(len(opens)), opens, closes) if open != -1 and close!=-1 ]
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6030
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6030&view=rev
Author: mdboom
Date: 2008年08月13日 14:09:04 +0000 (2008年8月13日)
Log Message:
-----------
Bumping version number.
Modified Paths:
--------------
 trunk/py4science/examples/sphinx_template/conf.py
Modified: trunk/py4science/examples/sphinx_template/conf.py
===================================================================
--- trunk/py4science/examples/sphinx_template/conf.py	2008年08月13日 13:11:51 UTC (rev 6029)
+++ trunk/py4science/examples/sphinx_template/conf.py	2008年08月13日 14:09:04 UTC (rev 6030)
@@ -48,9 +48,9 @@
 # other places throughout the built documents.
 #
 # The short X.Y version.
-version = '0.1'
+version = '0.2'
 # The full version, including alpha/beta/rc tags.
-release = '0.1'
+release = '0.2'
 
 # There are two options for replacing |today|: either, you set today to some
 # non-false value, then it is used:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6029
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6029&view=rev
Author: jswhit
Date: 2008年08月13日 13:11:51 +0000 (2008年8月13日)
Log Message:
-----------
more kludges for geos 3.0.0
Modified Paths:
--------------
 trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py	2008年08月12日 18:36:29 UTC (rev 6028)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py	2008年08月13日 13:11:51 UTC (rev 6029)
@@ -913,6 +913,12 @@
 antart = True
 else:
 poly = Shape(b)
+ # this is a workaround to avoid
+ # "GEOS_ERROR: TopologyException: 
+ # found non-noded intersection between ..."
+ # with geos 3.0.0
+ if _geoslib.__geos_major_version__ > 2:
+ poly = poly.simplify(1.e-10)
 antart = False
 # create duplicate polygons shifted by -360 and +360
 # (so as to properly treat polygons that cross
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6028
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6028&view=rev
Author: mdboom
Date: 2008年08月12日 18:36:29 +0000 (2008年8月12日)
Log Message:
-----------
Small bugfix in inheritance_diagram.py
Modified Paths:
--------------
 trunk/matplotlib/doc/sphinxext/inheritance_diagram.py
Modified: trunk/matplotlib/doc/sphinxext/inheritance_diagram.py
===================================================================
--- trunk/matplotlib/doc/sphinxext/inheritance_diagram.py	2008年08月12日 18:35:53 UTC (rev 6027)
+++ trunk/matplotlib/doc/sphinxext/inheritance_diagram.py	2008年08月12日 18:36:29 UTC (rev 6028)
@@ -81,10 +81,9 @@
 raise ValueError(
 "Invalid class or module '%s' specified for inheritance diagram" % name)
 fullname = (path or '') + base
- path = path and path.rstrip('.')
+ path = (path and path.rstrip('.'))
 if not path:
- raise ValueError(
- "Invalid class or module '%s' specified for inheritance diagram" % name)
+ path = base
 try:
 module = __import__(path, None, None, [])
 except ImportError:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2008年08月12日 18:35:59
Revision: 6027
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6027&view=rev
Author: mdboom
Date: 2008年08月12日 18:35:53 +0000 (2008年8月12日)
Log Message:
-----------
Add new features to template in prep for SciPy 08
Modified Paths:
--------------
 trunk/py4science/examples/sphinx_template/conf.py
 trunk/py4science/examples/sphinx_template/make.py
 trunk/py4science/examples/sphinx_template/model/api_docs.rst
 trunk/py4science/examples/sphinx_template/model/sphinx_helpers.rst
 trunk/py4science/examples/sphinx_template/simulations/finale.rst
 trunk/py4science/examples/sphinx_template/simulations/preliminary.rst
 trunk/py4science/examples/sphinx_template/sphinxext/ipython_console_highlighting.py
 trunk/py4science/examples/sphinx_template/sphinxext/mathmpl.py
Added Paths:
-----------
 trunk/py4science/examples/sphinx_template/pyplots/
 trunk/py4science/examples/sphinx_template/pyplots/elegant.py
 trunk/py4science/examples/sphinx_template/pyplots/hairy.py
 trunk/py4science/examples/sphinx_template/sphinxext/inheritance_diagram.py
 trunk/py4science/examples/sphinx_template/sphinxext/only_directives.py
 trunk/py4science/examples/sphinx_template/sphinxext/plot_directive.py
Removed Paths:
-------------
 trunk/py4science/examples/sphinx_template/simulations/code/
Modified: trunk/py4science/examples/sphinx_template/conf.py
===================================================================
--- trunk/py4science/examples/sphinx_template/conf.py	2008年08月12日 18:01:52 UTC (rev 6026)
+++ trunk/py4science/examples/sphinx_template/conf.py	2008年08月12日 18:35:53 UTC (rev 6027)
@@ -28,7 +28,8 @@
 
 # Add any Sphinx extension module names here, as strings. They can be extensions
 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
-extensions = ['mathpng', 'sphinx.ext.autodoc']
+extensions = ['mathmpl', 'ipython_console_highlighting', 'sphinx.ext.autodoc',
+ 'inheritance_diagram', 'only_directives', 'plot_directive']
 
 # Add any paths that contain templates here, relative to this directory.
 templates_path = ['_templates']
Modified: trunk/py4science/examples/sphinx_template/make.py
===================================================================
--- trunk/py4science/examples/sphinx_template/make.py	2008年08月12日 18:01:52 UTC (rev 6026)
+++ trunk/py4science/examples/sphinx_template/make.py	2008年08月12日 18:35:53 UTC (rev 6027)
@@ -14,17 +14,12 @@
 except OSError:
 pass
 
-def figs():
- os.system('cd simulations/code/ && python make.py')
-
 def html():
 check_build()
- figs()
 os.system('sphinx-build -b html -d build/doctrees . build/html')
 
 def latex():
 check_build()
- figs()
 if sys.platform != 'win32':
 # LaTeX format.
 os.system('sphinx-build -b latex -d build/doctrees . build/latex')
@@ -47,13 +42,11 @@
 shutil.rmtree('build')
 
 def all():
- figs()
 html()
 latex()
 
 
-funcd = {'figs':figs,
- 'html':html,
+funcd = {'html':html,
 'latex':latex,
 'clean':clean,
 'all':all,
Modified: trunk/py4science/examples/sphinx_template/model/api_docs.rst
===================================================================
--- trunk/py4science/examples/sphinx_template/model/api_docs.rst	2008年08月12日 18:01:52 UTC (rev 6026)
+++ trunk/py4science/examples/sphinx_template/model/api_docs.rst	2008年08月12日 18:35:53 UTC (rev 6027)
@@ -6,7 +6,7 @@
 
 It is easy to autodocument API code if the code has REST docstrings
 using the sphinx `autodoc <http://sphinx.pocoo.org/ext/autodoc.html>`_
-facilites.
+facilities.
 
 :mod:`matplotlib.backend_bases`
 ================================
Modified: trunk/py4science/examples/sphinx_template/model/sphinx_helpers.rst
===================================================================
--- trunk/py4science/examples/sphinx_template/model/sphinx_helpers.rst	2008年08月12日 18:01:52 UTC (rev 6026)
+++ trunk/py4science/examples/sphinx_template/model/sphinx_helpers.rst	2008年08月12日 18:35:53 UTC (rev 6027)
@@ -88,6 +88,9 @@
 antialiased or aa: [True | False]
 ...snip
 
+This support is included in this template, but will also be included
+in a future version of Pygments by default.
+
 .. _formatting-text:
 
 Formatting text
@@ -102,7 +105,7 @@
 
 Or literally include code:
 
-.. literalinclude:: ../simulations/code/elegant.py
+.. literalinclude:: ../pyplots/elegant.py
 
 
 .. _using-math:
@@ -117,26 +120,61 @@
 
 W^{3\beta}_{\delta_1 \rho_1 \sigma_2} = U^{3\beta}_{\delta_1 \rho_1} + \frac{1}{8 \pi 2} \int^{\alpha_2}_{\alpha_2} d \alpha^\prime_2 \left[\frac{ U^{2\beta}_{\delta_1 \rho_1} - \alpha^\prime_2U^{1\beta}_{\rho_1 \sigma_2} }{U^{0\beta}_{\rho_1 \sigma_2}}\right]
 
+This documentation framework includes a Sphinx extension,
+:file:`sphinxext/mathmpl.py`, that uses matplotlib to render math
+equations when generating HTML, and LaTeX itself when generating a
+PDF. This can be useful on systems that have matplotlib, but not
+LaTeX, installed. To use it, add ``mathpng`` to the list of
+extensions in :file:`conf.py`.
 
-There is a :file:`spinxext/mathml.py` file in the
-:file:`spinx_template` directory which can be enabled via the
-:file:`conf.py` configuration file. However, we have found that
-resultant html is not supported across many browsers, so have added a
-sphinx extension for translating math to png. In the file
-:file:`sphinxext/mathpng.py` there are two functions ``latex2png``. 
-The first one requires latex and dvipng, and the second one uses
-matplotlib mathtext (requires mpl svn rxx or later). Because the 2nd
-function replaces the first one, the matplotlib mathtext support is on
-by default, so you can generate equation enabled html anywhere
-matplotlib is installed (for PDF you will still need pdflatex
-installed). If you would rather use latex and dvipng, simply hide the
-second ``latex2png`` definition, eg by renaming the second function
-``_latex2png``.
+Current SVN versions of Sphinx now include built-in support for math.
+There are two flavors:
 
+ - pngmath: uses dvipng to render the equation
 
+ - jsmath: renders the math in the browser using Javascript
 
+To use these extensions instead, add ``sphinx.ext.pngmath`` or
+``sphinx.ext.jsmath`` to the list of extensions in :file:`conf.py`.
+
+All three of these options for math are designed to behave in the same
+way.
+
 .. _emacs-helpers:
 
+Inserting matplotlib plots
+==========================
+
+Inserting automatically-generated plots is easy. Simply put the
+script to generate the plot in the :file:`pyplots` directory, and
+refer to it using the ``plot`` directive. To include the source code
+for the plot in the document, pass the ``include-source`` parameter::
+
+ .. plot:: elegant.py
+ :include-source:
+
+In the HTML version of the document, the plot includes links to the
+original source code, a high-resolution PNG and a PDF. In the PDF
+version of the document, the plot is included as a scalable PDF.
+
+.. plot:: elegant.py
+ :include-source:
+
+Inheritance diagrams
+====================
+
+Inheritance diagrams can be inserted directly into the document by
+providing a list of class or module names to the
+``inheritance-diagram`` directive.
+
+For example::
+
+ .. inheritance-diagram:: codecs
+
+produces:
+
+.. inheritance-diagram:: codecs
+
 Emacs helpers
 =============
 
Copied: trunk/py4science/examples/sphinx_template/pyplots/elegant.py (from rev 6022, trunk/py4science/examples/sphinx_template/simulations/code/elegant.py)
===================================================================
--- trunk/py4science/examples/sphinx_template/pyplots/elegant.py	 (rev 0)
+++ trunk/py4science/examples/sphinx_template/pyplots/elegant.py	2008年08月12日 18:35:53 UTC (rev 6027)
@@ -0,0 +1,4 @@
+import matplotlib.pyplot as plt
+plt.plot([1,2,3], [4,5,6])
+plt.ylabel('some more numbers')
+
Copied: trunk/py4science/examples/sphinx_template/pyplots/hairy.py (from rev 6022, trunk/py4science/examples/sphinx_template/simulations/code/hairy.py)
===================================================================
--- trunk/py4science/examples/sphinx_template/pyplots/hairy.py	 (rev 0)
+++ trunk/py4science/examples/sphinx_template/pyplots/hairy.py	2008年08月12日 18:35:53 UTC (rev 6027)
@@ -0,0 +1,4 @@
+import matplotlib.pyplot as plt
+plt.plot([1,2,3])
+plt.ylabel('some numbers')
+
Modified: trunk/py4science/examples/sphinx_template/simulations/finale.rst
===================================================================
--- trunk/py4science/examples/sphinx_template/simulations/finale.rst	2008年08月12日 18:01:52 UTC (rev 6026)
+++ trunk/py4science/examples/sphinx_template/simulations/finale.rst	2008年08月12日 18:35:53 UTC (rev 6027)
@@ -5,13 +5,8 @@
 *************
 
 
-After much head scratching, I wrote this big elegant piece of code
+After much head scratching, I wrote this big elegant piece of code, to
+produce this much more elegant figure:
 
-.. literalinclude:: code/elegant.py
-
-which produced this elegant figure
-
-.. image:: code/elegant.png
- :scale: 50
-
-
+.. plot:: elegant.py
+ :include-source:
Modified: trunk/py4science/examples/sphinx_template/simulations/preliminary.rst
===================================================================
--- trunk/py4science/examples/sphinx_template/simulations/preliminary.rst	2008年08月12日 18:01:52 UTC (rev 6026)
+++ trunk/py4science/examples/sphinx_template/simulations/preliminary.rst	2008年08月12日 18:35:53 UTC (rev 6027)
@@ -4,14 +4,8 @@
 Preliminary tests
 *****************
 
-I wrote this big hairy piece of code
+I wrote this big hairy piece of code to make the following plot:
 
-.. literalinclude:: code/hairy.py
+.. plot:: hairy.py
+ :include-source:
 
-
-which produced this lovely figure
-
-.. image:: code/hairy.png
- :scale: 50
-
-
Added: trunk/py4science/examples/sphinx_template/sphinxext/inheritance_diagram.py
===================================================================
--- trunk/py4science/examples/sphinx_template/sphinxext/inheritance_diagram.py	 (rev 0)
+++ trunk/py4science/examples/sphinx_template/sphinxext/inheritance_diagram.py	2008年08月12日 18:35:53 UTC (rev 6027)
@@ -0,0 +1,423 @@
+"""
+Defines a docutils directive for inserting inheritance diagrams.
+
+Provide the directive with one or more classes or modules (separated
+by whitespace). For modules, all of the classes in that module will
+be used.
+
+Example::
+
+ Given the following classes:
+
+ class A: pass
+ class B(A): pass
+ class C(A): pass
+ class D(B, C): pass
+ class E(B): pass
+
+ .. inheritance-diagram: D E
+
+ Produces a graph like the following:
+
+ A
+ / \
+ B C
+ / \ /
+ E D
+
+The graph is inserted as a PNG+image map into HTML and a PDF in
+LaTeX.
+"""
+
+import inspect
+import os
+import re
+import subprocess
+try:
+ from hashlib import md5
+except ImportError:
+ from md5 import md5
+
+from docutils.nodes import Body, Element
+from docutils.writers.html4css1 import HTMLTranslator
+from sphinx.latexwriter import LaTeXTranslator
+from docutils.parsers.rst import directives
+from sphinx.roles import xfileref_role
+
+class DotException(Exception):
+ pass
+
+class InheritanceGraph(object):
+ """
+ Given a list of classes, determines the set of classes that
+ they inherit from all the way to the root "object", and then
+ is able to generate a graphviz dot graph from them.
+ """
+ def __init__(self, class_names, show_builtins=False):
+ """
+ *class_names* is a list of child classes to show bases from.
+
+ If *show_builtins* is True, then Python builtins will be shown
+ in the graph.
+ """
+ self.class_names = class_names
+ self.classes = self._import_classes(class_names)
+ self.all_classes = self._all_classes(self.classes)
+ if len(self.all_classes) == 0:
+ raise ValueError("No classes found for inheritance diagram")
+ self.show_builtins = show_builtins
+
+ py_sig_re = re.compile(r'''^([\w.]*\.)? # class names
+ (\w+) \s* $ # optionally arguments
+ ''', re.VERBOSE)
+
+ def _import_class_or_module(self, name):
+ """
+ Import a class using its fully-qualified *name*.
+ """
+ try:
+ path, base = self.py_sig_re.match(name).groups()
+ except:
+ raise ValueError(
+ "Invalid class or module '%s' specified for inheritance diagram" % name)
+ fullname = (path or '') + base
+ path = (path and path.rstrip('.'))
+ if not path:
+ path = base
+ if not path:
+ raise ValueError(
+ "Invalid class or module '%s' specified for inheritance diagram" % name)
+ try:
+ module = __import__(path, None, None, [])
+ except ImportError:
+ raise ValueError(
+ "Could not import class or module '%s' specified for inheritance diagram" % name)
+
+ try:
+ todoc = module
+ for comp in fullname.split('.')[1:]:
+ todoc = getattr(todoc, comp)
+ except AttributeError:
+ raise ValueError(
+ "Could not find class or module '%s' specified for inheritance diagram" % name)
+
+ # If a class, just return it
+ if inspect.isclass(todoc):
+ return [todoc]
+ elif inspect.ismodule(todoc):
+ classes = []
+ for cls in todoc.__dict__.values():
+ if inspect.isclass(cls) and cls.__module__ == todoc.__name__:
+ classes.append(cls)
+ return classes
+ raise ValueError(
+ "'%s' does not resolve to a class or module" % name)
+
+ def _import_classes(self, class_names):
+ """
+ Import a list of classes.
+ """
+ classes = []
+ for name in class_names:
+ classes.extend(self._import_class_or_module(name))
+ return classes
+
+ def _all_classes(self, classes):
+ """
+ Return a list of all classes that are ancestors of *classes*.
+ """
+ all_classes = {}
+
+ def recurse(cls):
+ all_classes[cls] = None
+ for c in cls.__bases__:
+ if c not in all_classes:
+ recurse(c)
+
+ for cls in classes:
+ recurse(cls)
+
+ return all_classes.keys()
+
+ def class_name(self, cls, parts=0):
+ """
+ Given a class object, return a fully-qualified name. This
+ works for things I've tested in matplotlib so far, but may not
+ be completely general.
+ """
+ module = cls.__module__
+ if module == '__builtin__':
+ fullname = cls.__name__
+ else:
+ fullname = "%s.%s" % (module, cls.__name__)
+ if parts == 0:
+ return fullname
+ name_parts = fullname.split('.')
+ return '.'.join(name_parts[-parts:])
+
+ def get_all_class_names(self):
+ """
+ Get all of the class names involved in the graph.
+ """
+ return [self.class_name(x) for x in self.all_classes]
+
+ # These are the default options for graphviz
+ default_graph_options = {
+ "rankdir": "LR",
+ "size": '"8.0, 12.0"'
+ }
+ default_node_options = {
+ "shape": "box",
+ "fontsize": 10,
+ "height": 0.25,
+ "fontname": "Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",
+ "style": '"setlinewidth(0.5)"'
+ }
+ default_edge_options = {
+ "arrowsize": 0.5,
+ "style": '"setlinewidth(0.5)"'
+ }
+
+ def _format_node_options(self, options):
+ return ','.join(["%s=%s" % x for x in options.items()])
+ def _format_graph_options(self, options):
+ return ''.join(["%s=%s;\n" % x for x in options.items()])
+
+ def generate_dot(self, fd, name, parts=0, urls={},
+ graph_options={}, node_options={},
+ edge_options={}):
+ """
+ Generate a graphviz dot graph from the classes that
+ were passed in to __init__.
+
+ *fd* is a Python file-like object to write to.
+
+ *name* is the name of the graph
+
+ *urls* is a dictionary mapping class names to http urls
+
+ *graph_options*, *node_options*, *edge_options* are
+ dictionaries containing key/value pairs to pass on as graphviz
+ properties.
+ """
+ g_options = self.default_graph_options.copy()
+ g_options.update(graph_options)
+ n_options = self.default_node_options.copy()
+ n_options.update(node_options)
+ e_options = self.default_edge_options.copy()
+ e_options.update(edge_options)
+
+ fd.write('digraph %s {\n' % name)
+ fd.write(self._format_graph_options(g_options))
+
+ for cls in self.all_classes:
+ if not self.show_builtins and cls in __builtins__.values():
+ continue
+
+ name = self.class_name(cls, parts)
+
+ # Write the node
+ this_node_options = n_options.copy()
+ url = urls.get(self.class_name(cls))
+ if url is not None:
+ this_node_options['URL'] = '"%s"' % url
+ fd.write(' "%s" [%s];\n' %
+ (name, self._format_node_options(this_node_options)))
+
+ # Write the edges
+ for base in cls.__bases__:
+ if not self.show_builtins and base in __builtins__.values():
+ continue
+
+ base_name = self.class_name(base, parts)
+ fd.write(' "%s" -> "%s" [%s];\n' %
+ (base_name, name,
+ self._format_node_options(e_options)))
+ fd.write('}\n')
+
+ def run_dot(self, args, name, parts=0, urls={},
+ graph_options={}, node_options={}, edge_options={}):
+ """
+ Run graphviz 'dot' over this graph, returning whatever 'dot'
+ writes to stdout.
+
+ *args* will be passed along as commandline arguments.
+
+ *name* is the name of the graph
+
+ *urls* is a dictionary mapping class names to http urls
+
+ Raises DotException for any of the many os and
+ installation-related errors that may occur.
+ """
+ try:
+ dot = subprocess.Popen(['dot'] + list(args),
+ stdin=subprocess.PIPE, stdout=subprocess.PIPE,
+ close_fds=True)
+ except OSError:
+ raise DotException("Could not execute 'dot'. Are you sure you have 'graphviz' installed?")
+ except ValueError:
+ raise DotException("'dot' called with invalid arguments")
+ except:
+ raise DotException("Unexpected error calling 'dot'")
+
+ self.generate_dot(dot.stdin, name, parts, urls, graph_options,
+ node_options, edge_options)
+ dot.stdin.close()
+ result = dot.stdout.read()
+ returncode = dot.wait()
+ if returncode != 0:
+ raise DotException("'dot' returned the errorcode %d" % returncode)
+ return result
+
+class inheritance_diagram(Body, Element):
+ """
+ A docutils node to use as a placeholder for the inheritance
+ diagram.
+ """
+ pass
+
+def inheritance_diagram_directive_run(class_names, options, state):
+ """
+ Run when the inheritance_diagram directive is first encountered.
+ """
+ node = inheritance_diagram()
+
+ # Create a graph starting with the list of classes
+ graph = InheritanceGraph(class_names)
+
+ # Create xref nodes for each target of the graph's image map and
+ # add them to the doc tree so that Sphinx can resolve the
+ # references to real URLs later. These nodes will eventually be
+ # removed from the doctree after we're done with them.
+ for name in graph.get_all_class_names():
+ refnodes, x = xfileref_role(
+ 'class', ':class:`%s`' % name, name, 0, state)
+ node.extend(refnodes)
+ # Store the graph object so we can use it to generate the
+ # dot file later
+ node['graph'] = graph
+ # Store the original content for use as a hash
+ node['parts'] = options.get('parts', 0)
+ node['content'] = " ".join(class_names)
+ return [node]
+
+def get_graph_hash(node):
+ return md5(node['content'] + str(node['parts'])).hexdigest()[-10:]
+
+def html_output_graph(self, node):
+ """
+ Output the graph for HTML. This will insert a PNG with clickable
+ image map.
+ """
+ graph = node['graph']
+ parts = node['parts']
+
+ graph_hash = get_graph_hash(node)
+ name = "inheritance%s" % graph_hash
+ png_path = os.path.join('_static', name + ".png")
+
+ path = '_static'
+ source = self.document.attributes['source']
+ count = source.split('/doc/')[-1].count('/')
+ for i in range(count):
+ if os.path.exists(path): break
+ path = '../'+path
+ path = '../'+path #specifically added for matplotlib
+
+ # Create a mapping from fully-qualified class names to URLs.
+ urls = {}
+ for child in node:
+ if child.get('refuri') is not None:
+ urls[child['reftitle']] = child.get('refuri')
+ elif child.get('refid') is not None:
+ urls[child['reftitle']] = '#' + child.get('refid')
+
+ # These arguments to dot will save a PNG file to disk and write
+ # an HTML image map to stdout.
+ image_map = graph.run_dot(['-Tpng', '-o%s' % png_path, '-Tcmapx'],
+ name, parts, urls)
+ return ('<img src="%s/%s.png" usemap="#%s" class="inheritance"/>%s' %
+ (path, name, name, image_map))
+
+def latex_output_graph(self, node):
+ """
+ Output the graph for LaTeX. This will insert a PDF.
+ """
+ graph = node['graph']
+ parts = node['parts']
+
+ graph_hash = get_graph_hash(node)
+ name = "inheritance%s" % graph_hash
+ pdf_path = os.path.join('_static', name + ".pdf")
+
+ graph.run_dot(['-Tpdf', '-o%s' % pdf_path],
+ name, parts, graph_options={'size': '"6.0,6.0"'})
+ return '\\includegraphics{../../%s}' % pdf_path
+
+def visit_inheritance_diagram(inner_func):
+ """
+ This is just a wrapper around html/latex_output_graph to make it
+ easier to handle errors and insert warnings.
+ """
+ def visitor(self, node):
+ try:
+ content = inner_func(self, node)
+ except DotException, e:
+ # Insert the exception as a warning in the document
+ warning = self.document.reporter.warning(str(e), line=node.line)
+ warning.parent = node
+ node.children = [warning]
+ else:
+ source = self.document.attributes['source']
+ self.body.append(content)
+ node.children = []
+ return visitor
+
+def do_nothing(self, node):
+ pass
+
+options_spec = {
+ 'parts': directives.nonnegative_int
+ }
+
+# Deal with the old and new way of registering directives
+try:
+ from docutils.parsers.rst import Directive
+except ImportError:
+ from docutils.parsers.rst.directives import _directives
+ def inheritance_diagram_directive(name, arguments, options, content, lineno,
+ content_offset, block_text, state,
+ state_machine):
+ return inheritance_diagram_directive_run(arguments, options, state)
+ inheritance_diagram_directive.__doc__ = __doc__
+ inheritance_diagram_directive.arguments = (1, 100, 0)
+ inheritance_diagram_directive.options = options_spec
+ inheritance_diagram_directive.content = 0
+ _directives['inheritance-diagram'] = inheritance_diagram_directive
+else:
+ class inheritance_diagram_directive(Directive):
+ has_content = False
+ required_arguments = 1
+ optional_arguments = 100
+ final_argument_whitespace = False
+ option_spec = options_spec
+
+ def run(self):
+ return inheritance_diagram_directive_run(
+ self.arguments, self.options, self.state)
+ inheritance_diagram_directive.__doc__ = __doc__
+
+ directives.register_directive('inheritance-diagram',
+ inheritance_diagram_directive)
+
+def setup(app):
+ app.add_node(inheritance_diagram)
+
+ HTMLTranslator.visit_inheritance_diagram = \
+ visit_inheritance_diagram(html_output_graph)
+ HTMLTranslator.depart_inheritance_diagram = do_nothing
+
+ LaTeXTranslator.visit_inheritance_diagram = \
+ visit_inheritance_diagram(latex_output_graph)
+ LaTeXTranslator.depart_inheritance_diagram = do_nothing
Modified: trunk/py4science/examples/sphinx_template/sphinxext/ipython_console_highlighting.py
===================================================================
--- trunk/py4science/examples/sphinx_template/sphinxext/ipython_console_highlighting.py	2008年08月12日 18:01:52 UTC (rev 6026)
+++ trunk/py4science/examples/sphinx_template/sphinxext/ipython_console_highlighting.py	2008年08月12日 18:35:53 UTC (rev 6027)
@@ -13,7 +13,7 @@
 
 Tracebacks are not currently supported.
 
- .. sourcecode:: pycon
+ .. sourcecode:: ipython
 
 In [1]: a = 'foo'
 
Modified: trunk/py4science/examples/sphinx_template/sphinxext/mathmpl.py
===================================================================
--- trunk/py4science/examples/sphinx_template/sphinxext/mathmpl.py	2008年08月12日 18:01:52 UTC (rev 6026)
+++ trunk/py4science/examples/sphinx_template/sphinxext/mathmpl.py	2008年08月12日 18:35:53 UTC (rev 6027)
@@ -5,21 +5,36 @@
 from md5 import md5
 
 from docutils import nodes
+from docutils.parsers.rst import directives
 from docutils.writers.html4css1 import HTMLTranslator
 from sphinx.latexwriter import LaTeXTranslator
+import warnings
 
 # Define LaTeX math node:
 class latex_math(nodes.General, nodes.Element):
 pass
 
+def fontset_choice(arg):
+ return directives.choice(arg, ['cm', 'stix', 'stixsans'])
+
+options_spec = {'fontset': fontset_choice}
+
 def math_role(role, rawtext, text, lineno, inliner,
 options={}, content=[]):
 i = rawtext.find('`')
 latex = rawtext[i+1:-1]
 node = latex_math(rawtext)
 node['latex'] = latex
+ node['fontset'] = options.get('fontset', 'cm')
 return [node], []
+math_role.options = options_spec
 
+def math_directive_run(content, block_text, options):
+ latex = ''.join(content)
+ node = latex_math(block_text)
+ node['latex'] = latex
+ node['fontset'] = options.get('fontset', 'cm')
+ return [node]
 
 try:
 from docutils.parsers.rst import Directive
@@ -28,22 +43,19 @@
 from docutils.parsers.rst.directives import _directives
 def math_directive(name, arguments, options, content, lineno,
 content_offset, block_text, state, state_machine):
- latex = ''.join(content)
- node = latex_math(block_text)
- node['latex'] = latex
- return [node]
+ return math_directive_run(content, block_text, options)
 math_directive.arguments = None
- math_directive.options = {}
+ math_directive.options = options_spec
 math_directive.content = 1
 _directives['math'] = math_directive
 else:
 class math_directive(Directive):
 has_content = True
+ option_spec = options_spec
+
 def run(self):
- latex = ' '.join(self.content)
- node = latex_math(self.block_text)
- node['latex'] = latex
- return [node]
+ return math_directive_run(self.content, self.block_text,
+ self.options)
 from docutils.parsers.rst import directives
 directives.register_directive('math', math_directive)
 
@@ -74,25 +86,6 @@
 LaTeXTranslator.visit_latex_math = visit_latex_math_latex
 LaTeXTranslator.depart_latex_math = depart_latex_math_latex
 
-from os.path import isfile
-
-# This calls out to LaTeX to render the expression
-def latex2png(latex, name):
- f = open('math.tex', 'w')
- f.write(r"""\documentclass[12pt]{article}
- \pagestyle{empty}
- \begin{document}""")
- if inline:
- f.write('$%s$' % latex)
- else:
- f.write(r'\[ %s \]' % latex)
- f.write('\end{document}')
- f.close()
- os.system('latex --interaction=nonstopmode math.tex > /dev/null')
- os.system('dvipng -bgTransparent -Ttight --noghostscript -l10 ' +
- '-o %s math.dvi > /dev/null' % name)
-
-
 from matplotlib import rcParams
 from matplotlib.mathtext import MathTextParser
 rcParams['mathtext.fontset'] = 'cm'
@@ -100,21 +93,30 @@
 
 
 # This uses mathtext to render the expression
-def latex2png(latex, filename):
+def latex2png(latex, filename, fontset='cm'):
+ latex = "$%s$" % latex
+ orig_fontset = rcParams['mathtext.fontset']
+ rcParams['mathtext.fontset'] = fontset
 if os.path.exists(filename):
- return
- mathtext_parser.to_png(filename, "$%s$" % latex, dpi=120)
+ depth = mathtext_parser.get_depth(latex, dpi=100)
+ else:
+ print latex.encode("ascii", "backslashreplace")
+ try:
+ depth = mathtext_parser.to_png(filename, latex, dpi=100)
+ except:
+ warnings.warn("Could not render math expression %s" % latex,
+ Warning)
+ depth = 0
+ rcParams['mathtext.fontset'] = orig_fontset
+ return depth
 
-
 # LaTeX to HTML translation stuff:
 def latex2html(node, source):
 inline = isinstance(node.parent, nodes.TextElement)
 latex = node['latex']
- print latex.encode("ascii", "backslashreplace")
 name = 'math-%s' % md5(latex).hexdigest()[-10:]
 dest = '_static/%s.png' % name
- if not isfile(dest):
- latex2png(latex, dest)
+ depth = latex2png(latex, dest, node.get('fontset', rcParams['mathtext.fontset']))
 
 path = '_static'
 count = source.split('/doc/')[-1].count('/')
@@ -122,13 +124,14 @@
 if os.path.exists(path): break
 path = '../'+path
 path = '../'+path #specifically added for matplotlib
- if inline and '_' in latex:
- align = 'align="absmiddle" '
- else:
- align = ''
 if inline:
 cls = ''
 else:
 cls = 'class="center" '
- return '<img src="%s/%s.png" %s%s/>' % (path, name, align, cls)
+ if inline and depth != 0:
+ style = 'style="position: relative; bottom: -%dpx"' % (depth + 1)
+ else:
+ style = ''
 
+ return '<img src="%s/%s.png" %s%s/>' % (path, name, cls, style)
+
Added: trunk/py4science/examples/sphinx_template/sphinxext/only_directives.py
===================================================================
--- trunk/py4science/examples/sphinx_template/sphinxext/only_directives.py	 (rev 0)
+++ trunk/py4science/examples/sphinx_template/sphinxext/only_directives.py	2008年08月12日 18:35:53 UTC (rev 6027)
@@ -0,0 +1,87 @@
+#
+# A pair of directives for inserting content that will only appear in
+# either html or latex.
+#
+
+from docutils.nodes import Body, Element
+from docutils.writers.html4css1 import HTMLTranslator
+from sphinx.latexwriter import LaTeXTranslator
+from docutils.parsers.rst import directives
+
+class html_only(Body, Element):
+ pass
+
+class latex_only(Body, Element):
+ pass
+
+def run(content, node_class, state, content_offset):
+ text = '\n'.join(content)
+ node = node_class(text)
+ state.nested_parse(content, content_offset, node)
+ return [node]
+
+try:
+ from docutils.parsers.rst import Directive
+except ImportError:
+ from docutils.parsers.rst.directives import _directives
+
+ def html_only_directive(name, arguments, options, content, lineno,
+ content_offset, block_text, state, state_machine):
+ return run(content, html_only, state, content_offset)
+
+ def latex_only_directive(name, arguments, options, content, lineno,
+ content_offset, block_text, state, state_machine):
+ return run(content, latex_only, state, content_offset)
+
+ for func in (html_only_directive, latex_only_directive):
+ func.content = 1
+ func.options = {}
+ func.arguments = None
+
+ _directives['htmlonly'] = html_only_directive
+ _directives['latexonly'] = latex_only_directive
+else:
+ class OnlyDirective(Directive):
+ has_content = True
+ required_arguments = 0
+ optional_arguments = 0
+ final_argument_whitespace = True
+ option_spec = {}
+
+ def run(self):
+ self.assert_has_content()
+ return run(self.content, self.node_class,
+ self.state, self.content_offset)
+
+ class HtmlOnlyDirective(OnlyDirective):
+ node_class = html_only
+
+ class LatexOnlyDirective(OnlyDirective):
+ node_class = latex_only
+
+ directives.register_directive('htmlonly', HtmlOnlyDirective)
+ directives.register_directive('latexonly', LatexOnlyDirective)
+
+def setup(app):
+ app.add_node(html_only)
+ app.add_node(latex_only)
+
+ # Add visit/depart methods to HTML-Translator:
+ def visit_perform(self, node):
+ pass
+ def depart_perform(self, node):
+ pass
+ def visit_ignore(self, node):
+ node.children = []
+ def depart_ignore(self, node):
+ node.children = []
+
+ HTMLTranslator.visit_html_only = visit_perform
+ HTMLTranslator.depart_html_only = depart_perform
+ HTMLTranslator.visit_latex_only = visit_ignore
+ HTMLTranslator.depart_latex_only = depart_ignore
+
+ LaTeXTranslator.visit_html_only = visit_ignore
+ LaTeXTranslator.depart_html_only = depart_ignore
+ LaTeXTranslator.visit_latex_only = visit_perform
+ LaTeXTranslator.depart_latex_only = depart_perform
Added: trunk/py4science/examples/sphinx_template/sphinxext/plot_directive.py
===================================================================
--- trunk/py4science/examples/sphinx_template/sphinxext/plot_directive.py	 (rev 0)
+++ trunk/py4science/examples/sphinx_template/sphinxext/plot_directive.py	2008年08月12日 18:35:53 UTC (rev 6027)
@@ -0,0 +1,155 @@
+"""A special directive for including a matplotlib plot.
+
+Given a path to a .py file, it includes the source code inline, then:
+
+- On HTML, will include a .png with a link to a high-res .png.
+
+- On LaTeX, will include a .pdf
+
+This directive supports all of the options of the `image` directive,
+except for `target` (since plot will add its own target).
+
+Additionally, if the :include-source: option is provided, the literal
+source will be included inline, as well as a link to the source.
+"""
+
+import sys, os, glob, shutil
+from docutils.parsers.rst import directives
+
+try:
+ # docutils 0.4
+ from docutils.parsers.rst.directives.images import align
+except ImportError:
+ # docutils 0.5
+ from docutils.parsers.rst.directives.images import Image
+ align = Image.align
+
+
+import matplotlib
+import IPython.Shell
+matplotlib.use('Agg')
+import matplotlib.pyplot as plt
+
+mplshell = IPython.Shell.MatplotlibShell('mpl')
+
+options = {'alt': directives.unchanged,
+ 'height': directives.length_or_unitless,
+ 'width': directives.length_or_percentage_or_unitless,
+ 'scale': directives.nonnegative_int,
+ 'align': align,
+ 'class': directives.class_option,
+ 'include-source': directives.flag }
+
+template = """
+.. htmlonly::
+
+ [`source code <../%(srcdir)s/%(basename)s.py>`__,
+ `png <../%(srcdir)s/%(basename)s.hires.png>`__,
+ `pdf <../%(srcdir)s/%(basename)s.pdf>`__]
+
+ .. image:: ../%(srcdir)s/%(basename)s.png
+%(options)s
+
+.. latexonly::
+ .. image:: ../%(srcdir)s/%(basename)s.pdf
+%(options)s
+
+"""
+
+def makefig(fullpath, outdir):
+ """
+ run a pyplot script and save the low and high res PNGs and a PDF in _static
+ """
+
+ fullpath = str(fullpath) # todo, why is unicode breaking this
+ formats = [('png', 100),
+ ('hires.png', 200),
+ ('pdf', 72),
+ ]
+
+ basedir, fname = os.path.split(fullpath)
+ basename, ext = os.path.splitext(fname)
+ all_exists = True
+
+ if basedir != outdir:
+ shutil.copyfile(fullpath, os.path.join(outdir, fname))
+
+ for format, dpi in formats:
+ outname = os.path.join(outdir, '%s.%s' % (basename, format))
+ if not os.path.exists(outname):
+ all_exists = False
+ break
+
+ if all_exists:
+ print ' already have %s'%fullpath
+ return
+
+ print ' building %s'%fullpath
+ plt.close('all') # we need to clear between runs
+ matplotlib.rcdefaults()
+
+ mplshell.magic_run(fullpath)
+ for format, dpi in formats:
+ outname = os.path.join(outdir, '%s.%s' % (basename, format))
+ if os.path.exists(outname): continue
+ plt.savefig(outname, dpi=dpi)
+
+def run(arguments, options, state_machine, lineno):
+ reference = directives.uri(arguments[0])
+ basedir, fname = os.path.split(reference)
+ basename, ext = os.path.splitext(fname)
+
+ # todo - should we be using the _static dir for the outdir, I am
+ # not sure we want to corrupt that dir with autogenerated files
+ # since it also has permanent files in it which makes it difficult
+ # to clean (save an rm -rf followed by and svn up)
+ srcdir = 'pyplots'
+
+ makefig(os.path.join(srcdir, reference), srcdir)
+
+ # todo: it is not great design to assume the makefile is putting
+ # the figs into the right place, so we may want to do that here instead.
+
+ if options.has_key('include-source'):
+ lines = ['.. literalinclude:: ../pyplots/%(reference)s' % locals()]
+ del options['include-source']
+ else:
+ lines = []
+
+ options = [' :%s: %s' % (key, val) for key, val in
+ options.items()]
+ options = "\n".join(options)
+
+ lines.extend((template % locals()).split('\n'))
+
+ state_machine.insert_input(
+ lines, state_machine.input_lines.source(0))
+ return []
+
+
+try:
+ from docutils.parsers.rst import Directive
+except ImportError:
+ from docutils.parsers.rst.directives import _directives
+
+ def plot_directive(name, arguments, options, content, lineno,
+ content_offset, block_text, state, state_machine):
+ return run(arguments, options, state_machine, lineno)
+ plot_directive.__doc__ = __doc__
+ plot_directive.arguments = (1, 0, 1)
+ plot_directive.options = options
+
+ _directives['plot'] = plot_directive
+else:
+ class plot_directive(Directive):
+ required_arguments = 1
+ optional_arguments = 0
+ final_argument_whitespace = True
+ option_spec = options
+ def run(self):
+ return run(self.arguments, self.options,
+ self.state_machine, self.lineno)
+ plot_directive.__doc__ = __doc__
+
+ directives.register_directive('plot', plot_directive)
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2008年08月12日 18:01:55
Revision: 6026
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6026&view=rev
Author: mdboom
Date: 2008年08月12日 18:01:52 +0000 (2008年8月12日)
Log Message:
-----------
Oops in last commit.
Modified Paths:
--------------
 trunk/matplotlib/doc/conf.py
Modified: trunk/matplotlib/doc/conf.py
===================================================================
--- trunk/matplotlib/doc/conf.py	2008年08月12日 17:58:00 UTC (rev 6025)
+++ trunk/matplotlib/doc/conf.py	2008年08月12日 18:01:52 UTC (rev 6026)
@@ -28,7 +28,7 @@
 # Add any Sphinx extension module names here, as strings. They can be extensions
 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
 extensions = ['mathmpl', 'math_symbol_table', 'sphinx.ext.autodoc',
- 'only_directives', 'plot_directive', 'inheritance_diagram', 'toy']
+ 'only_directives', 'plot_directive', 'inheritance_diagram']
 
 # Add any paths that contain templates here, relative to this directory.
 templates_path = ['_templates']
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2008年08月12日 17:58:03
Revision: 6025
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6025&view=rev
Author: mdboom
Date: 2008年08月12日 17:58:00 +0000 (2008年8月12日)
Log Message:
-----------
Remove old dvipng support in mathmpl.py, since it is now in Sphinx core.
Modified Paths:
--------------
 trunk/matplotlib/doc/sphinxext/mathmpl.py
Modified: trunk/matplotlib/doc/sphinxext/mathmpl.py
===================================================================
--- trunk/matplotlib/doc/sphinxext/mathmpl.py	2008年08月12日 17:57:14 UTC (rev 6024)
+++ trunk/matplotlib/doc/sphinxext/mathmpl.py	2008年08月12日 17:58:00 UTC (rev 6025)
@@ -86,25 +86,6 @@
 LaTeXTranslator.visit_latex_math = visit_latex_math_latex
 LaTeXTranslator.depart_latex_math = depart_latex_math_latex
 
-from os.path import isfile
-
-# This calls out to LaTeX to render the expression
-def latex2png(latex, name):
- f = open('math.tex', 'w')
- f.write(r"""\documentclass[12pt]{article}
- \pagestyle{empty}
- \begin{document}""")
- if inline:
- f.write('$%s$' % latex)
- else:
- f.write(r'\[ %s \]' % latex)
- f.write('\end{document}')
- f.close()
- os.system('latex --interaction=nonstopmode math.tex > /dev/null')
- os.system('dvipng -bgTransparent -Ttight --noghostscript -l10 ' +
- '-o %s math.dvi > /dev/null' % name)
-
-
 from matplotlib import rcParams
 from matplotlib.mathtext import MathTextParser
 rcParams['mathtext.fontset'] = 'cm'
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2008年08月12日 17:57:18
Revision: 6024
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6024&view=rev
Author: mdboom
Date: 2008年08月12日 17:57:14 +0000 (2008年8月12日)
Log Message:
-----------
Rename mathpng to mathmpl
Modified Paths:
--------------
 trunk/matplotlib/doc/conf.py
Added Paths:
-----------
 trunk/matplotlib/doc/sphinxext/mathmpl.py
Removed Paths:
-------------
 trunk/matplotlib/doc/sphinxext/mathpng.py
Modified: trunk/matplotlib/doc/conf.py
===================================================================
--- trunk/matplotlib/doc/conf.py	2008年08月12日 17:54:48 UTC (rev 6023)
+++ trunk/matplotlib/doc/conf.py	2008年08月12日 17:57:14 UTC (rev 6024)
@@ -27,8 +27,8 @@
 
 # Add any Sphinx extension module names here, as strings. They can be extensions
 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
-extensions = ['mathpng', 'math_symbol_table', 'sphinx.ext.autodoc',
- 'only_directives', 'plot_directive', 'inheritance_diagram']
+extensions = ['mathmpl', 'math_symbol_table', 'sphinx.ext.autodoc',
+ 'only_directives', 'plot_directive', 'inheritance_diagram', 'toy']
 
 # Add any paths that contain templates here, relative to this directory.
 templates_path = ['_templates']
Copied: trunk/matplotlib/doc/sphinxext/mathmpl.py (from rev 6021, trunk/matplotlib/doc/sphinxext/mathpng.py)
===================================================================
--- trunk/matplotlib/doc/sphinxext/mathmpl.py	 (rev 0)
+++ trunk/matplotlib/doc/sphinxext/mathmpl.py	2008年08月12日 17:57:14 UTC (rev 6024)
@@ -0,0 +1,156 @@
+import os
+try:
+ from hashlib import md5
+except ImportError:
+ from md5 import md5
+
+from docutils import nodes
+from docutils.parsers.rst import directives
+from docutils.writers.html4css1 import HTMLTranslator
+from sphinx.latexwriter import LaTeXTranslator
+import warnings
+
+# Define LaTeX math node:
+class latex_math(nodes.General, nodes.Element):
+ pass
+
+def fontset_choice(arg):
+ return directives.choice(arg, ['cm', 'stix', 'stixsans'])
+
+options_spec = {'fontset': fontset_choice}
+
+def math_role(role, rawtext, text, lineno, inliner,
+ options={}, content=[]):
+ i = rawtext.find('`')
+ latex = rawtext[i+1:-1]
+ node = latex_math(rawtext)
+ node['latex'] = latex
+ node['fontset'] = options.get('fontset', 'cm')
+ return [node], []
+math_role.options = options_spec
+
+def math_directive_run(content, block_text, options):
+ latex = ''.join(content)
+ node = latex_math(block_text)
+ node['latex'] = latex
+ node['fontset'] = options.get('fontset', 'cm')
+ return [node]
+
+try:
+ from docutils.parsers.rst import Directive
+except ImportError:
+ # Register directive the old way:
+ from docutils.parsers.rst.directives import _directives
+ def math_directive(name, arguments, options, content, lineno,
+ content_offset, block_text, state, state_machine):
+ return math_directive_run(content, block_text, options)
+ math_directive.arguments = None
+ math_directive.options = options_spec
+ math_directive.content = 1
+ _directives['math'] = math_directive
+else:
+ class math_directive(Directive):
+ has_content = True
+ option_spec = options_spec
+
+ def run(self):
+ return math_directive_run(self.content, self.block_text,
+ self.options)
+ from docutils.parsers.rst import directives
+ directives.register_directive('math', math_directive)
+
+def setup(app):
+ app.add_node(latex_math)
+ app.add_role('math', math_role)
+
+ # Add visit/depart methods to HTML-Translator:
+ def visit_latex_math_html(self, node):
+ source = self.document.attributes['source']
+ self.body.append(latex2html(node, source))
+ def depart_latex_math_html(self, node):
+ pass
+ HTMLTranslator.visit_latex_math = visit_latex_math_html
+ HTMLTranslator.depart_latex_math = depart_latex_math_html
+
+ # Add visit/depart methods to LaTeX-Translator:
+ def visit_latex_math_latex(self, node):
+ inline = isinstance(node.parent, nodes.TextElement)
+ if inline:
+ self.body.append('$%s$' % node['latex'])
+ else:
+ self.body.extend(['\\begin{equation}',
+ node['latex'],
+ '\\end{equation}'])
+ def depart_latex_math_latex(self, node):
+ pass
+ LaTeXTranslator.visit_latex_math = visit_latex_math_latex
+ LaTeXTranslator.depart_latex_math = depart_latex_math_latex
+
+from os.path import isfile
+
+# This calls out to LaTeX to render the expression
+def latex2png(latex, name):
+ f = open('math.tex', 'w')
+ f.write(r"""\documentclass[12pt]{article}
+ \pagestyle{empty}
+ \begin{document}""")
+ if inline:
+ f.write('$%s$' % latex)
+ else:
+ f.write(r'\[ %s \]' % latex)
+ f.write('\end{document}')
+ f.close()
+ os.system('latex --interaction=nonstopmode math.tex > /dev/null')
+ os.system('dvipng -bgTransparent -Ttight --noghostscript -l10 ' +
+ '-o %s math.dvi > /dev/null' % name)
+
+
+from matplotlib import rcParams
+from matplotlib.mathtext import MathTextParser
+rcParams['mathtext.fontset'] = 'cm'
+mathtext_parser = MathTextParser("Bitmap")
+
+
+# This uses mathtext to render the expression
+def latex2png(latex, filename, fontset='cm'):
+ latex = "$%s$" % latex
+ orig_fontset = rcParams['mathtext.fontset']
+ rcParams['mathtext.fontset'] = fontset
+ if os.path.exists(filename):
+ depth = mathtext_parser.get_depth(latex, dpi=100)
+ else:
+ print latex.encode("ascii", "backslashreplace")
+ try:
+ depth = mathtext_parser.to_png(filename, latex, dpi=100)
+ except:
+ warnings.warn("Could not render math expression %s" % latex,
+ Warning)
+ depth = 0
+ rcParams['mathtext.fontset'] = orig_fontset
+ return depth
+
+# LaTeX to HTML translation stuff:
+def latex2html(node, source):
+ inline = isinstance(node.parent, nodes.TextElement)
+ latex = node['latex']
+ name = 'math-%s' % md5(latex).hexdigest()[-10:]
+ dest = '_static/%s.png' % name
+ depth = latex2png(latex, dest, node['fontset'])
+
+ path = '_static'
+ count = source.split('/doc/')[-1].count('/')
+ for i in range(count):
+ if os.path.exists(path): break
+ path = '../'+path
+ path = '../'+path #specifically added for matplotlib
+ if inline:
+ cls = ''
+ else:
+ cls = 'class="center" '
+ if inline and depth != 0:
+ style = 'style="position: relative; bottom: -%dpx"' % (depth + 1)
+ else:
+ style = ''
+
+ return '<img src="%s/%s.png" %s%s/>' % (path, name, cls, style)
+
Deleted: trunk/matplotlib/doc/sphinxext/mathpng.py
===================================================================
--- trunk/matplotlib/doc/sphinxext/mathpng.py	2008年08月12日 17:54:48 UTC (rev 6023)
+++ trunk/matplotlib/doc/sphinxext/mathpng.py	2008年08月12日 17:57:14 UTC (rev 6024)
@@ -1,156 +0,0 @@
-import os
-try:
- from hashlib import md5
-except ImportError:
- from md5 import md5
-
-from docutils import nodes
-from docutils.parsers.rst import directives
-from docutils.writers.html4css1 import HTMLTranslator
-from sphinx.latexwriter import LaTeXTranslator
-import warnings
-
-# Define LaTeX math node:
-class latex_math(nodes.General, nodes.Element):
- pass
-
-def fontset_choice(arg):
- return directives.choice(arg, ['cm', 'stix', 'stixsans'])
-
-options_spec = {'fontset': fontset_choice}
-
-def math_role(role, rawtext, text, lineno, inliner,
- options={}, content=[]):
- i = rawtext.find('`')
- latex = rawtext[i+1:-1]
- node = latex_math(rawtext)
- node['latex'] = latex
- node['fontset'] = options.get('fontset', 'cm')
- return [node], []
-math_role.options = options_spec
-
-def math_directive_run(content, block_text, options):
- latex = ''.join(content)
- node = latex_math(block_text)
- node['latex'] = latex
- node['fontset'] = options.get('fontset', 'cm')
- return [node]
-
-try:
- from docutils.parsers.rst import Directive
-except ImportError:
- # Register directive the old way:
- from docutils.parsers.rst.directives import _directives
- def math_directive(name, arguments, options, content, lineno,
- content_offset, block_text, state, state_machine):
- return math_directive_run(content, block_text, options)
- math_directive.arguments = None
- math_directive.options = options_spec
- math_directive.content = 1
- _directives['math'] = math_directive
-else:
- class math_directive(Directive):
- has_content = True
- option_spec = options_spec
-
- def run(self):
- return math_directive_run(self.content, self.block_text,
- self.options)
- from docutils.parsers.rst import directives
- directives.register_directive('math', math_directive)
-
-def setup(app):
- app.add_node(latex_math)
- app.add_role('math', math_role)
-
- # Add visit/depart methods to HTML-Translator:
- def visit_latex_math_html(self, node):
- source = self.document.attributes['source']
- self.body.append(latex2html(node, source))
- def depart_latex_math_html(self, node):
- pass
- HTMLTranslator.visit_latex_math = visit_latex_math_html
- HTMLTranslator.depart_latex_math = depart_latex_math_html
-
- # Add visit/depart methods to LaTeX-Translator:
- def visit_latex_math_latex(self, node):
- inline = isinstance(node.parent, nodes.TextElement)
- if inline:
- self.body.append('$%s$' % node['latex'])
- else:
- self.body.extend(['\\begin{equation}',
- node['latex'],
- '\\end{equation}'])
- def depart_latex_math_latex(self, node):
- pass
- LaTeXTranslator.visit_latex_math = visit_latex_math_latex
- LaTeXTranslator.depart_latex_math = depart_latex_math_latex
-
-from os.path import isfile
-
-# This calls out to LaTeX to render the expression
-def latex2png(latex, name):
- f = open('math.tex', 'w')
- f.write(r"""\documentclass[12pt]{article}
- \pagestyle{empty}
- \begin{document}""")
- if inline:
- f.write('$%s$' % latex)
- else:
- f.write(r'\[ %s \]' % latex)
- f.write('\end{document}')
- f.close()
- os.system('latex --interaction=nonstopmode math.tex > /dev/null')
- os.system('dvipng -bgTransparent -Ttight --noghostscript -l10 ' +
- '-o %s math.dvi > /dev/null' % name)
-
-
-from matplotlib import rcParams
-from matplotlib.mathtext import MathTextParser
-rcParams['mathtext.fontset'] = 'cm'
-mathtext_parser = MathTextParser("Bitmap")
-
-
-# This uses mathtext to render the expression
-def latex2png(latex, filename, fontset='cm'):
- latex = "$%s$" % latex
- orig_fontset = rcParams['mathtext.fontset']
- rcParams['mathtext.fontset'] = fontset
- if os.path.exists(filename):
- depth = mathtext_parser.get_depth(latex, dpi=100)
- else:
- print latex.encode("ascii", "backslashreplace")
- try:
- depth = mathtext_parser.to_png(filename, latex, dpi=100)
- except:
- warnings.warn("Could not render math expression %s" % latex,
- Warning)
- depth = 0
- rcParams['mathtext.fontset'] = orig_fontset
- return depth
-
-# LaTeX to HTML translation stuff:
-def latex2html(node, source):
- inline = isinstance(node.parent, nodes.TextElement)
- latex = node['latex']
- name = 'math-%s' % md5(latex).hexdigest()[-10:]
- dest = '_static/%s.png' % name
- depth = latex2png(latex, dest, node['fontset'])
-
- path = '_static'
- count = source.split('/doc/')[-1].count('/')
- for i in range(count):
- if os.path.exists(path): break
- path = '../'+path
- path = '../'+path #specifically added for matplotlib
- if inline:
- cls = ''
- else:
- cls = 'class="center" '
- if inline and depth != 0:
- style = 'style="position: relative; bottom: -%dpx"' % (depth + 1)
- else:
- style = ''
-
- return '<img src="%s/%s.png" %s%s/>' % (path, name, cls, style)
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6023
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6023&view=rev
Author: mdboom
Date: 2008年08月12日 17:54:48 +0000 (2008年8月12日)
Log Message:
-----------
reorganization
Added Paths:
-----------
 trunk/py4science/examples/sphinx_template/sphinxext/mathmpl.py
Removed Paths:
-------------
 trunk/py4science/examples/sphinx_template/sphinxext/mathml.py
 trunk/py4science/examples/sphinx_template/sphinxext/mathpng.py
Deleted: trunk/py4science/examples/sphinx_template/sphinxext/mathml.py
===================================================================
--- trunk/py4science/examples/sphinx_template/sphinxext/mathml.py	2008年08月12日 16:03:19 UTC (rev 6022)
+++ trunk/py4science/examples/sphinx_template/sphinxext/mathml.py	2008年08月12日 17:54:48 UTC (rev 6023)
@@ -1,552 +0,0 @@
-from docutils import nodes
-from docutils.writers.html4css1 import HTMLTranslator
-from sphinx.latexwriter import LaTeXTranslator
-
-# Define LaTeX math node:
-class latex_math(nodes.General, nodes.Element):
- pass
-
-def math_role(role, rawtext, text, lineno, inliner,
- options={}, content=[]):
- i = rawtext.find('`')
- latex = rawtext[i+1:-1]
- try:
- mathml_tree = parse_latex_math(latex, inline=True)
- except SyntaxError, msg:
- msg = inliner.reporter.error(msg, line=lineno)
- prb = inliner.problematic(rawtext, rawtext, msg)
- return [prb], [msg]
- node = latex_math(rawtext)
- node['latex'] = latex
- node['mathml_tree'] = mathml_tree
- return [node], []
-
-
-try:
- from docutils.parsers.rst import Directive
-except ImportError:
- # Register directive the old way:
- from docutils.parsers.rst.directives import _directives
- def math_directive(name, arguments, options, content, lineno,
- content_offset, block_text, state, state_machine):
- latex = ''.join(content)
- try:
- mathml_tree = parse_latex_math(latex, inline=False)
- except SyntaxError, msg:
- error = state_machine.reporter.error(
- msg, nodes.literal_block(block_text, block_text), line=lineno)
- return [error]
- node = latex_math(block_text)
- node['latex'] = latex
- node['mathml_tree'] = mathml_tree
- return [node]
- math_directive.arguments = None
- math_directive.options = {}
- math_directive.content = 1
- _directives['math'] = math_directive
-else:
- class math_directive(Directive):
- has_content = True
- def run(self):
- latex = ' '.join(self.content)
- try:
- mathml_tree = parse_latex_math(latex, inline=False)
- except SyntaxError, msg:
- error = self.state_machine.reporter.error(
- msg, nodes.literal_block(self.block_text, self.block_text),
- line=self.lineno)
- return [error]
- node = latex_math(self.block_text)
- node['latex'] = latex
- node['mathml_tree'] = mathml_tree
- return [node]
- from docutils.parsers.rst import directives
- directives.register_directive('math', math_directive)
-
-def setup(app):
- app.add_node(latex_math)
- app.add_role('math', math_role)
-
- # Add visit/depart methods to HTML-Translator:
- def visit_latex_math_html(self, node):
- mathml = ''.join(node['mathml_tree'].xml())
- self.body.append(mathml)
- def depart_latex_math_html(self, node):
- pass
- HTMLTranslator.visit_latex_math = visit_latex_math_html
- HTMLTranslator.depart_latex_math = depart_latex_math_html
-
- # Add visit/depart methods to LaTeX-Translator:
- def visit_latex_math_latex(self, node):
- inline = isinstance(node.parent, nodes.TextElement)
- if inline:
- self.body.append('$%s$' % node['latex'])
- else:
- self.body.extend(['\\begin{equation}',
- node['latex'],
- '\\end{equation}'])
- def depart_latex_math_latex(self, node):
- pass
- LaTeXTranslator.visit_latex_math = visit_latex_math_latex
- LaTeXTranslator.depart_latex_math = depart_latex_math_latex
-
-
-# LaTeX to MathML translation stuff:
-class math:
- """Base class for MathML elements."""
-
- nchildren = 1000000
- """Required number of children"""
-
- def __init__(self, children=None, inline=None):
- """math([children]) -> MathML element
-
- children can be one child or a list of children."""
-
- self.children = []
- if children is not None:
- if type(children) is list:
- for child in children:
- self.append(child)
- else:
- # Only one child:
- self.append(children)
-
- if inline is not None:
- self.inline = inline
-
- def __repr__(self):
- if hasattr(self, 'children'):
- return self.__class__.__name__ + '(%s)' % \
- ','.join([repr(child) for child in self.children])
- else:
- return self.__class__.__name__
-
- def full(self):
- """Room for more children?"""
-
- return len(self.children) >= self.nchildren
-
- def append(self, child):
- """append(child) -> element
-
- Appends child and returns self if self is not full or first
- non-full parent."""
-
- assert not self.full()
- self.children.append(child)
- child.parent = self
- node = self
- while node.full():
- node = node.parent
- return node
-
- def delete_child(self):
- """delete_child() -> child
-
- Delete last child and return it."""
-
- child = self.children[-1]
- del self.children[-1]
- return child
-
- def close(self):
- """close() -> parent
-
- Close element and return first non-full element."""
-
- parent = self.parent
- while parent.full():
- parent = parent.parent
- return parent
-
- def xml(self):
- """xml() -> xml-string"""
-
- return self.xml_start() + self.xml_body() + self.xml_end()
-
- def xml_start(self):
- if not hasattr(self, 'inline'):
- return ['<%s>' % self.__class__.__name__]
- xmlns = 'http://www.w3.org/1998/Math/MathML'
- if self.inline:
- return ['<math xmlns="%s">' % xmlns]
- else:
- return ['<math xmlns="%s" mode="display">' % xmlns]
-
- def xml_end(self):
- return ['</%s>' % self.__class__.__name__]
-
- def xml_body(self):
- xml = []
- for child in self.children:
- xml.extend(child.xml())
- return xml
-
-class mrow(math): pass
-class mtable(math): pass
-class mtr(mrow): pass
-class mtd(mrow): pass
-
-class mx(math):
- """Base class for mo, mi, and mn"""
-
- nchildren = 0
- def __init__(self, data):
- self.data = data
-
- def xml_body(self):
- return [self.data]
-
-class mo(mx):
- translation = {'<': '&lt;', '>': '&gt;'}
- def xml_body(self):
- return [self.translation.get(self.data, self.data)]
-
-class mi(mx): pass
-class mn(mx): pass
-
-class msub(math):
- nchildren = 2
-
-class msup(math):
- nchildren = 2
-
-class msqrt(math):
- nchildren = 1
-
-class mroot(math):
- nchildren = 2
-
-class mfrac(math):
- nchildren = 2
-
-class msubsup(math):
- nchildren = 3
- def __init__(self, children=None, reversed=False):
- self.reversed = reversed
- math.__init__(self, children)
-
- def xml(self):
- if self.reversed:
-## self.children[1:3] = self.children[2:0:-1]
- self.children[1:3] = [self.children[2], self.children[1]]
- self.reversed = False
- return math.xml(self)
-
-class mfenced(math):
- translation = {'\\{': '{', '\\langle': u'\u2329',
- '\\}': '}', '\\rangle': u'\u232A',
- '.': ''}
- def __init__(self, par):
- self.openpar = par
- math.__init__(self)
-
- def xml_start(self):
- open = self.translation.get(self.openpar, self.openpar)
- close = self.translation.get(self.closepar, self.closepar)
- return ['<mfenced open="%s" close="%s">' % (open, close)]
-
-class mspace(math):
- nchildren = 0
-
-class mstyle(math):
- def __init__(self, children=None, nchildren=None, **kwargs):
- if nchildren is not None:
- self.nchildren = nchildren
- math.__init__(self, children)
- self.attrs = kwargs
-
- def xml_start(self):
- return ['<mstyle '] + ['%s="%s"' % item
- for item in self.attrs.items()] + ['>']
-
-class mover(math):
- nchildren = 2
- def __init__(self, children=None, reversed=False):
- self.reversed = reversed
- math.__init__(self, children)
-
- def xml(self):
- if self.reversed:
- self.children.reverse()
- self.reversed = False
- return math.xml(self)
-
-class munder(math):
- nchildren = 2
-
-class munderover(math):
- nchildren = 3
- def __init__(self, children=None):
- math.__init__(self, children)
-
-class mtext(math):
- nchildren = 0
- def __init__(self, text):
- self.text = text
-
- def xml_body(self):
- return [self.text]
-
-
-over = {'tilde': '~',
- 'hat': '^',
- 'bar': '_',
- 'vec': u'\u2192'}
-
-Greek = {
- # Upper case greek letters:
- 'Phi': u'\u03a6', 'Xi': u'\u039e', 'Sigma': u'\u03a3', 'Psi': u'\u03a8', 'Delta': u'\u0394', 'Theta': u'\u0398', 'Upsilon': u'\u03d2', 'Pi': u'\u03a0', 'Omega': u'\u03a9', 'Gamma': u'\u0393', 'Lambda': u'\u039b'}
-greek = {
- # Lower case greek letters:
- 'tau': u'\u03c4', 'phi': u'\u03d5', 'xi': u'\u03be', 'iota': u'\u03b9', 'epsilon': u'\u03f5', 'varrho': u'\u03f1', 'varsigma': u'\u03c2', 'beta': u'\u03b2', 'psi': u'\u03c8', 'rho': u'\u03c1', 'delta': u'\u03b4', 'alpha': u'\u03b1', 'zeta': u'\u03b6', 'omega': u'\u03c9', 'varepsilon': u'\u03b5', 'kappa': u'\u03ba', 'vartheta': u'\u03d1', 'chi': u'\u03c7', 'upsilon': u'\u03c5', 'sigma': u'\u03c3', 'varphi': u'\u03c6', 'varpi': u'\u03d6', 'mu': u'\u03bc', 'eta': u'\u03b7', 'theta': u'\u03b8', 'pi': u'\u03c0', 'varkappa': u'\u03f0', 'nu': u'\u03bd', 'gamma': u'\u03b3', 'lambda': u'\u03bb'}
-
-special = {
- # Binary operation symbols:
- 'wedge': u'\u2227', 'diamond': u'\u22c4', 'star': u'\u22c6', 'amalg': u'\u2a3f', 'ast': u'\u2217', 'odot': u'\u2299', 'triangleleft': u'\u25c1', 'bigtriangleup': u'\u25b3', 'ominus': u'\u2296', 'ddagger': u'\u2021', 'wr': u'\u2240', 'otimes': u'\u2297', 'sqcup': u'\u2294', 'oplus': u'\u2295', 'bigcirc': u'\u25cb', 'oslash': u'\u2298', 'sqcap': u'\u2293', 'bullet': u'\u2219', 'cup': u'\u222a', 'cdot': u'\u22c5', 'cap': u'\u2229', 'bigtriangledown': u'\u25bd', 'times': u'\xd7', 'setminus': u'\u2216', 'circ': u'\u2218', 'vee': u'\u2228', 'uplus': u'\u228e', 'mp': u'\u2213', 'dagger': u'\u2020', 'triangleright': u'\u25b7', 'div': u'\xf7', 'pm': u'\xb1',
- # Relation symbols:
- 'subset': u'\u2282', 'propto': u'\u221d', 'geq': u'\u2265', 'ge': u'\u2265', 'sqsubset': u'\u228f', 'Join': u'\u2a1d', 'frown': u'\u2322', 'models': u'\u22a7', 'supset': u'\u2283', 'in': u'\u2208', 'doteq': u'\u2250', 'dashv': u'\u22a3', 'gg': u'\u226b', 'leq': u'\u2264', 'succ': u'\u227b', 'vdash': u'\u22a2', 'cong': u'\u2245', 'simeq': u'\u2243', 'subseteq': u'\u2286', 'parallel': u'\u2225', 'equiv': u'\u2261', 'ni': u'\u220b', 'le': u'\u2264', 'approx': u'\u2248', 'precsim': u'\u227e', 'sqsupset': u'\u2290', 'll': u'\u226a', 'sqsupseteq': u'\u2292', 'mid': u'\u2223', 'prec': u'\u227a', 'succsim': u'\u227f', 'bowtie': u'\u22c8', 'perp': u'\u27c2', 'sqsubseteq': u'\u2291', 'asymp': u'\u224d', 'smile': u'\u2323', 'supseteq': u'\u2287', 'sim': u'\u223c', 'neq': u'\u2260',
- # Arrow symbols:
- 'searrow': u'\u2198', 'updownarrow': u'\u2195', 'Uparrow': u'\u21d1', 'longleftrightarrow': u'\u27f7', 'Leftarrow': u'\u21d0', 'longmapsto': u'\u27fc', 'Longleftarrow': u'\u27f8', 'nearrow': u'\u2197', 'hookleftarrow': u'\u21a9', 'downarrow': u'\u2193', 'Leftrightarrow': u'\u21d4', 'longrightarrow': u'\u27f6', 'rightharpoondown': u'\u21c1', 'longleftarrow': u'\u27f5', 'rightarrow': u'\u2192', 'Updownarrow': u'\u21d5', 'rightharpoonup': u'\u21c0', 'Longleftrightarrow': u'\u27fa', 'leftarrow': u'\u2190', 'mapsto': u'\u21a6', 'nwarrow': u'\u2196', 'uparrow': u'\u2191', 'leftharpoonup': u'\u21bc', 'leftharpoondown': u'\u21bd', 'Downarrow': u'\u21d3', 'leftrightarrow': u'\u2194', 'Longrightarrow': u'\u27f9', 'swarrow': u'\u2199', 'hookrightarrow': u'\u21aa', 'Rightarrow': u'\u21d2',
- # Miscellaneous symbols:
- 'infty': u'\u221e', 'surd': u'\u221a', 'partial': u'\u2202', 'ddots': u'\u22f1', 'exists': u'\u2203', 'flat': u'\u266d', 'diamondsuit': u'\u2662', 'wp': u'\u2118', 'spadesuit': u'\u2660', 'Re': u'\u211c', 'vdots': u'\u22ee', 'aleph': u'\u2135', 'clubsuit': u'\u2663', 'sharp': u'\u266f', 'angle': u'\u2220', 'prime': u'\u2032', 'natural': u'\u266e', 'ell': u'\u2113', 'neg': u'\xac', 'top': u'\u22a4', 'nabla': u'\u2207', 'bot': u'\u22a5', 'heartsuit': u'\u2661', 'cdots': u'\u22ef', 'Im': u'\u2111', 'forall': u'\u2200', 'imath': u'\u0131', 'hbar': u'\u210f', 'emptyset': u'\u2205',
- # Variable-sized symbols:
- 'bigotimes': u'\u2a02', 'coprod': u'\u2210', 'int': u'\u222b', 'sum': u'\u2211', 'bigodot': u'\u2a00', 'bigcup': u'\u22c3', 'biguplus': u'\u2a04', 'bigcap': u'\u22c2', 'bigoplus': u'\u2a01', 'oint': u'\u222e', 'bigvee': u'\u22c1', 'bigwedge': u'\u22c0', 'prod': u'\u220f',
- # Braces:
- 'langle': u'\u2329', 'rangle': u'\u232A'}
-
-sumintprod = ''.join([special[symbol] for symbol in
- ['sum', 'int', 'oint', 'prod']])
-
-functions = ['arccos', 'arcsin', 'arctan', 'arg', 'cos', 'cosh',
- 'cot', 'coth', 'csc', 'deg', 'det', 'dim',
- 'exp', 'gcd', 'hom', 'inf', 'ker', 'lg',
- 'lim', 'liminf', 'limsup', 'ln', 'log', 'max',
- 'min', 'Pr', 'sec', 'sin', 'sinh', 'sup',
- 'tan', 'tanh',
- 'injlim', 'varinjlim', 'varlimsup',
- 'projlim', 'varliminf', 'varprojlim']
-
-
-def parse_latex_math(string, inline=True):
- """parse_latex_math(string [,inline]) -> MathML-tree
-
- Returns a MathML-tree parsed from string. inline=True is for
- inline math and inline=False is for displayed math.
-
- tree is the whole tree and node is the current element."""
-
- # Normalize white-space:
- string = ' '.join(string.split())
-
- if inline:
- node = mrow()
- tree = math(node, inline=True)
- else:
- node = mtd()
- tree = math(mtable(mtr(node)), inline=False)
-
- while len(string) > 0:
- n = len(string)
- c = string[0]
- skip = 1 # number of characters consumed
- if n > 1:
- c2 = string[1]
- else:
- c2 = ''
-## print n, string, c, c2, node.__class__.__name__
- if c == ' ':
- pass
- elif c == '\\':
- if c2 in '{}':
- node = node.append(mo(c2))
- skip = 2
- elif c2 == ' ':
- node = node.append(mspace())
- skip = 2
- elif c2.isalpha():
- # We have a LaTeX-name:
- i = 2
- while i < n and string[i].isalpha():
- i += 1
- name = string[1:i]
- node, skip = handle_keyword(name, node, string[i:])
- skip += i
- elif c2 == '\\':
- # End of a row:
- entry = mtd()
- row = mtr(entry)
- node.close().close().append(row)
- node = entry
- skip = 2
- else:
- raise SyntaxError('Syntax error: "%s%s"' % (c, c2))
- elif c.isalpha():
- node = node.append(mi(c))
- elif c.isdigit():
- node = node.append(mn(c))
- elif c in "+-/()[]|=<>,.!'":
- node = node.append(mo(c))
- elif c == '_':
- child = node.delete_child()
- if isinstance(child, msup):
- sub = msubsup(child.children, reversed=True)
- elif isinstance(child, mo) and child.data in sumintprod:
- sub = munder(child)
- else:
- sub = msub(child)
- node.append(sub)
- node = sub
- elif c == '^':
- child = node.delete_child()
- if isinstance(child, msub):
- sup = msubsup(child.children)
- elif isinstance(child, mo) and child.data in sumintprod:
- sup = mover(child)
- elif (isinstance(child, munder) and
- child.children[0].data in sumintprod):
- sup = munderover(child.children)
- else:
- sup = msup(child)
- node.append(sup)
- node = sup
- elif c == '{':
- row = mrow()
- node.append(row)
- node = row
- elif c == '}':
- node = node.close()
- elif c == '&':
- entry = mtd()
- node.close().append(entry)
- node = entry
- else:
- raise SyntaxError('Illegal character: "%s"' % c)
- string = string[skip:]
- return tree
-
-
-mathbb = {'A': u'\U0001D538',
- 'B': u'\U0001D539',
- 'C': u'\u2102',
- 'D': u'\U0001D53B',
- 'E': u'\U0001D53C',
- 'F': u'\U0001D53D',
- 'G': u'\U0001D53E',
- 'H': u'\u210D',
- 'I': u'\U0001D540',
- 'J': u'\U0001D541',
- 'K': u'\U0001D542',
- 'L': u'\U0001D543',
- 'M': u'\U0001D544',
- 'N': u'\u2115',
- 'O': u'\U0001D546',
- 'P': u'\u2119',
- 'Q': u'\u211A',
- 'R': u'\u211D',
- 'S': u'\U0001D54A',
- 'T': u'\U0001D54B',
- 'U': u'\U0001D54C',
- 'V': u'\U0001D54D',
- 'W': u'\U0001D54E',
- 'X': u'\U0001D54F',
- 'Y': u'\U0001D550',
- 'Z': u'\u2124'}
-
-negatables = {'=': u'\u2260',
- '\in': u'\u2209',
- '\equiv': u'\u2262'}
-
-
-def handle_keyword(name, node, string):
- skip = 0
- if len(string) > 0 and string[0] == ' ':
- string = string[1:]
- skip = 1
- if name == 'begin':
- if not string.startswith('{matrix}'):
- raise SyntaxError('Expected "\begin{matrix}"!')
- skip += 8
- entry = mtd()
- table = mtable(mtr(entry))
- node.append(table)
- node = entry
- elif name == 'end':
- if not string.startswith('{matrix}'):
- raise SyntaxError('Expected "\end{matrix}"!')
- skip += 8
- node = node.close().close().close()
- elif name == 'text':
- if string[0] != '{':
- raise SyntaxError('Expected "\text{...}"!')
- i = string.find('}')
- if i == -1:
- raise SyntaxError('Expected "\text{...}"!')
- node = node.append(mtext(string[1:i]))
- skip += i + 1
- elif name == 'sqrt':
- sqrt = msqrt()
- node.append(sqrt)
- node = sqrt
- elif name == 'frac':
- frac = mfrac()
- node.append(frac)
- node = frac
- elif name == 'left':
- for par in ['(', '[', '|', '\\{', '\\langle', '.']:
- if string.startswith(par):
- break
- else:
- raise SyntaxError('Missing left-brace!')
- fenced = mfenced(par)
- node.append(fenced)
- row = mrow()
- fenced.append(row)
- node = row
- skip += len(par)
- elif name == 'right':
- for par in [')', ']', '|', '\\}', '\\rangle', '.']:
- if string.startswith(par):
- break
- else:
- raise SyntaxError('Missing right-brace!')
- node = node.close()
- node.closepar = par
- node = node.close()
- skip += len(par)
- elif name == 'not':
- for operator in negatables:
- if string.startswith(operator):
- break
- else:
- raise SyntaxError('Expected something to negate: "\\not ..."!')
- node = node.append(mo(negatables[operator]))
- skip += len(operator)
- elif name == 'mathbf':
- style = mstyle(nchildren=1, fontweight='bold')
- node.append(style)
- node = style
- elif name == 'mathbb':
- if string[0] != '{' or not string[1].isupper() or string[2] != '}':
- raise SyntaxError('Expected something like "\mathbb{A}"!')
- node = node.append(mi(mathbb[string[1]]))
- skip += 3
- elif name in greek:
- node = node.append(mi(greek[name]))
- elif name in Greek:
- node = node.append(mo(Greek[name]))
- elif name in special:
- node = node.append(mo(special[name]))
- elif name in functions:
- node = node.append(mo(name))
- else:
- chr = over.get(name)
- if chr is not None:
- ovr = mover(mo(chr), reversed=True)
- node.append(ovr)
- node = ovr
- else:
- raise SyntaxError('Unknown LaTeX command: ' + name)
-
- return node, skip
Copied: trunk/py4science/examples/sphinx_template/sphinxext/mathmpl.py (from rev 6022, trunk/py4science/examples/sphinx_template/sphinxext/mathpng.py)
===================================================================
--- trunk/py4science/examples/sphinx_template/sphinxext/mathmpl.py	 (rev 0)
+++ trunk/py4science/examples/sphinx_template/sphinxext/mathmpl.py	2008年08月12日 17:54:48 UTC (rev 6023)
@@ -0,0 +1,134 @@
+import os
+try:
+ from hashlib import md5
+except ImportError:
+ from md5 import md5
+
+from docutils import nodes
+from docutils.writers.html4css1 import HTMLTranslator
+from sphinx.latexwriter import LaTeXTranslator
+
+# Define LaTeX math node:
+class latex_math(nodes.General, nodes.Element):
+ pass
+
+def math_role(role, rawtext, text, lineno, inliner,
+ options={}, content=[]):
+ i = rawtext.find('`')
+ latex = rawtext[i+1:-1]
+ node = latex_math(rawtext)
+ node['latex'] = latex
+ return [node], []
+
+
+try:
+ from docutils.parsers.rst import Directive
+except ImportError:
+ # Register directive the old way:
+ from docutils.parsers.rst.directives import _directives
+ def math_directive(name, arguments, options, content, lineno,
+ content_offset, block_text, state, state_machine):
+ latex = ''.join(content)
+ node = latex_math(block_text)
+ node['latex'] = latex
+ return [node]
+ math_directive.arguments = None
+ math_directive.options = {}
+ math_directive.content = 1
+ _directives['math'] = math_directive
+else:
+ class math_directive(Directive):
+ has_content = True
+ def run(self):
+ latex = ' '.join(self.content)
+ node = latex_math(self.block_text)
+ node['latex'] = latex
+ return [node]
+ from docutils.parsers.rst import directives
+ directives.register_directive('math', math_directive)
+
+def setup(app):
+ app.add_node(latex_math)
+ app.add_role('math', math_role)
+
+ # Add visit/depart methods to HTML-Translator:
+ def visit_latex_math_html(self, node):
+ source = self.document.attributes['source']
+ self.body.append(latex2html(node, source))
+ def depart_latex_math_html(self, node):
+ pass
+ HTMLTranslator.visit_latex_math = visit_latex_math_html
+ HTMLTranslator.depart_latex_math = depart_latex_math_html
+
+ # Add visit/depart methods to LaTeX-Translator:
+ def visit_latex_math_latex(self, node):
+ inline = isinstance(node.parent, nodes.TextElement)
+ if inline:
+ self.body.append('$%s$' % node['latex'])
+ else:
+ self.body.extend(['\\begin{equation}',
+ node['latex'],
+ '\\end{equation}'])
+ def depart_latex_math_latex(self, node):
+ pass
+ LaTeXTranslator.visit_latex_math = visit_latex_math_latex
+ LaTeXTranslator.depart_latex_math = depart_latex_math_latex
+
+from os.path import isfile
+
+# This calls out to LaTeX to render the expression
+def latex2png(latex, name):
+ f = open('math.tex', 'w')
+ f.write(r"""\documentclass[12pt]{article}
+ \pagestyle{empty}
+ \begin{document}""")
+ if inline:
+ f.write('$%s$' % latex)
+ else:
+ f.write(r'\[ %s \]' % latex)
+ f.write('\end{document}')
+ f.close()
+ os.system('latex --interaction=nonstopmode math.tex > /dev/null')
+ os.system('dvipng -bgTransparent -Ttight --noghostscript -l10 ' +
+ '-o %s math.dvi > /dev/null' % name)
+
+
+from matplotlib import rcParams
+from matplotlib.mathtext import MathTextParser
+rcParams['mathtext.fontset'] = 'cm'
+mathtext_parser = MathTextParser("Bitmap")
+
+
+# This uses mathtext to render the expression
+def latex2png(latex, filename):
+ if os.path.exists(filename):
+ return
+ mathtext_parser.to_png(filename, "$%s$" % latex, dpi=120)
+
+
+# LaTeX to HTML translation stuff:
+def latex2html(node, source):
+ inline = isinstance(node.parent, nodes.TextElement)
+ latex = node['latex']
+ print latex.encode("ascii", "backslashreplace")
+ name = 'math-%s' % md5(latex).hexdigest()[-10:]
+ dest = '_static/%s.png' % name
+ if not isfile(dest):
+ latex2png(latex, dest)
+
+ path = '_static'
+ count = source.split('/doc/')[-1].count('/')
+ for i in range(count):
+ if os.path.exists(path): break
+ path = '../'+path
+ path = '../'+path #specifically added for matplotlib
+ if inline and '_' in latex:
+ align = 'align="absmiddle" '
+ else:
+ align = ''
+ if inline:
+ cls = ''
+ else:
+ cls = 'class="center" '
+ return '<img src="%s/%s.png" %s%s/>' % (path, name, align, cls)
+
Deleted: trunk/py4science/examples/sphinx_template/sphinxext/mathpng.py
===================================================================
--- trunk/py4science/examples/sphinx_template/sphinxext/mathpng.py	2008年08月12日 16:03:19 UTC (rev 6022)
+++ trunk/py4science/examples/sphinx_template/sphinxext/mathpng.py	2008年08月12日 17:54:48 UTC (rev 6023)
@@ -1,134 +0,0 @@
-import os
-try:
- from hashlib import md5
-except ImportError:
- from md5 import md5
-
-from docutils import nodes
-from docutils.writers.html4css1 import HTMLTranslator
-from sphinx.latexwriter import LaTeXTranslator
-
-# Define LaTeX math node:
-class latex_math(nodes.General, nodes.Element):
- pass
-
-def math_role(role, rawtext, text, lineno, inliner,
- options={}, content=[]):
- i = rawtext.find('`')
- latex = rawtext[i+1:-1]
- node = latex_math(rawtext)
- node['latex'] = latex
- return [node], []
-
-
-try:
- from docutils.parsers.rst import Directive
-except ImportError:
- # Register directive the old way:
- from docutils.parsers.rst.directives import _directives
- def math_directive(name, arguments, options, content, lineno,
- content_offset, block_text, state, state_machine):
- latex = ''.join(content)
- node = latex_math(block_text)
- node['latex'] = latex
- return [node]
- math_directive.arguments = None
- math_directive.options = {}
- math_directive.content = 1
- _directives['math'] = math_directive
-else:
- class math_directive(Directive):
- has_content = True
- def run(self):
- latex = ' '.join(self.content)
- node = latex_math(self.block_text)
- node['latex'] = latex
- return [node]
- from docutils.parsers.rst import directives
- directives.register_directive('math', math_directive)
-
-def setup(app):
- app.add_node(latex_math)
- app.add_role('math', math_role)
-
- # Add visit/depart methods to HTML-Translator:
- def visit_latex_math_html(self, node):
- source = self.document.attributes['source']
- self.body.append(latex2html(node, source))
- def depart_latex_math_html(self, node):
- pass
- HTMLTranslator.visit_latex_math = visit_latex_math_html
- HTMLTranslator.depart_latex_math = depart_latex_math_html
-
- # Add visit/depart methods to LaTeX-Translator:
- def visit_latex_math_latex(self, node):
- inline = isinstance(node.parent, nodes.TextElement)
- if inline:
- self.body.append('$%s$' % node['latex'])
- else:
- self.body.extend(['\\begin{equation}',
- node['latex'],
- '\\end{equation}'])
- def depart_latex_math_latex(self, node):
- pass
- LaTeXTranslator.visit_latex_math = visit_latex_math_latex
- LaTeXTranslator.depart_latex_math = depart_latex_math_latex
-
-from os.path import isfile
-
-# This calls out to LaTeX to render the expression
-def latex2png(latex, name):
- f = open('math.tex', 'w')
- f.write(r"""\documentclass[12pt]{article}
- \pagestyle{empty}
- \begin{document}""")
- if inline:
- f.write('$%s$' % latex)
- else:
- f.write(r'\[ %s \]' % latex)
- f.write('\end{document}')
- f.close()
- os.system('latex --interaction=nonstopmode math.tex > /dev/null')
- os.system('dvipng -bgTransparent -Ttight --noghostscript -l10 ' +
- '-o %s math.dvi > /dev/null' % name)
-
-
-from matplotlib import rcParams
-from matplotlib.mathtext import MathTextParser
-rcParams['mathtext.fontset'] = 'cm'
-mathtext_parser = MathTextParser("Bitmap")
-
-
-# This uses mathtext to render the expression
-def latex2png(latex, filename):
- if os.path.exists(filename):
- return
- mathtext_parser.to_png(filename, "$%s$" % latex, dpi=120)
-
-
-# LaTeX to HTML translation stuff:
-def latex2html(node, source):
- inline = isinstance(node.parent, nodes.TextElement)
- latex = node['latex']
- print latex.encode("ascii", "backslashreplace")
- name = 'math-%s' % md5(latex).hexdigest()[-10:]
- dest = '_static/%s.png' % name
- if not isfile(dest):
- latex2png(latex, dest)
-
- path = '_static'
- count = source.split('/doc/')[-1].count('/')
- for i in range(count):
- if os.path.exists(path): break
- path = '../'+path
- path = '../'+path #specifically added for matplotlib
- if inline and '_' in latex:
- align = 'align="absmiddle" '
- else:
- align = ''
- if inline:
- cls = ''
- else:
- cls = 'class="center" '
- return '<img src="%s/%s.png" %s%s/>' % (path, name, align, cls)
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <jd...@us...> - 2008年08月12日 16:03:22
Revision: 6022
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6022&view=rev
Author: jdh2358
Date: 2008年08月12日 16:03:19 +0000 (2008年8月12日)
Log Message:
-----------
some legend fixes
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/axes.py
 trunk/matplotlib/lib/matplotlib/legend.py
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py	2008年08月11日 15:34:30 UTC (rev 6021)
+++ trunk/matplotlib/lib/matplotlib/axes.py	2008年08月12日 16:03:19 UTC (rev 6022)
@@ -6364,7 +6364,7 @@
 for p in patch:
 p.update(kwargs)
 p.set_label(label)
- label = '_nolegend'
+ label = '_nolegend_'
 
 
 if len(n)==1:
Modified: trunk/matplotlib/lib/matplotlib/legend.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/legend.py	2008年08月11日 15:34:30 UTC (rev 6021)
+++ trunk/matplotlib/lib/matplotlib/legend.py	2008年08月12日 16:03:19 UTC (rev 6022)
@@ -520,7 +520,8 @@
 if isinstance(handle, Line2D):
 ydata = y*np.ones(handle.get_xdata().shape, float)
 handle.set_ydata(ydata+h/2.)
- handle._legmarker.set_ydata(ydata+h/2.)
+ if hasattr(handle, '_legmarker'):
+ handle._legmarker.set_ydata(ydata+h/2.)
 elif isinstance(handle, Rectangle):
 handle.set_y(y+1/4*h)
 handle.set_height(h/2)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <js...@us...> - 2008年08月11日 15:34:37
Revision: 6021
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6021&view=rev
Author: jswhit
Date: 2008年08月11日 15:34:30 +0000 (2008年8月11日)
Log Message:
-----------
up version number
Modified Paths:
--------------
 trunk/toolkits/basemap/src/_geoslib.c
 trunk/toolkits/basemap/src/_geoslib.pyx
Modified: trunk/toolkits/basemap/src/_geoslib.c
===================================================================
--- trunk/toolkits/basemap/src/_geoslib.c	2008年08月11日 15:07:49 UTC (rev 6020)
+++ trunk/toolkits/basemap/src/_geoslib.c	2008年08月11日 15:34:30 UTC (rev 6021)
@@ -1,4 +1,4 @@
-/* Generated by Cython 0.9.8 on Mon Aug 11 09:07:15 2008 */
+/* Generated by Cython 0.9.8 on Mon Aug 11 09:34:06 2008 */
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"
@@ -297,7 +297,7 @@
 
 /* Implementation of _geoslib */
 
-static char __pyx_k_1[] = "0.1";
+static char __pyx_k_1[] = "0.2";
 
 static char __pyx_k_is_valid[] = "is_valid";
 static char __pyx_k_geom_type[] = "geom_type";
@@ -3480,7 +3480,7 @@
 * import sys
 * import numpy # <<<<<<<<<<<<<<
 * 
- * __version__ = "0.1"
+ * __version__ = "0.2"
 */
 __pyx_1 = __Pyx_Import(__pyx_kp_numpy, 0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1;}
 if (PyObject_SetAttr(__pyx_m, __pyx_kp_numpy, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1;}
@@ -3489,7 +3489,7 @@
 /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":4
 * import numpy
 * 
- * __version__ = "0.1" # <<<<<<<<<<<<<<
+ * __version__ = "0.2" # <<<<<<<<<<<<<<
 * 
 * # need some python C API functions for strings.
 */
Modified: trunk/toolkits/basemap/src/_geoslib.pyx
===================================================================
--- trunk/toolkits/basemap/src/_geoslib.pyx	2008年08月11日 15:07:49 UTC (rev 6020)
+++ trunk/toolkits/basemap/src/_geoslib.pyx	2008年08月11日 15:34:30 UTC (rev 6021)
@@ -1,7 +1,7 @@
 import sys
 import numpy
 
-__version__ = "0.1"
+__version__ = "0.2"
 
 # need some python C API functions for strings.
 cdef extern from "Python.h":
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <js...@us...> - 2008年08月11日 15:07:55
Revision: 6020
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6020&view=rev
Author: jswhit
Date: 2008年08月11日 15:07:49 +0000 (2008年8月11日)
Log Message:
-----------
previous commit broke geos 2 compatibility
Modified Paths:
--------------
 trunk/toolkits/basemap/src/_geoslib.c
 trunk/toolkits/basemap/src/_geoslib.pyx
Modified: trunk/toolkits/basemap/src/_geoslib.c
===================================================================
--- trunk/toolkits/basemap/src/_geoslib.c	2008年08月11日 13:01:47 UTC (rev 6019)
+++ trunk/toolkits/basemap/src/_geoslib.c	2008年08月11日 15:07:49 UTC (rev 6020)
@@ -1,4 +1,4 @@
-/* Generated by Cython 0.9.8 on Sat Aug 9 10:17:12 2008 */
+/* Generated by Cython 0.9.8 on Mon Aug 11 09:07:15 2008 */
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"
@@ -228,7 +228,7 @@
 
 /* Type declarations */
 
-/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":131
+/* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":131
 * initGEOS(notice_h, error_h)
 * 
 * cdef class BaseGeometry: # <<<<<<<<<<<<<<
@@ -243,7 +243,7 @@
 PyObject *boundary;
 };
 
-/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":249
+/* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":250
 * return (self.__class__,(self.boundary,))
 * 
 * cdef class Polygon(BaseGeometry): # <<<<<<<<<<<<<<
@@ -255,7 +255,7 @@
 struct __pyx_obj_8_geoslib_BaseGeometry __pyx_base;
 };
 
-/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":305
+/* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":306
 * return area
 * 
 * cdef class LineString(BaseGeometry): # <<<<<<<<<<<<<<
@@ -267,7 +267,7 @@
 struct __pyx_obj_8_geoslib_BaseGeometry __pyx_base;
 };
 
-/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":337
+/* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":338
 * self.boundary = b
 * 
 * cdef class Point(BaseGeometry): # <<<<<<<<<<<<<<
@@ -335,7 +335,7 @@
 
 static PyObject *__pyx_kp_1;
 
-/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":102
+/* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":102
 * int GEOSCoordSeq_getSize(GEOSCoordSeq *s, unsigned int *size)
 * 
 * cdef void notice_h(char *fmt, char*msg): # <<<<<<<<<<<<<<
@@ -364,7 +364,7 @@
 __pyx_v_message = Py_None; Py_INCREF(Py_None);
 __pyx_v_warn_msg = Py_None; Py_INCREF(Py_None);
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":103
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":103
 * 
 * cdef void notice_h(char *fmt, char*msg):
 * format = PyString_FromString(fmt) # <<<<<<<<<<<<<<
@@ -376,7 +376,7 @@
 __pyx_v_format = __pyx_1;
 __pyx_1 = 0;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":104
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":104
 * cdef void notice_h(char *fmt, char*msg):
 * format = PyString_FromString(fmt)
 * message = PyString_FromString(msg) # <<<<<<<<<<<<<<
@@ -388,7 +388,7 @@
 __pyx_v_message = __pyx_1;
 __pyx_1 = 0;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":105
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":105
 * format = PyString_FromString(fmt)
 * message = PyString_FromString(msg)
 * try: # <<<<<<<<<<<<<<
@@ -397,7 +397,7 @@
 */
 /*try:*/ {
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":106
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":106
 * message = PyString_FromString(msg)
 * try:
 * warn_msg = format % message # <<<<<<<<<<<<<<
@@ -413,7 +413,7 @@
 __pyx_L2:;
 Py_XDECREF(__pyx_1); __pyx_1 = 0;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":107
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":107
 * try:
 * warn_msg = format % message
 * except: # <<<<<<<<<<<<<<
@@ -424,7 +424,7 @@
 __Pyx_AddTraceback("_geoslib.notice_h");
 if (__Pyx_GetException(&__pyx_1, &__pyx_2, &__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1;}
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":108
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":108
 * warn_msg = format % message
 * except:
 * warn_msg = format # <<<<<<<<<<<<<<
@@ -441,7 +441,7 @@
 }
 __pyx_L3:;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":109
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":109
 * except:
 * warn_msg = format
 * sys.stdout.write('GEOS_NOTICE: %s\n' % warn_msg) # <<<<<<<<<<<<<<
@@ -474,7 +474,7 @@
 Py_DECREF(__pyx_v_warn_msg);
 }
 
-/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":111
+/* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":111
 * sys.stdout.write('GEOS_NOTICE: %s\n' % warn_msg)
 * 
 * cdef void error_h(char *fmt, char*msg): # <<<<<<<<<<<<<<
@@ -501,7 +501,7 @@
 __pyx_v_message = Py_None; Py_INCREF(Py_None);
 __pyx_v_warn_msg = Py_None; Py_INCREF(Py_None);
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":112
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":112
 * 
 * cdef void error_h(char *fmt, char*msg):
 * format = PyString_FromString(fmt) # <<<<<<<<<<<<<<
@@ -513,7 +513,7 @@
 __pyx_v_format = __pyx_1;
 __pyx_1 = 0;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":113
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":113
 * cdef void error_h(char *fmt, char*msg):
 * format = PyString_FromString(fmt)
 * message = PyString_FromString(msg) # <<<<<<<<<<<<<<
@@ -525,7 +525,7 @@
 __pyx_v_message = __pyx_1;
 __pyx_1 = 0;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":114
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":114
 * format = PyString_FromString(fmt)
 * message = PyString_FromString(msg)
 * try: # <<<<<<<<<<<<<<
@@ -534,7 +534,7 @@
 */
 /*try:*/ {
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":115
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":115
 * message = PyString_FromString(msg)
 * try:
 * warn_msg = format % message # <<<<<<<<<<<<<<
@@ -550,7 +550,7 @@
 __pyx_L2:;
 Py_XDECREF(__pyx_1); __pyx_1 = 0;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":116
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":116
 * try:
 * warn_msg = format % message
 * except: # <<<<<<<<<<<<<<
@@ -561,7 +561,7 @@
 __Pyx_AddTraceback("_geoslib.error_h");
 if (__Pyx_GetException(&__pyx_1, &__pyx_2, &__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1;}
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":117
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":117
 * warn_msg = format % message
 * except:
 * warn_msg = format # <<<<<<<<<<<<<<
@@ -578,7 +578,7 @@
 }
 __pyx_L3:;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":118
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":118
 * except:
 * warn_msg = format
 * sys.stderr.write('GEOS_ERROR: %s\n' % warn_msg) # <<<<<<<<<<<<<<
@@ -611,7 +611,7 @@
 Py_DECREF(__pyx_v_warn_msg);
 }
 
-/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":121
+/* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":121
 * 
 * # check library version
 * cdef geos_version(): # <<<<<<<<<<<<<<
@@ -623,7 +623,7 @@
 PyObject *__pyx_r;
 PyObject *__pyx_1 = 0;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":122
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":122
 * # check library version
 * cdef geos_version():
 * return PyString_FromString(GEOSversion()) # <<<<<<<<<<<<<<
@@ -645,7 +645,7 @@
 return __pyx_r;
 }
 
-/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":136
+/* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":136
 * cdef public object boundary
 * 
 * def is_valid(self): # <<<<<<<<<<<<<<
@@ -659,7 +659,7 @@
 PyObject *__pyx_r;
 char __pyx_1;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":138
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":138
 * def is_valid(self):
 * cdef char valid
 * valid = GEOSisValid(self._geom) # <<<<<<<<<<<<<<
@@ -668,7 +668,7 @@
 */
 __pyx_v_valid = GEOSisValid(((struct __pyx_obj_8_geoslib_BaseGeometry *)__pyx_v_self)->_geom);
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":139
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":139
 * cdef char valid
 * valid = GEOSisValid(self._geom)
 * if valid: # <<<<<<<<<<<<<<
@@ -678,7 +678,7 @@
 __pyx_1 = __pyx_v_valid;
 if (__pyx_1) {
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":140
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":140
 * valid = GEOSisValid(self._geom)
 * if valid:
 * return True # <<<<<<<<<<<<<<
@@ -692,7 +692,7 @@
 }
 /*else*/ {
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":142
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":142
 * return True
 * else:
 * return False # <<<<<<<<<<<<<<
@@ -710,7 +710,7 @@
 return __pyx_r;
 }
 
-/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":144
+/* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":144
 * return False
 * 
 * def geom_type(self): # <<<<<<<<<<<<<<
@@ -723,7 +723,7 @@
 PyObject *__pyx_r;
 PyObject *__pyx_1 = 0;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":145
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":145
 * 
 * def geom_type(self):
 * return PyString_FromString(GEOSGeomType(self._geom)) # <<<<<<<<<<<<<<
@@ -745,7 +745,7 @@
 return __pyx_r;
 }
 
-/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":147
+/* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":147
 * return PyString_FromString(GEOSGeomType(self._geom))
 * 
 * def within(self, BaseGeometry geom): # <<<<<<<<<<<<<<
@@ -762,7 +762,7 @@
 char __pyx_1;
 if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_geom), __pyx_ptype_8_geoslib_BaseGeometry, 1, "geom", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1;}
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":150
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":150
 * cdef GEOSGeom *g1, *g2
 * cdef char answer
 * g1 = self._geom # <<<<<<<<<<<<<<
@@ -771,7 +771,7 @@
 */
 __pyx_v_g1 = ((struct __pyx_obj_8_geoslib_BaseGeometry *)__pyx_v_self)->_geom;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":151
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":151
 * cdef char answer
 * g1 = self._geom
 * g2 = geom._geom # <<<<<<<<<<<<<<
@@ -780,7 +780,7 @@
 */
 __pyx_v_g2 = ((struct __pyx_obj_8_geoslib_BaseGeometry *)__pyx_v_geom)->_geom;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":152
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":152
 * g1 = self._geom
 * g2 = geom._geom
 * answer = GEOSWithin(g1, g2) # <<<<<<<<<<<<<<
@@ -789,7 +789,7 @@
 */
 __pyx_v_answer = GEOSWithin(__pyx_v_g1, __pyx_v_g2);
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":153
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":153
 * g2 = geom._geom
 * answer = GEOSWithin(g1, g2)
 * if answer: # <<<<<<<<<<<<<<
@@ -799,7 +799,7 @@
 __pyx_1 = __pyx_v_answer;
 if (__pyx_1) {
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":154
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":154
 * answer = GEOSWithin(g1, g2)
 * if answer:
 * return True # <<<<<<<<<<<<<<
@@ -813,7 +813,7 @@
 }
 /*else*/ {
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":156
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":156
 * return True
 * else:
 * return False # <<<<<<<<<<<<<<
@@ -835,7 +835,7 @@
 return __pyx_r;
 }
 
-/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":158
+/* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":158
 * return False
 * 
 * def simplify(self, tol): # <<<<<<<<<<<<<<
@@ -865,298 +865,311 @@
 PyObject *__pyx_v_p;
 PyObject *__pyx_v_type;
 PyObject *__pyx_r;
- double __pyx_1;
- int __pyx_2;
+ int __pyx_1;
+ double __pyx_2;
 PyObject *__pyx_3 = 0;
 PyObject *__pyx_4 = 0;
 __pyx_v_b = Py_None; Py_INCREF(Py_None);
 __pyx_v_p = Py_None; Py_INCREF(Py_None);
 __pyx_v_type = Py_None; Py_INCREF(Py_None);
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":162
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":162
 * cdef double tolerance
 * cdef int numgeoms, i, typeid
- * g1 = self._geom # <<<<<<<<<<<<<<
- * tolerance = tol
- * g3 = GEOSSimplify(g1,tolerance)
+ * if GEOS_VERSION_MAJOR > 2: # <<<<<<<<<<<<<<
+ * g1 = self._geom
+ * tolerance = tol
 */
- __pyx_v_g1 = ((struct __pyx_obj_8_geoslib_BaseGeometry *)__pyx_v_self)->_geom;
+ __pyx_1 = (GEOS_VERSION_MAJOR > 2);
+ if (__pyx_1) {
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":163
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":163
 * cdef int numgeoms, i, typeid
- * g1 = self._geom
- * tolerance = tol # <<<<<<<<<<<<<<
- * g3 = GEOSSimplify(g1,tolerance)
- * typeid = GEOSGeomTypeId(g3)
+ * if GEOS_VERSION_MAJOR > 2:
+ * g1 = self._geom # <<<<<<<<<<<<<<
+ * tolerance = tol
+ * g3 = GEOSSimplify(g1,tolerance)
 */
- __pyx_1 = __pyx_PyFloat_AsDouble(__pyx_v_tol); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1;}
- __pyx_v_tolerance = __pyx_1;
+ __pyx_v_g1 = ((struct __pyx_obj_8_geoslib_BaseGeometry *)__pyx_v_self)->_geom;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":164
- * g1 = self._geom
- * tolerance = tol
- * g3 = GEOSSimplify(g1,tolerance) # <<<<<<<<<<<<<<
- * typeid = GEOSGeomTypeId(g3)
- * if typeid == GEOS_POLYGON:
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":164
+ * if GEOS_VERSION_MAJOR > 2:
+ * g1 = self._geom
+ * tolerance = tol # <<<<<<<<<<<<<<
+ * g3 = GEOSSimplify(g1,tolerance)
+ * typeid = GEOSGeomTypeId(g3)
 */
- __pyx_v_g3 = GEOSSimplify(__pyx_v_g1, __pyx_v_tolerance);
+ __pyx_2 = __pyx_PyFloat_AsDouble(__pyx_v_tol); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_v_tolerance = __pyx_2;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":165
- * tolerance = tol
- * g3 = GEOSSimplify(g1,tolerance)
- * typeid = GEOSGeomTypeId(g3) # <<<<<<<<<<<<<<
- * if typeid == GEOS_POLYGON:
- * b = _get_coords(g3)
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":165
+ * g1 = self._geom
+ * tolerance = tol
+ * g3 = GEOSSimplify(g1,tolerance) # <<<<<<<<<<<<<<
+ * typeid = GEOSGeomTypeId(g3)
+ * if typeid == GEOS_POLYGON:
 */
- __pyx_v_typeid = GEOSGeomTypeId(__pyx_v_g3);
+ __pyx_v_g3 = GEOSSimplify(__pyx_v_g1, __pyx_v_tolerance);
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":166
- * g3 = GEOSSimplify(g1,tolerance)
- * typeid = GEOSGeomTypeId(g3)
- * if typeid == GEOS_POLYGON: # <<<<<<<<<<<<<<
- * b = _get_coords(g3)
- * p = Polygon(b)
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":166
+ * tolerance = tol
+ * g3 = GEOSSimplify(g1,tolerance)
+ * typeid = GEOSGeomTypeId(g3) # <<<<<<<<<<<<<<
+ * if typeid == GEOS_POLYGON:
+ * b = _get_coords(g3)
 */
- __pyx_2 = (__pyx_v_typeid == GEOS_POLYGON);
- if (__pyx_2) {
+ __pyx_v_typeid = GEOSGeomTypeId(__pyx_v_g3);
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":167
- * typeid = GEOSGeomTypeId(g3)
- * if typeid == GEOS_POLYGON:
- * b = _get_coords(g3) # <<<<<<<<<<<<<<
- * p = Polygon(b)
- * elif typeid == GEOS_LINESTRING:
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":167
+ * g3 = GEOSSimplify(g1,tolerance)
+ * typeid = GEOSGeomTypeId(g3)
+ * if typeid == GEOS_POLYGON: # <<<<<<<<<<<<<<
+ * b = _get_coords(g3)
+ * p = Polygon(b)
 */
- __pyx_3 = __pyx_f_8_geoslib__get_coords(__pyx_v_g3); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1;}
- Py_DECREF(__pyx_v_b);
- __pyx_v_b = __pyx_3;
- __pyx_3 = 0;
+ __pyx_1 = (__pyx_v_typeid == GEOS_POLYGON);
+ if (__pyx_1) {
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":168
- * if typeid == GEOS_POLYGON:
- * b = _get_coords(g3)
- * p = Polygon(b) # <<<<<<<<<<<<<<
- * elif typeid == GEOS_LINESTRING:
- * b = _get_coords(g3)
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":168
+ * typeid = GEOSGeomTypeId(g3)
+ * if typeid == GEOS_POLYGON:
+ * b = _get_coords(g3) # <<<<<<<<<<<<<<
+ * p = Polygon(b)
+ * elif typeid == GEOS_LINESTRING:
 */
- __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1;}
- Py_INCREF(__pyx_v_b);
- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_b);
- __pyx_4 = PyObject_Call(((PyObject*)__pyx_ptype_8_geoslib_Polygon), ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1;}
- Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
- Py_DECREF(__pyx_v_p);
- __pyx_v_p = __pyx_4;
- __pyx_4 = 0;
- goto __pyx_L4;
- }
+ __pyx_3 = __pyx_f_8_geoslib__get_coords(__pyx_v_g3); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ Py_DECREF(__pyx_v_b);
+ __pyx_v_b = __pyx_3;
+ __pyx_3 = 0;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":169
- * b = _get_coords(g3)
- * p = Polygon(b)
- * elif typeid == GEOS_LINESTRING: # <<<<<<<<<<<<<<
- * b = _get_coords(g3)
- * p = LineString(b)
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":169
+ * if typeid == GEOS_POLYGON:
+ * b = _get_coords(g3)
+ * p = Polygon(b) # <<<<<<<<<<<<<<
+ * elif typeid == GEOS_LINESTRING:
+ * b = _get_coords(g3)
 */
- __pyx_2 = (__pyx_v_typeid == GEOS_LINESTRING);
- if (__pyx_2) {
+ __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ Py_INCREF(__pyx_v_b);
+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_b);
+ __pyx_4 = PyObject_Call(((PyObject*)__pyx_ptype_8_geoslib_Polygon), ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
+ Py_DECREF(__pyx_v_p);
+ __pyx_v_p = __pyx_4;
+ __pyx_4 = 0;
+ goto __pyx_L5;
+ }
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":170
- * p = Polygon(b)
- * elif typeid == GEOS_LINESTRING:
- * b = _get_coords(g3) # <<<<<<<<<<<<<<
- * p = LineString(b)
- * # for multi-geom structures, just return first one.
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":170
+ * b = _get_coords(g3)
+ * p = Polygon(b)
+ * elif typeid == GEOS_LINESTRING: # <<<<<<<<<<<<<<
+ * b = _get_coords(g3)
+ * p = LineString(b)
 */
- __pyx_3 = __pyx_f_8_geoslib__get_coords(__pyx_v_g3); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1;}
- Py_DECREF(__pyx_v_b);
- __pyx_v_b = __pyx_3;
- __pyx_3 = 0;
+ __pyx_1 = (__pyx_v_typeid == GEOS_LINESTRING);
+ if (__pyx_1) {
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":171
- * elif typeid == GEOS_LINESTRING:
- * b = _get_coords(g3)
- * p = LineString(b) # <<<<<<<<<<<<<<
- * # for multi-geom structures, just return first one.
- * elif typeid == GEOS_MULTIPOLYGON:
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":171
+ * p = Polygon(b)
+ * elif typeid == GEOS_LINESTRING:
+ * b = _get_coords(g3) # <<<<<<<<<<<<<<
+ * p = LineString(b)
+ * # for multi-geom structures, just return first one.
 */
- __pyx_4 = PyTuple_New(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1;}
- Py_INCREF(__pyx_v_b);
- PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_b);
- __pyx_3 = PyObject_Call(((PyObject*)__pyx_ptype_8_geoslib_LineString), ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1;}
- Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
- Py_DECREF(__pyx_v_p);
- __pyx_v_p = __pyx_3;
- __pyx_3 = 0;
- goto __pyx_L4;
- }
+ __pyx_3 = __pyx_f_8_geoslib__get_coords(__pyx_v_g3); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ Py_DECREF(__pyx_v_b);
+ __pyx_v_b = __pyx_3;
+ __pyx_3 = 0;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":173
- * p = LineString(b)
- * # for multi-geom structures, just return first one.
- * elif typeid == GEOS_MULTIPOLYGON: # <<<<<<<<<<<<<<
- * numgeoms = GEOSGetNumGeometries(g3)
- * gout = GEOSGetGeometryN(g3, 0)
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":172
+ * elif typeid == GEOS_LINESTRING:
+ * b = _get_coords(g3)
+ * p = LineString(b) # <<<<<<<<<<<<<<
+ * # for multi-geom structures, just return first one.
+ * elif typeid == GEOS_MULTIPOLYGON:
 */
- __pyx_2 = (__pyx_v_typeid == GEOS_MULTIPOLYGON);
- if (__pyx_2) {
+ __pyx_4 = PyTuple_New(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ Py_INCREF(__pyx_v_b);
+ PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_b);
+ __pyx_3 = PyObject_Call(((PyObject*)__pyx_ptype_8_geoslib_LineString), ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
+ Py_DECREF(__pyx_v_p);
+ __pyx_v_p = __pyx_3;
+ __pyx_3 = 0;
+ goto __pyx_L5;
+ }
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":174
- * # for multi-geom structures, just return first one.
- * elif typeid == GEOS_MULTIPOLYGON:
- * numgeoms = GEOSGetNumGeometries(g3) # <<<<<<<<<<<<<<
- * gout = GEOSGetGeometryN(g3, 0)
- * b = _get_coords(gout)
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":174
+ * p = LineString(b)
+ * # for multi-geom structures, just return first one.
+ * elif typeid == GEOS_MULTIPOLYGON: # <<<<<<<<<<<<<<
+ * numgeoms = GEOSGetNumGeometries(g3)
+ * gout = GEOSGetGeometryN(g3, 0)
 */
- __pyx_v_numgeoms = GEOSGetNumGeometries(__pyx_v_g3);
+ __pyx_1 = (__pyx_v_typeid == GEOS_MULTIPOLYGON);
+ if (__pyx_1) {
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":175
- * elif typeid == GEOS_MULTIPOLYGON:
- * numgeoms = GEOSGetNumGeometries(g3)
- * gout = GEOSGetGeometryN(g3, 0) # <<<<<<<<<<<<<<
- * b = _get_coords(gout)
- * p = Polygon(b)
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":175
+ * # for multi-geom structures, just return first one.
+ * elif typeid == GEOS_MULTIPOLYGON:
+ * numgeoms = GEOSGetNumGeometries(g3) # <<<<<<<<<<<<<<
+ * gout = GEOSGetGeometryN(g3, 0)
+ * b = _get_coords(gout)
 */
- __pyx_v_gout = GEOSGetGeometryN(__pyx_v_g3, 0);
+ __pyx_v_numgeoms = GEOSGetNumGeometries(__pyx_v_g3);
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":176
- * numgeoms = GEOSGetNumGeometries(g3)
- * gout = GEOSGetGeometryN(g3, 0)
- * b = _get_coords(gout) # <<<<<<<<<<<<<<
- * p = Polygon(b)
- * elif typeid == GEOS_MULTILINESTRING:
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":176
+ * elif typeid == GEOS_MULTIPOLYGON:
+ * numgeoms = GEOSGetNumGeometries(g3)
+ * gout = GEOSGetGeometryN(g3, 0) # <<<<<<<<<<<<<<
+ * b = _get_coords(gout)
+ * p = Polygon(b)
 */
- __pyx_4 = __pyx_f_8_geoslib__get_coords(__pyx_v_gout); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1;}
- Py_DECREF(__pyx_v_b);
- __pyx_v_b = __pyx_4;
- __pyx_4 = 0;
+ __pyx_v_gout = GEOSGetGeometryN(__pyx_v_g3, 0);
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":177
- * gout = GEOSGetGeometryN(g3, 0)
- * b = _get_coords(gout)
- * p = Polygon(b) # <<<<<<<<<<<<<<
- * elif typeid == GEOS_MULTILINESTRING:
- * numgeoms = GEOSGetNumGeometries(g3)
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":177
+ * numgeoms = GEOSGetNumGeometries(g3)
+ * gout = GEOSGetGeometryN(g3, 0)
+ * b = _get_coords(gout) # <<<<<<<<<<<<<<
+ * p = Polygon(b)
+ * elif typeid == GEOS_MULTILINESTRING:
 */
- __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1;}
- Py_INCREF(__pyx_v_b);
- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_b);
- __pyx_4 = PyObject_Call(((PyObject*)__pyx_ptype_8_geoslib_Polygon), ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1;}
- Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
- Py_DECREF(__pyx_v_p);
- __pyx_v_p = __pyx_4;
- __pyx_4 = 0;
- goto __pyx_L4;
- }
+ __pyx_4 = __pyx_f_8_geoslib__get_coords(__pyx_v_gout); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ Py_DECREF(__pyx_v_b);
+ __pyx_v_b = __pyx_4;
+ __pyx_4 = 0;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":178
- * b = _get_coords(gout)
- * p = Polygon(b)
- * elif typeid == GEOS_MULTILINESTRING: # <<<<<<<<<<<<<<
- * numgeoms = GEOSGetNumGeometries(g3)
- * gout = GEOSGetGeometryN(g3, 0)
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":178
+ * gout = GEOSGetGeometryN(g3, 0)
+ * b = _get_coords(gout)
+ * p = Polygon(b) # <<<<<<<<<<<<<<
+ * elif typeid == GEOS_MULTILINESTRING:
+ * numgeoms = GEOSGetNumGeometries(g3)
 */
- __pyx_2 = (__pyx_v_typeid == GEOS_MULTILINESTRING);
- if (__pyx_2) {
+ __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ Py_INCREF(__pyx_v_b);
+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_b);
+ __pyx_4 = PyObject_Call(((PyObject*)__pyx_ptype_8_geoslib_Polygon), ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
+ Py_DECREF(__pyx_v_p);
+ __pyx_v_p = __pyx_4;
+ __pyx_4 = 0;
+ goto __pyx_L5;
+ }
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":179
- * p = Polygon(b)
- * elif typeid == GEOS_MULTILINESTRING:
- * numgeoms = GEOSGetNumGeometries(g3) # <<<<<<<<<<<<<<
- * gout = GEOSGetGeometryN(g3, 0)
- * b = _get_coords(gout)
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":179
+ * b = _get_coords(gout)
+ * p = Polygon(b)
+ * elif typeid == GEOS_MULTILINESTRING: # <<<<<<<<<<<<<<
+ * numgeoms = GEOSGetNumGeometries(g3)
+ * gout = GEOSGetGeometryN(g3, 0)
 */
- __pyx_v_numgeoms = GEOSGetNumGeometries(__pyx_v_g3);
+ __pyx_1 = (__pyx_v_typeid == GEOS_MULTILINESTRING);
+ if (__pyx_1) {
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":180
- * elif typeid == GEOS_MULTILINESTRING:
- * numgeoms = GEOSGetNumGeometries(g3)
- * gout = GEOSGetGeometryN(g3, 0) # <<<<<<<<<<<<<<
- * b = _get_coords(gout)
- * p = LineString(b)
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":180
+ * p = Polygon(b)
+ * elif typeid == GEOS_MULTILINESTRING:
+ * numgeoms = GEOSGetNumGeometries(g3) # <<<<<<<<<<<<<<
+ * gout = GEOSGetGeometryN(g3, 0)
+ * b = _get_coords(gout)
 */
- __pyx_v_gout = GEOSGetGeometryN(__pyx_v_g3, 0);
+ __pyx_v_numgeoms = GEOSGetNumGeometries(__pyx_v_g3);
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":181
- * numgeoms = GEOSGetNumGeometries(g3)
- * gout = GEOSGetGeometryN(g3, 0)
- * b = _get_coords(gout) # <<<<<<<<<<<<<<
- * p = LineString(b)
- * else:
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":181
+ * elif typeid == GEOS_MULTILINESTRING:
+ * numgeoms = GEOSGetNumGeometries(g3)
+ * gout = GEOSGetGeometryN(g3, 0) # <<<<<<<<<<<<<<
+ * b = _get_coords(gout)
+ * p = LineString(b)
 */
- __pyx_3 = __pyx_f_8_geoslib__get_coords(__pyx_v_gout); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1;}
- Py_DECREF(__pyx_v_b);
- __pyx_v_b = __pyx_3;
- __pyx_3 = 0;
+ __pyx_v_gout = GEOSGetGeometryN(__pyx_v_g3, 0);
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":182
- * gout = GEOSGetGeometryN(g3, 0)
- * b = _get_coords(gout)
- * p = LineString(b) # <<<<<<<<<<<<<<
- * else:
- * type = PyString_FromString(GEOSGeomType(g3))
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":182
+ * numgeoms = GEOSGetNumGeometries(g3)
+ * gout = GEOSGetGeometryN(g3, 0)
+ * b = _get_coords(gout) # <<<<<<<<<<<<<<
+ * p = LineString(b)
+ * else:
 */
- __pyx_4 = PyTuple_New(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1;}
- Py_INCREF(__pyx_v_b);
- PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_b);
- __pyx_3 = PyObject_Call(((PyObject*)__pyx_ptype_8_geoslib_LineString), ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1;}
- Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
- Py_DECREF(__pyx_v_p);
- __pyx_v_p = __pyx_3;
- __pyx_3 = 0;
- goto __pyx_L4;
- }
- /*else*/ {
+ __pyx_3 = __pyx_f_8_geoslib__get_coords(__pyx_v_gout); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ Py_DECREF(__pyx_v_b);
+ __pyx_v_b = __pyx_3;
+ __pyx_3 = 0;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":184
- * p = LineString(b)
- * else:
- * type = PyString_FromString(GEOSGeomType(g3)) # <<<<<<<<<<<<<<
- * raise NotImplementedError("intersections of type '%s' not yet implemented" % (type))
- * GEOSGeom_destroy(g3)
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":183
+ * gout = GEOSGetGeometryN(g3, 0)
+ * b = _get_coords(gout)
+ * p = LineString(b) # <<<<<<<<<<<<<<
+ * else:
+ * type = PyString_FromString(GEOSGeomType(g3))
 */
- __pyx_4 = PyString_FromString(GEOSGeomType(__pyx_v_g3)); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1;}
- Py_DECREF(__pyx_v_type);
- __pyx_v_type = __pyx_4;
- __pyx_4 = 0;
+ __pyx_4 = PyTuple_New(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ Py_INCREF(__pyx_v_b);
+ PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_b);
+ __pyx_3 = PyObject_Call(((PyObject*)__pyx_ptype_8_geoslib_LineString), ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
+ Py_DECREF(__pyx_v_p);
+ __pyx_v_p = __pyx_3;
+ __pyx_3 = 0;
+ goto __pyx_L5;
+ }
+ /*else*/ {
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":185
- * else:
- * type = PyString_FromString(GEOSGeomType(g3))
- * raise NotImplementedError("intersections of type '%s' not yet implemented" % (type)) # <<<<<<<<<<<<<<
- * GEOSGeom_destroy(g3)
- * return p
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":185
+ * p = LineString(b)
+ * else:
+ * type = PyString_FromString(GEOSGeomType(g3)) # <<<<<<<<<<<<<<
+ * raise NotImplementedError("intersections of type '%s' not yet implemented" % (type))
+ * GEOSGeom_destroy(g3)
 */
- __pyx_3 = PyNumber_Remainder(__pyx_kp_5, __pyx_v_type); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1;}
- __pyx_4 = PyTuple_New(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1;}
- PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
- __pyx_3 = 0;
- __pyx_3 = PyObject_Call(__pyx_builtin_NotImplementedError, ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1;}
- Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
- __Pyx_Raise(__pyx_3, 0, 0);
- Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1;}
- }
- __pyx_L4:;
+ __pyx_4 = PyString_FromString(GEOSGeomType(__pyx_v_g3)); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ Py_DECREF(__pyx_v_type);
+ __pyx_v_type = __pyx_4;
+ __pyx_4 = 0;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":186
- * type = PyString_FromString(GEOSGeomType(g3))
- * raise NotImplementedError("intersections of type '%s' not yet implemented" % (type))
- * GEOSGeom_destroy(g3) # <<<<<<<<<<<<<<
- * return p
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":186
+ * else:
+ * type = PyString_FromString(GEOSGeomType(g3))
+ * raise NotImplementedError("intersections of type '%s' not yet implemented" % (type)) # <<<<<<<<<<<<<<
+ * GEOSGeom_destroy(g3)
+ * return p
+ */
+ __pyx_3 = PyNumber_Remainder(__pyx_kp_5, __pyx_v_type); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
+ __pyx_3 = 0;
+ __pyx_3 = PyObject_Call(__pyx_builtin_NotImplementedError, ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
+ __Pyx_Raise(__pyx_3, 0, 0);
+ Py_DECREF(__pyx_3); __pyx_3 = 0;
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ }
+ __pyx_L5:;
+
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":187
+ * type = PyString_FromString(GEOSGeomType(g3))
+ * raise NotImplementedError("intersections of type '%s' not yet implemented" % (type))
+ * GEOSGeom_destroy(g3) # <<<<<<<<<<<<<<
+ * return p
 * 
 */
- GEOSGeom_destroy(__pyx_v_g3);
+ GEOSGeom_destroy(__pyx_v_g3);
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":187
- * raise NotImplementedError("intersections of type '%s' not yet implemented" % (type))
- * GEOSGeom_destroy(g3)
- * return p # <<<<<<<<<<<<<<
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":188
+ * raise NotImplementedError("intersections of type '%s' not yet implemented" % (type))
+ * GEOSGeom_destroy(g3)
+ * return p # <<<<<<<<<<<<<<
 * 
 * def intersects(self, BaseGeometry geom):
 */
- Py_INCREF(__pyx_v_p);
- __pyx_r = __pyx_v_p;
- goto __pyx_L0;
+ Py_INCREF(__pyx_v_p);
+ __pyx_r = __pyx_v_p;
+ goto __pyx_L0;
+ goto __pyx_L4;
+ }
+ __pyx_L4:;
 
 __pyx_r = Py_None; Py_INCREF(Py_None);
 goto __pyx_L0;
@@ -1172,8 +1185,8 @@
 return __pyx_r;
 }
 
-/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":189
- * return p
+/* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":190
+ * return p
 * 
 * def intersects(self, BaseGeometry geom): # <<<<<<<<<<<<<<
 * cdef GEOSGeom *g1, *g2
@@ -1187,9 +1200,9 @@
 char __pyx_v_answer;
 PyObject *__pyx_r;
 char __pyx_1;
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_geom), __pyx_ptype_8_geoslib_BaseGeometry, 1, "geom", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_geom), __pyx_ptype_8_geoslib_BaseGeometry, 1, "geom", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1;}
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":192
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":193
 * cdef GEOSGeom *g1, *g2
 * cdef char answer
 * g1 = self._geom # <<<<<<<<<<<<<<
@@ -1198,7 +1211,7 @@
 */
 __pyx_v_g1 = ((struct __pyx_obj_8_geoslib_BaseGeometry *)__pyx_v_self)->_geom;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":193
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":194
 * cdef char answer
 * g1 = self._geom
 * g2 = geom._geom # <<<<<<<<<<<<<<
@@ -1207,7 +1220,7 @@
 */
 __pyx_v_g2 = ((struct __pyx_obj_8_geoslib_BaseGeometry *)__pyx_v_geom)->_geom;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":194
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":195
 * g1 = self._geom
 * g2 = geom._geom
 * answer = GEOSIntersects(g1, g2) # <<<<<<<<<<<<<<
@@ -1216,7 +1229,7 @@
 */
 __pyx_v_answer = GEOSIntersects(__pyx_v_g1, __pyx_v_g2);
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":195
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":196
 * g2 = geom._geom
 * answer = GEOSIntersects(g1, g2)
 * if answer: # <<<<<<<<<<<<<<
@@ -1226,7 +1239,7 @@
 __pyx_1 = __pyx_v_answer;
 if (__pyx_1) {
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":196
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":197
 * answer = GEOSIntersects(g1, g2)
 * if answer:
 * return True # <<<<<<<<<<<<<<
@@ -1240,7 +1253,7 @@
 }
 /*else*/ {
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":198
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":199
 * return True
 * else:
 * return False # <<<<<<<<<<<<<<
@@ -1262,7 +1275,7 @@
 return __pyx_r;
 }
 
-/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":200
+/* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":201
 * return False
 * 
 * def intersection(self, BaseGeometry geom): # <<<<<<<<<<<<<<
@@ -1299,9 +1312,9 @@
 __pyx_v_p = Py_None; Py_INCREF(Py_None);
 __pyx_v_pout = Py_None; Py_INCREF(Py_None);
 __pyx_v_type = Py_None; Py_INCREF(Py_None);
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_geom), __pyx_ptype_8_geoslib_BaseGeometry, 1, "geom", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_geom), __pyx_ptype_8_geoslib_BaseGeometry, 1, "geom", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1;}
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":204
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":205
 * cdef char answer
 * cdef int numgeoms, i, typeid
 * g1 = self._geom # <<<<<<<<<<<<<<
@@ -1310,7 +1323,7 @@
 */
 __pyx_v_g1 = ((struct __pyx_obj_8_geoslib_BaseGeometry *)__pyx_v_self)->_geom;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":205
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":206
 * cdef int numgeoms, i, typeid
 * g1 = self._geom
 * g2 = geom._geom # <<<<<<<<<<<<<<
@@ -1319,7 +1332,7 @@
 */
 __pyx_v_g2 = ((struct __pyx_obj_8_geoslib_BaseGeometry *)__pyx_v_geom)->_geom;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":206
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":207
 * g1 = self._geom
 * g2 = geom._geom
 * g3 = GEOSIntersection(g1, g2) # <<<<<<<<<<<<<<
@@ -1328,7 +1341,7 @@
 */
 __pyx_v_g3 = GEOSIntersection(__pyx_v_g1, __pyx_v_g2);
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":207
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":208
 * g2 = geom._geom
 * g3 = GEOSIntersection(g1, g2)
 * typeid = GEOSGeomTypeId(g3) # <<<<<<<<<<<<<<
@@ -1337,7 +1350,7 @@
 */
 __pyx_v_typeid = GEOSGeomTypeId(__pyx_v_g3);
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":208
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":209
 * g3 = GEOSIntersection(g1, g2)
 * typeid = GEOSGeomTypeId(g3)
 * if typeid == GEOS_POLYGON: # <<<<<<<<<<<<<<
@@ -1347,42 +1360,42 @@
 __pyx_1 = (__pyx_v_typeid == GEOS_POLYGON);
 if (__pyx_1) {
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":209
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":210
 * typeid = GEOSGeomTypeId(g3)
 * if typeid == GEOS_POLYGON:
 * b = _get_coords(g3) # <<<<<<<<<<<<<<
 * p = Polygon(b)
 * pout = [p]
 */
- __pyx_2 = __pyx_f_8_geoslib__get_coords(__pyx_v_g3); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_2 = __pyx_f_8_geoslib__get_coords(__pyx_v_g3); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1;}
 Py_DECREF(__pyx_v_b);
 __pyx_v_b = __pyx_2;
 __pyx_2 = 0;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":210
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":211
 * if typeid == GEOS_POLYGON:
 * b = _get_coords(g3)
 * p = Polygon(b) # <<<<<<<<<<<<<<
 * pout = [p]
 * elif typeid == GEOS_LINESTRING:
 */
- __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1;}
 Py_INCREF(__pyx_v_b);
 PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_b);
- __pyx_3 = PyObject_Call(((PyObject*)__pyx_ptype_8_geoslib_Polygon), ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_3 = PyObject_Call(((PyObject*)__pyx_ptype_8_geoslib_Polygon), ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1;}
 Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
 Py_DECREF(__pyx_v_p);
 __pyx_v_p = __pyx_3;
 __pyx_3 = 0;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":211
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":212
 * b = _get_coords(g3)
 * p = Polygon(b)
 * pout = [p] # <<<<<<<<<<<<<<
 * elif typeid == GEOS_LINESTRING:
 * b = _get_coords(g3)
 */
- __pyx_2 = PyList_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_2 = PyList_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1;}
 Py_INCREF(__pyx_v_p);
 PyList_SET_ITEM(__pyx_2, 0, __pyx_v_p);
 Py_DECREF(__pyx_v_pout);
@@ -1391,7 +1404,7 @@
 goto __pyx_L4;
 }
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":212
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":213
 * p = Polygon(b)
 * pout = [p]
 * elif typeid == GEOS_LINESTRING: # <<<<<<<<<<<<<<
@@ -1401,42 +1414,42 @@
 __pyx_1 = (__pyx_v_typeid == GEOS_LINESTRING);
 if (__pyx_1) {
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":213
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":214
 * pout = [p]
 * elif typeid == GEOS_LINESTRING:
 * b = _get_coords(g3) # <<<<<<<<<<<<<<
 * p = LineString(b)
 * pout = [p]
 */
- __pyx_3 = __pyx_f_8_geoslib__get_coords(__pyx_v_g3); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_3 = __pyx_f_8_geoslib__get_coords(__pyx_v_g3); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1;}
 Py_DECREF(__pyx_v_b);
 __pyx_v_b = __pyx_3;
 __pyx_3 = 0;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":214
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":215
 * elif typeid == GEOS_LINESTRING:
 * b = _get_coords(g3)
 * p = LineString(b) # <<<<<<<<<<<<<<
 * pout = [p]
 * elif typeid == GEOS_MULTIPOLYGON:
 */
- __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1;}
 Py_INCREF(__pyx_v_b);
 PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_b);
- __pyx_3 = PyObject_Call(((PyObject*)__pyx_ptype_8_geoslib_LineString), ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_3 = PyObject_Call(((PyObject*)__pyx_ptype_8_geoslib_LineString), ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1;}
 Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
 Py_DECREF(__pyx_v_p);
 __pyx_v_p = __pyx_3;
 __pyx_3 = 0;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":215
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":216
 * b = _get_coords(g3)
 * p = LineString(b)
 * pout = [p] # <<<<<<<<<<<<<<
 * elif typeid == GEOS_MULTIPOLYGON:
 * numgeoms = GEOSGetNumGeometries(g3)
 */
- __pyx_2 = PyList_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_2 = PyList_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1;}
 Py_INCREF(__pyx_v_p);
 PyList_SET_ITEM(__pyx_2, 0, __pyx_v_p);
 Py_DECREF(__pyx_v_pout);
@@ -1445,7 +1458,7 @@
 goto __pyx_L4;
 }
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":216
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":217
 * p = LineString(b)
 * pout = [p]
 * elif typeid == GEOS_MULTIPOLYGON: # <<<<<<<<<<<<<<
@@ -1455,7 +1468,7 @@
 __pyx_1 = (__pyx_v_typeid == GEOS_MULTIPOLYGON);
 if (__pyx_1) {
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":217
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":218
 * pout = [p]
 * elif typeid == GEOS_MULTIPOLYGON:
 * numgeoms = GEOSGetNumGeometries(g3) # <<<<<<<<<<<<<<
@@ -1464,19 +1477,19 @@
 */
 __pyx_v_numgeoms = GEOSGetNumGeometries(__pyx_v_g3);
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":218
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":219
 * elif typeid == GEOS_MULTIPOLYGON:
 * numgeoms = GEOSGetNumGeometries(g3)
 * pout = [] # <<<<<<<<<<<<<<
 * for i from 0 <= i < numgeoms:
 * gout = GEOSGetGeometryN(g3, i)
 */
- __pyx_3 = PyList_New(0); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_3 = PyList_New(0); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1;}
 Py_DECREF(__pyx_v_pout);
 __pyx_v_pout = ((PyObject *)__pyx_3);
 __pyx_3 = 0;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":219
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":220
 * numgeoms = GEOSGetNumGeometries(g3)
 * pout = []
 * for i from 0 <= i < numgeoms: # <<<<<<<<<<<<<<
@@ -1485,7 +1498,7 @@
 */
 for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_numgeoms; __pyx_v_i++) {
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":220
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":221
 * pout = []
 * for i from 0 <= i < numgeoms:
 * gout = GEOSGetGeometryN(g3, i) # <<<<<<<<<<<<<<
@@ -1494,48 +1507,48 @@
 */
 __pyx_v_gout = GEOSGetGeometryN(__pyx_v_g3, __pyx_v_i);
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":221
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":222
 * for i from 0 <= i < numgeoms:
 * gout = GEOSGetGeometryN(g3, i)
 * b = _get_coords(gout) # <<<<<<<<<<<<<<
 * p = Polygon(b)
 * pout.append(p)
 */
- __pyx_2 = __pyx_f_8_geoslib__get_coords(__pyx_v_gout); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_2 = __pyx_f_8_geoslib__get_coords(__pyx_v_gout); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1;}
 Py_DECREF(__pyx_v_b);
 __pyx_v_b = __pyx_2;
 __pyx_2 = 0;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":222
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":223
 * gout = GEOSGetGeometryN(g3, i)
 * b = _get_coords(gout)
 * p = Polygon(b) # <<<<<<<<<<<<<<
 * pout.append(p)
 * elif typeid == GEOS_MULTILINESTRING:
 */
- __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1;}
 Py_INCREF(__pyx_v_b);
 PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_b);
- __pyx_2 = PyObject_Call(((PyObject*)__pyx_ptype_8_geoslib_Polygon), ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_2 = PyObject_Call(((PyObject*)__pyx_ptype_8_geoslib_Polygon), ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1;}
 Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
 Py_DECREF(__pyx_v_p);
 __pyx_v_p = __pyx_2;
 __pyx_2 = 0;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":223
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":224
 * b = _get_coords(gout)
 * p = Polygon(b)
 * pout.append(p) # <<<<<<<<<<<<<<
 * elif typeid == GEOS_MULTILINESTRING:
 * numgeoms = GEOSGetNumGeometries(g3)
 */
- __pyx_3 = __Pyx_PyObject_Append(__pyx_v_pout, __pyx_v_p); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_3 = __Pyx_PyObject_Append(__pyx_v_pout, __pyx_v_p); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1;}
 Py_DECREF(__pyx_3); __pyx_3 = 0;
 }
 goto __pyx_L4;
 }
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":224
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":225
 * p = Polygon(b)
 * pout.append(p)
 * elif typeid == GEOS_MULTILINESTRING: # <<<<<<<<<<<<<<
@@ -1545,7 +1558,7 @@
 __pyx_1 = (__pyx_v_typeid == GEOS_MULTILINESTRING);
 if (__pyx_1) {
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":225
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":226
 * pout.append(p)
 * elif typeid == GEOS_MULTILINESTRING:
 * numgeoms = GEOSGetNumGeometries(g3) # <<<<<<<<<<<<<<
@@ -1554,19 +1567,19 @@
 */
 __pyx_v_numgeoms = GEOSGetNumGeometries(__pyx_v_g3);
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":226
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":227
 * elif typeid == GEOS_MULTILINESTRING:
 * numgeoms = GEOSGetNumGeometries(g3)
 * pout = [] # <<<<<<<<<<<<<<
 * for i from 0 <= i < numgeoms:
 * gout = GEOSGetGeometryN(g3, i)
 */
- __pyx_2 = PyList_New(0); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_2 = PyList_New(0); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1;}
 Py_DECREF(__pyx_v_pout);
 __pyx_v_pout = ((PyObject *)__pyx_2);
 __pyx_2 = 0;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":227
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":228
 * numgeoms = GEOSGetNumGeometries(g3)
 * pout = []
 * for i from 0 <= i < numgeoms: # <<<<<<<<<<<<<<
@@ -1575,7 +1588,7 @@
 */
 for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_numgeoms; __pyx_v_i++) {
 
- /* "/Users/jsw/python/matplotlib/...
 
[truncated message content]
From: <md...@us...> - 2008年08月11日 13:01:52
Revision: 6019
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6019&view=rev
Author: mdboom
Date: 2008年08月11日 13:01:47 +0000 (2008年8月11日)
Log Message:
-----------
Snapping bug in last commit.
Modified Paths:
--------------
 trunk/matplotlib/src/_backend_agg.cpp
Modified: trunk/matplotlib/src/_backend_agg.cpp
===================================================================
--- trunk/matplotlib/src/_backend_agg.cpp	2008年08月11日 12:48:50 UTC (rev 6018)
+++ trunk/matplotlib/src/_backend_agg.cpp	2008年08月11日 13:01:47 UTC (rev 6019)
@@ -387,7 +387,7 @@
 double x0, y0, x1, y1;
 unsigned code;
 
- if (!path.should_simplify() || path.total_vertices() > 15)
+ if (path.total_vertices() > 15)
 return false;
 
 code = path.vertex(&x0, &y0);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2008年08月11日 12:48:59
Revision: 6018
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6018&view=rev
Author: mdboom
Date: 2008年08月11日 12:48:50 +0000 (2008年8月11日)
Log Message:
-----------
Does simplify paths when NaN/inf is present.
Modified Paths:
--------------
 trunk/matplotlib/CHANGELOG
 trunk/matplotlib/lib/matplotlib/path.py
 trunk/matplotlib/src/_backend_agg.cpp
 trunk/matplotlib/src/_path.cpp
 trunk/matplotlib/src/agg_py_path_iterator.h
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG	2008年08月11日 07:09:16 UTC (rev 6017)
+++ trunk/matplotlib/CHANGELOG	2008年08月11日 12:48:50 UTC (rev 6018)
@@ -1,3 +1,9 @@
+2008年08月11日 Fix more bugs in NaN/inf handling. In particular, path simplification
+ (which does not handle NaNs or infs) will be turned off automatically
+ when infs or NaNs are present. Also masked arrays are now converted
+ to arrays with NaNs for consistent handling of masks and NaNs
+ - MGD and EF
+
 =================================================================
 2008年08月03日 Released 0.98.3 at svn r5947
 
Modified: trunk/matplotlib/lib/matplotlib/path.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/path.py	2008年08月11日 07:09:16 UTC (rev 6017)
+++ trunk/matplotlib/lib/matplotlib/path.py	2008年08月11日 12:48:50 UTC (rev 6018)
@@ -56,6 +56,11 @@
 :class:`Path` objects, as an optimization, do not store a *codes*
 at all, but have a default one provided for them by
 :meth:`iter_segments`.
+
+ Note also that the vertices and codes arrays should be treated as
+ immutable -- there are a number of optimizations and assumptions
+ made up front in the constructor that will not change when the
+ data changes.
 """
 
 # Path codes
@@ -84,46 +89,29 @@
 dimension.
 
 If *codes* is None, *vertices* will be treated as a series of
- line segments. If *vertices* contains masked values, the
- resulting path will be compressed, with ``MOVETO`` codes
- inserted in the correct places to jump over the masked
- regions.
+ line segments.
+
+ If *vertices* contains masked values, they will be converted
+ to NaNs which are then handled correctly by the Agg
+ PathIterator and other consumers of path data, such as
+ :meth:`iter_segments`.
 """
 if ma.isMaskedArray(vertices):
- is_mask = True
- mask = ma.getmask(vertices)
+ vertices = vertices.astype(np.float_).filled(np.nan)
 else:
- is_mask = False
 vertices = np.asarray(vertices, np.float_)
- mask = ma.nomask
 
 if codes is not None:
 codes = np.asarray(codes, self.code_type)
 assert codes.ndim == 1
 assert len(codes) == len(vertices)
 
- # The path being passed in may have masked values. However,
- # the backends (and any affine transformations in matplotlib
- # itself), are not expected to deal with masked arrays, so we
- # must remove them from the array (using compressed), and add
- # MOVETO commands to the codes array accordingly.
- if is_mask:
- if mask is not ma.nomask:
- mask1d = np.logical_or.reduce(mask, axis=1)
- gmask1d = np.invert(mask1d)
- if codes is None:
- codes = np.empty((len(vertices)), self.code_type)
- codes.fill(self.LINETO)
- codes[0] = self.MOVETO
- vertices = vertices[gmask1d].filled() # ndarray
- codes[np.roll(mask1d, 1)] = self.MOVETO
- codes = codes[gmask1d] # np.compress is much slower
- else:
- vertices = np.asarray(vertices, np.float_)
-
 assert vertices.ndim == 2
 assert vertices.shape[1] == 2
 
+ self.should_simplify = (codes is None and
+ np.all(np.isfinite(vertices)) and
+ len(vertices) >= 128)
 self.codes = codes
 self.vertices = vertices
 
Modified: trunk/matplotlib/src/_backend_agg.cpp
===================================================================
--- trunk/matplotlib/src/_backend_agg.cpp	2008年08月11日 07:09:16 UTC (rev 6017)
+++ trunk/matplotlib/src/_backend_agg.cpp	2008年08月11日 12:48:50 UTC (rev 6018)
@@ -387,7 +387,7 @@
 double x0, y0, x1, y1;
 unsigned code;
 
- if (path.total_vertices() > 15)
+ if (!path.should_simplify() || path.total_vertices() > 15)
 return false;
 
 code = path.vertex(&x0, &y0);
@@ -420,11 +420,6 @@
 return true;
 }
 
-template<class Path>
-bool should_simplify(Path& path) {
- return !path.has_curves() && path.total_vertices() >= 128;
-}
-
 Py::Object
 RendererAgg::copy_from_bbox(const Py::Tuple& args) {
 //copy region in bbox to buffer and return swig/agg buffer object
@@ -938,7 +933,7 @@
 trans *= agg::trans_affine_scaling(1.0, -1.0);
 trans *= agg::trans_affine_translation(0.0, (double)height);
 bool snap = should_snap(path, trans);
- bool simplify = should_simplify(path) && !face.first;
+ bool simplify = path.should_simplify() && !face.first;
 
 transformed_path_t tpath(path, trans);
 simplify_t simplified(tpath, snap, simplify, width, height);
@@ -1236,6 +1231,10 @@
 inline unsigned total_vertices() {
 return 5;
 }
+
+ inline bool should_simplify() {
+ return false;
+ }
 };
 
 public:
Modified: trunk/matplotlib/src/_path.cpp
===================================================================
--- trunk/matplotlib/src/_path.cpp	2008年08月11日 07:09:16 UTC (rev 6017)
+++ trunk/matplotlib/src/_path.cpp	2008年08月11日 12:48:50 UTC (rev 6018)
@@ -1120,7 +1120,7 @@
 double width = Py::Float(args[2]);
 double height = Py::Float(args[3]);
 
- bool simplify = !path.has_curves() && width != 0.0 && height != 0.0;
+ bool simplify = path.should_simplify() && width != 0.0 && height != 0.0;
 
 transformed_path_t tpath(path, trans);
 simplify_t simplified(tpath, false, simplify, width, height);
Modified: trunk/matplotlib/src/agg_py_path_iterator.h
===================================================================
--- trunk/matplotlib/src/agg_py_path_iterator.h	2008年08月11日 07:09:16 UTC (rev 6017)
+++ trunk/matplotlib/src/agg_py_path_iterator.h	2008年08月11日 12:48:50 UTC (rev 6018)
@@ -15,6 +15,7 @@
 PyArrayObject* m_codes;
 size_t m_iterator;
 size_t m_total_vertices;
+ bool m_should_simplify;
 
 public:
 PathIterator(const Py::Object& path_obj) :
@@ -22,6 +23,7 @@
 {
 Py::Object vertices_obj = path_obj.getAttr("vertices");
 Py::Object codes_obj = path_obj.getAttr("codes");
+ Py::Object should_simplify_obj = path_obj.getAttr("should_simplify");
 
 m_vertices = (PyArrayObject*)PyArray_FromObject
 (vertices_obj.ptr(), PyArray_DOUBLE, 2, 2);
@@ -38,6 +40,7 @@
 throw Py::ValueError("Invalid codes array.");
 }
 
+ m_should_simplify = bool(Py::Int(should_simplify_obj));
 m_total_vertices = m_vertices->dimensions[0];
 }
 
@@ -100,9 +103,9 @@
 return m_total_vertices;
 }
 
- inline bool has_curves()
+ inline bool should_simplify()
 {
- return m_codes;
+ return m_should_simplify;
 }
 };
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <ef...@us...> - 2008年08月11日 07:09:22
Revision: 6017
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6017&view=rev
Author: efiring
Date: 2008年08月11日 07:09:16 +0000 (2008年8月11日)
Log Message:
-----------
Eliminate duplicate Path instantiation
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/axes.py
 trunk/matplotlib/lib/matplotlib/transforms.py
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py	2008年08月10日 23:49:21 UTC (rev 6016)
+++ trunk/matplotlib/lib/matplotlib/axes.py	2008年08月11日 07:09:16 UTC (rev 6017)
@@ -1282,8 +1282,9 @@
 line._remove_method = lambda h: self.lines.remove(h)
 
 def _update_line_limits(self, line):
- xydata = line.get_xydata()
- self.update_datalim( xydata )
+ self.dataLim.update_from_path(line.get_path(),
+ self.ignore_existing_data_limits)
+ self.ignore_existing_data_limits = False
 
 def add_patch(self, p):
 """
@@ -1307,12 +1308,11 @@
 # the auto-scaling
 if isinstance(p, mpatches.Rectangle) and (p.get_width()==0. or p.get_height()==0.):
 return
-
 vertices = p.get_patch_transform().transform(p.get_path().vertices)
 if p.get_data_transform() != self.transData:
 transform = p.get_data_transform() + self.transData.inverted()
 xys = transform.transform(vertices)
-
+ # Something is wrong--xys is never used.
 self.update_datalim(vertices)
 
 def add_table(self, tab):
@@ -1327,6 +1327,8 @@
 
 def relim(self):
 'recompute the data limits based on current artists'
+ # Collections are deliberately not supported (yet); see
+ # the TODO note in artists.py.
 self.dataLim.ignore(True)
 self.ignore_existing_data_limits = True
 for line in self.lines:
Modified: trunk/matplotlib/lib/matplotlib/transforms.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/transforms.py	2008年08月10日 23:49:21 UTC (rev 6016)
+++ trunk/matplotlib/lib/matplotlib/transforms.py	2008年08月11日 07:09:16 UTC (rev 6017)
@@ -786,12 +786,12 @@
 xy = np.hstack((x.reshape((len(x), 1)), y.reshape((len(y), 1))))
 return self.update_from_data_xy(xy, ignore)
 
- def update_from_data_xy(self, xy, ignore=None):
+ def update_from_path(self, path, ignore=None):
 """
 Update the bounds of the :class:`Bbox` based on the passed in
 data.
 
- xy: a numpy array of 2D points
+ path: a Path instance
 
 ignore:
 - when True, ignore the existing bounds of the Bbox.
@@ -801,20 +801,33 @@
 if ignore is None:
 ignore = self._ignore
 
- if len(xy) == 0:
- return
- xym = ma.masked_invalid(xy) # maybe add copy=False
- if (xym.count(axis=1)!=2).all():
- return
-
 points, minpos, changed = update_path_extents(
- Path(xym), None, self._points, self._minpos, ignore)
+ path, None, self._points, self._minpos, ignore)
 
 if changed:
 self._points = points
 self._minpos = minpos
 self.invalidate()
 
+
+ def update_from_data_xy(self, xy, ignore=None):
+ """
+ Update the bounds of the :class:`Bbox` based on the passed in
+ data.
+
+ xy: a numpy array of 2D points
+
+ ignore:
+ - when True, ignore the existing bounds of the Bbox.
+ - when False, include the existing bounds of the Bbox.
+ - when None, use the last value passed to :meth:`ignore`.
+ """
+ if len(xy) == 0:
+ return
+
+ path = Path(xy)
+ self.update_from_path(path, ignore=ignore)
+
 def _set_x0(self, val):
 self._points[0, 0] = val
 self.invalidate()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <ef...@us...> - 2008年08月10日 23:49:24
Revision: 6016
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6016&view=rev
Author: efiring
Date: 2008年08月10日 23:49:21 +0000 (2008年8月10日)
Log Message:
-----------
Fix MPL_notisfinite64
Modified Paths:
--------------
 trunk/matplotlib/src/MPL_isnan.h
Modified: trunk/matplotlib/src/MPL_isnan.h
===================================================================
--- trunk/matplotlib/src/MPL_isnan.h	2008年08月09日 16:26:16 UTC (rev 6015)
+++ trunk/matplotlib/src/MPL_isnan.h	2008年08月10日 23:49:21 UTC (rev 6016)
@@ -73,10 +73,10 @@
 #if !defined(MPL_notisfinite64)
 #if !defined(_MSC_VER)
 #define MPL_notisfinite64(u) \
- ( (( MPL_U64(u) & 0x7ff0000000000000LL) != 0x7ff0000000000000LL)) ? 0:1
+ ( (( MPL_U64(u) & 0x7ff0000000000000LL) == 0x7ff0000000000000LL)) ? 1:0
 #else
 #define MPL_notisfinite64(u) \
- ( (( MPL_U64(u) & 0x7ff0000000000000i64) != 0x7ff0000000000000i64)) ? 0:1
+ ( (( MPL_U64(u) & 0x7ff0000000000000i64) == 0x7ff0000000000000i64)) ? 1:0
 #endif
 #endif /* MPL_notisfinite64 */
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <js...@us...> - 2008年08月09日 16:26:19
Revision: 6015
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6015&view=rev
Author: jswhit
Date: 2008年08月09日 16:26:16 +0000 (2008年8月09日)
Log Message:
-----------
added NetCDFFile test
Modified Paths:
--------------
 trunk/toolkits/basemap/MANIFEST.in
Modified: trunk/toolkits/basemap/MANIFEST.in
===================================================================
--- trunk/toolkits/basemap/MANIFEST.in	2008年08月09日 16:25:22 UTC (rev 6014)
+++ trunk/toolkits/basemap/MANIFEST.in	2008年08月09日 16:26:16 UTC (rev 6015)
@@ -66,6 +66,7 @@
 include examples/show_colormaps.py
 include examples/plotprecip.py
 include examples/nws_precip_conus_20061222.nc
+include examples/NetCDFFile_tst.py
 include examples/README
 include lib/mpl_toolkits/__init__.py
 include lib/mpl_toolkits/basemap/__init__.py
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6014
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6014&view=rev
Author: jswhit
Date: 2008年08月09日 16:25:22 +0000 (2008年8月09日)
Log Message:
-----------
added NetCDFFile test
Added Paths:
-----------
 trunk/toolkits/basemap/examples/NetCDFFile_tst.py
Added: trunk/toolkits/basemap/examples/NetCDFFile_tst.py
===================================================================
--- trunk/toolkits/basemap/examples/NetCDFFile_tst.py	 (rev 0)
+++ trunk/toolkits/basemap/examples/NetCDFFile_tst.py	2008年08月09日 16:25:22 UTC (rev 6014)
@@ -0,0 +1,65 @@
+import sys
+import unittest
+import os
+import tempfile
+from numpy import ma
+from numpy.testing import assert_array_equal, assert_array_almost_equal
+from numpy.random.mtrand import uniform 
+from mpl_toolkits.basemap import NetCDFFile
+
+# test automatic conversion of masked arrays, and
+# packing/unpacking of short ints.
+
+FILE_NAME = tempfile.mktemp(".nc")
+ndim = 10
+ranarr = 100.*uniform(size=(ndim))
+packeddata = 10.*uniform(size=(ndim))
+missing_value = -9999.
+ranarr[::2] = missing_value
+maskedarr = ma.masked_values(ranarr,-9999.)
+scale_factor = (packeddata.max()-packeddata.min())/(2.*32766.)
+add_offset = 0.5*(packeddata.max()+packeddata.min())
+packeddata2 = ((packeddata-add_offset)/scale_factor).astype('i2')
+
+class TestCase(unittest.TestCase):
+
+ def setUp(self):
+ self.file = FILE_NAME
+ file = NetCDFFile(self.file,'w')
+ file.createDimension('n', None) # use unlimited dim.
+ foo = file.createVariable('maskeddata', 'f8', ('n',))
+ foo.missing_value = missing_value
+ bar = file.createVariable('packeddata', 'i2', ('n',))
+ bar.scale_factor = scale_factor
+ bar.add_offset = add_offset
+ foo[0:ndim] = maskedarr
+ bar[0:ndim] = packeddata
+ file.close()
+
+ def tearDown(self):
+ # Remove the temporary files
+ os.remove(self.file)
+
+ def runTest(self):
+ """testing auto-conversion of masked arrays and packed integers""" 
+ # no auto-conversion.
+ file = NetCDFFile(self.file,maskandscale=False)
+ datamasked = file.variables['maskeddata']
+ datapacked = file.variables['packeddata']
+ # check missing_value, scale_factor and add_offset attributes.
+ assert datamasked.missing_value == missing_value
+ assert datapacked.scale_factor == scale_factor
+ assert datapacked.add_offset == add_offset
+ assert_array_equal(datapacked[:],packeddata2)
+ assert_array_almost_equal(datamasked[:],ranarr)
+ file.close()
+ # auto-conversion
+ file = NetCDFFile(self.file)
+ datamasked = file.variables['maskeddata']
+ datapacked = file.variables['packeddata']
+ assert_array_almost_equal(datamasked[:].filled(),ranarr)
+ assert_array_almost_equal(datapacked[:],packeddata,decimal=4)
+ file.close()
+
+if __name__ == '__main__':
+ unittest.main()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <js...@us...> - 2008年08月09日 16:18:23
Revision: 6013
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6013&view=rev
Author: jswhit
Date: 2008年08月09日 16:18:19 +0000 (2008年8月09日)
Log Message:
-----------
simplify treatment of dodgy geometries in GEOS 3
Modified Paths:
--------------
 trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
 trunk/toolkits/basemap/src/_geoslib.c
 trunk/toolkits/basemap/src/_geoslib.pyx
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py	2008年08月09日 14:49:42 UTC (rev 6012)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py	2008年08月09日 16:18:19 UTC (rev 6013)
@@ -985,7 +985,7 @@
 # found non-noded intersection between ..."
 # with geos 3.0.0
 if _geoslib.__geos_major_version__ > 2:
- poly = poly.simplify(1.e-10)[0]
+ poly = poly.simplify(1.e-10)
 # if geometry instersects map projection
 # region, and doesn't have any invalid points, process it.
 if goodmask.all() and poly.intersects(boundarypolyxy):
Modified: trunk/toolkits/basemap/src/_geoslib.c
===================================================================
--- trunk/toolkits/basemap/src/_geoslib.c	2008年08月09日 14:49:42 UTC (rev 6012)
+++ trunk/toolkits/basemap/src/_geoslib.c	2008年08月09日 16:18:19 UTC (rev 6013)
@@ -1,4 +1,4 @@
-/* Generated by Cython 0.9.8 on Fri Aug 8 06:11:34 2008 */
+/* Generated by Cython 0.9.8 on Sat Aug 9 10:17:12 2008 */
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"
@@ -181,6 +181,8 @@
 
 static void __Pyx_WriteUnraisable(const char *name); /*proto*/
 
+static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
+
 static INLINE PyObject* __Pyx_PyObject_Append(PyObject* L, PyObject* x) {
 if (likely(PyList_CheckExact(L))) {
 if (PyList_Append(L, x) < 0) return NULL;
@@ -192,8 +194,6 @@
 }
 }
 
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
-
 static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/
 
 static INLINE PyObject *__Pyx_GetItemInt(PyObject *o, Py_ssize_t i, int is_unsigned) {
@@ -243,7 +243,7 @@
 PyObject *boundary;
 };
 
-/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":259
+/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":249
 * return (self.__class__,(self.boundary,))
 * 
 * cdef class Polygon(BaseGeometry): # <<<<<<<<<<<<<<
@@ -255,7 +255,7 @@
 struct __pyx_obj_8_geoslib_BaseGeometry __pyx_base;
 };
 
-/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":315
+/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":305
 * return area
 * 
 * cdef class LineString(BaseGeometry): # <<<<<<<<<<<<<<
@@ -267,7 +267,7 @@
 struct __pyx_obj_8_geoslib_BaseGeometry __pyx_base;
 };
 
-/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":347
+/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":337
 * self.boundary = b
 * 
 * cdef class Point(BaseGeometry): # <<<<<<<<<<<<<<
@@ -843,10 +843,8 @@
 * cdef double tolerance
 */
 
-static char __pyx_k_append[] = "append";
 static char __pyx_k_NotImplementedError[] = "NotImplementedError";
 
-static PyObject *__pyx_kp_append;
 static PyObject *__pyx_kp_NotImplementedError;
 
 static PyObject *__pyx_kp_5;
@@ -862,421 +860,302 @@
 GEOSGeom *__pyx_v_gout;
 double __pyx_v_tolerance;
 int __pyx_v_numgeoms;
- int __pyx_v_i;
 int __pyx_v_typeid;
 PyObject *__pyx_v_b;
 PyObject *__pyx_v_p;
- PyObject *__pyx_v_pout;
 PyObject *__pyx_v_type;
 PyObject *__pyx_r;
- int __pyx_1;
- double __pyx_2;
+ double __pyx_1;
+ int __pyx_2;
 PyObject *__pyx_3 = 0;
 PyObject *__pyx_4 = 0;
 __pyx_v_b = Py_None; Py_INCREF(Py_None);
 __pyx_v_p = Py_None; Py_INCREF(Py_None);
- __pyx_v_pout = Py_None; Py_INCREF(Py_None);
 __pyx_v_type = Py_None; Py_INCREF(Py_None);
 
 /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":162
 * cdef double tolerance
 * cdef int numgeoms, i, typeid
 * g1 = self._geom # <<<<<<<<<<<<<<
- * if GEOS_VERSION_MAJOR > 2:
- * tolerance = tol
+ * tolerance = tol
+ * g3 = GEOSSimplify(g1,tolerance)
 */
 __pyx_v_g1 = ((struct __pyx_obj_8_geoslib_BaseGeometry *)__pyx_v_self)->_geom;
 
 /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":163
 * cdef int numgeoms, i, typeid
 * g1 = self._geom
- * if GEOS_VERSION_MAJOR > 2: # <<<<<<<<<<<<<<
- * tolerance = tol
- * g3 = GEOSSimplify(g1, tolerance)
+ * tolerance = tol # <<<<<<<<<<<<<<
+ * g3 = GEOSSimplify(g1,tolerance)
+ * typeid = GEOSGeomTypeId(g3)
 */
- __pyx_1 = (GEOS_VERSION_MAJOR > 2);
- if (__pyx_1) {
+ __pyx_1 = __pyx_PyFloat_AsDouble(__pyx_v_tol); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_v_tolerance = __pyx_1;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":164
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":164
 * g1 = self._geom
- * if GEOS_VERSION_MAJOR > 2:
- * tolerance = tol # <<<<<<<<<<<<<<
- * g3 = GEOSSimplify(g1, tolerance)
- * else:
- */
- __pyx_2 = __pyx_PyFloat_AsDouble(__pyx_v_tol); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1;}
- __pyx_v_tolerance = __pyx_2;
-
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":165
- * if GEOS_VERSION_MAJOR > 2:
- * tolerance = tol
- * g3 = GEOSSimplify(g1, tolerance) # <<<<<<<<<<<<<<
- * else:
- * g3 = g1
- */
- __pyx_v_g3 = GEOSSimplify(__pyx_v_g1, __pyx_v_tolerance);
- goto __pyx_L4;
- }
- /*else*/ {
-
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":167
- * g3 = GEOSSimplify(g1, tolerance)
- * else:
- * g3 = g1 # <<<<<<<<<<<<<<
+ * tolerance = tol
+ * g3 = GEOSSimplify(g1,tolerance) # <<<<<<<<<<<<<<
 * typeid = GEOSGeomTypeId(g3)
 * if typeid == GEOS_POLYGON:
 */
- __pyx_v_g3 = __pyx_v_g1;
- }
- __pyx_L4:;
+ __pyx_v_g3 = GEOSSimplify(__pyx_v_g1, __pyx_v_tolerance);
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":168
- * else:
- * g3 = g1
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":165
+ * tolerance = tol
+ * g3 = GEOSSimplify(g1,tolerance)
 * typeid = GEOSGeomTypeId(g3) # <<<<<<<<<<<<<<
 * if typeid == GEOS_POLYGON:
 * b = _get_coords(g3)
 */
 __pyx_v_typeid = GEOSGeomTypeId(__pyx_v_g3);
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":169
- * g3 = g1
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":166
+ * g3 = GEOSSimplify(g1,tolerance)
 * typeid = GEOSGeomTypeId(g3)
 * if typeid == GEOS_POLYGON: # <<<<<<<<<<<<<<
 * b = _get_coords(g3)
 * p = Polygon(b)
 */
- __pyx_1 = (__pyx_v_typeid == GEOS_POLYGON);
- if (__pyx_1) {
+ __pyx_2 = (__pyx_v_typeid == GEOS_POLYGON);
+ if (__pyx_2) {
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":170
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":167
 * typeid = GEOSGeomTypeId(g3)
 * if typeid == GEOS_POLYGON:
 * b = _get_coords(g3) # <<<<<<<<<<<<<<
 * p = Polygon(b)
- * pout = [p]
+ * elif typeid == GEOS_LINESTRING:
 */
- __pyx_3 = __pyx_f_8_geoslib__get_coords(__pyx_v_g3); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_3 = __pyx_f_8_geoslib__get_coords(__pyx_v_g3); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1;}
 Py_DECREF(__pyx_v_b);
 __pyx_v_b = __pyx_3;
 __pyx_3 = 0;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":171
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":168
 * if typeid == GEOS_POLYGON:
 * b = _get_coords(g3)
 * p = Polygon(b) # <<<<<<<<<<<<<<
- * pout = [p]
 * elif typeid == GEOS_LINESTRING:
+ * b = _get_coords(g3)
 */
- __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1;}
 Py_INCREF(__pyx_v_b);
 PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_b);
- __pyx_4 = PyObject_Call(((PyObject*)__pyx_ptype_8_geoslib_Polygon), ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_4 = PyObject_Call(((PyObject*)__pyx_ptype_8_geoslib_Polygon), ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1;}
 Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
 Py_DECREF(__pyx_v_p);
 __pyx_v_p = __pyx_4;
 __pyx_4 = 0;
+ goto __pyx_L4;
+ }
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":172
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":169
 * b = _get_coords(g3)
 * p = Polygon(b)
- * pout = [p] # <<<<<<<<<<<<<<
- * elif typeid == GEOS_LINESTRING:
- * b = _get_coords(g3)
- */
- __pyx_3 = PyList_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1;}
- Py_INCREF(__pyx_v_p);
- PyList_SET_ITEM(__pyx_3, 0, __pyx_v_p);
- Py_DECREF(__pyx_v_pout);
- __pyx_v_pout = ((PyObject *)__pyx_3);
- __pyx_3 = 0;
- goto __pyx_L5;
- }
-
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":173
- * p = Polygon(b)
- * pout = [p]
 * elif typeid == GEOS_LINESTRING: # <<<<<<<<<<<<<<
 * b = _get_coords(g3)
 * p = LineString(b)
 */
- __pyx_1 = (__pyx_v_typeid == GEOS_LINESTRING);
- if (__pyx_1) {
+ __pyx_2 = (__pyx_v_typeid == GEOS_LINESTRING);
+ if (__pyx_2) {
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":174
- * pout = [p]
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":170
+ * p = Polygon(b)
 * elif typeid == GEOS_LINESTRING:
 * b = _get_coords(g3) # <<<<<<<<<<<<<<
 * p = LineString(b)
- * pout = [p]
+ * # for multi-geom structures, just return first one.
 */
- __pyx_4 = __pyx_f_8_geoslib__get_coords(__pyx_v_g3); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_3 = __pyx_f_8_geoslib__get_coords(__pyx_v_g3); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1;}
 Py_DECREF(__pyx_v_b);
- __pyx_v_b = __pyx_4;
- __pyx_4 = 0;
+ __pyx_v_b = __pyx_3;
+ __pyx_3 = 0;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":175
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":171
 * elif typeid == GEOS_LINESTRING:
 * b = _get_coords(g3)
 * p = LineString(b) # <<<<<<<<<<<<<<
- * pout = [p]
+ * # for multi-geom structures, just return first one.
 * elif typeid == GEOS_MULTIPOLYGON:
 */
- __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1;}
 Py_INCREF(__pyx_v_b);
- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_b);
- __pyx_4 = PyObject_Call(((PyObject*)__pyx_ptype_8_geoslib_LineString), ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1;}
- Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
+ PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_b);
+ __pyx_3 = PyObject_Call(((PyObject*)__pyx_ptype_8_geoslib_LineString), ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
 Py_DECREF(__pyx_v_p);
- __pyx_v_p = __pyx_4;
- __pyx_4 = 0;
-
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":176
- * b = _get_coords(g3)
- * p = LineString(b)
- * pout = [p] # <<<<<<<<<<<<<<
- * elif typeid == GEOS_MULTIPOLYGON:
- * numgeoms = GEOSGetNumGeometries(g3)
- */
- __pyx_3 = PyList_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1;}
- Py_INCREF(__pyx_v_p);
- PyList_SET_ITEM(__pyx_3, 0, __pyx_v_p);
- Py_DECREF(__pyx_v_pout);
- __pyx_v_pout = ((PyObject *)__pyx_3);
+ __pyx_v_p = __pyx_3;
 __pyx_3 = 0;
- goto __pyx_L5;
+ goto __pyx_L4;
 }
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":177
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":173
 * p = LineString(b)
- * pout = [p]
+ * # for multi-geom structures, just return first one.
 * elif typeid == GEOS_MULTIPOLYGON: # <<<<<<<<<<<<<<
 * numgeoms = GEOSGetNumGeometries(g3)
- * pout = []
+ * gout = GEOSGetGeometryN(g3, 0)
 */
- __pyx_1 = (__pyx_v_typeid == GEOS_MULTIPOLYGON);
- if (__pyx_1) {
+ __pyx_2 = (__pyx_v_typeid == GEOS_MULTIPOLYGON);
+ if (__pyx_2) {
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":178
- * pout = [p]
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":174
+ * # for multi-geom structures, just return first one.
 * elif typeid == GEOS_MULTIPOLYGON:
 * numgeoms = GEOSGetNumGeometries(g3) # <<<<<<<<<<<<<<
- * pout = []
- * for i from 0 <= i < numgeoms:
+ * gout = GEOSGetGeometryN(g3, 0)
+ * b = _get_coords(gout)
 */
 __pyx_v_numgeoms = GEOSGetNumGeometries(__pyx_v_g3);
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":179
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":175
 * elif typeid == GEOS_MULTIPOLYGON:
 * numgeoms = GEOSGetNumGeometries(g3)
- * pout = [] # <<<<<<<<<<<<<<
- * for i from 0 <= i < numgeoms:
- * gout = GEOSGetGeometryN(g3, i)
+ * gout = GEOSGetGeometryN(g3, 0) # <<<<<<<<<<<<<<
+ * b = _get_coords(gout)
+ * p = Polygon(b)
 */
- __pyx_4 = PyList_New(0); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1;}
- Py_DECREF(__pyx_v_pout);
- __pyx_v_pout = ((PyObject *)__pyx_4);
- __pyx_4 = 0;
+ __pyx_v_gout = GEOSGetGeometryN(__pyx_v_g3, 0);
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":180
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":176
 * numgeoms = GEOSGetNumGeometries(g3)
- * pout = []
- * for i from 0 <= i < numgeoms: # <<<<<<<<<<<<<<
- * gout = GEOSGetGeometryN(g3, i)
- * b = _get_coords(gout)
- */
- for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_numgeoms; __pyx_v_i++) {
-
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":181
- * pout = []
- * for i from 0 <= i < numgeoms:
- * gout = GEOSGetGeometryN(g3, i) # <<<<<<<<<<<<<<
- * b = _get_coords(gout)
- * p = Polygon(b)
- */
- __pyx_v_gout = GEOSGetGeometryN(__pyx_v_g3, __pyx_v_i);
-
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":182
- * for i from 0 <= i < numgeoms:
- * gout = GEOSGetGeometryN(g3, i)
- * b = _get_coords(gout) # <<<<<<<<<<<<<<
- * p = Polygon(b)
- * pout.append(p)
- */
- __pyx_3 = __pyx_f_8_geoslib__get_coords(__pyx_v_gout); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1;}
- Py_DECREF(__pyx_v_b);
- __pyx_v_b = __pyx_3;
- __pyx_3 = 0;
-
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":183
- * gout = GEOSGetGeometryN(g3, i)
- * b = _get_coords(gout)
- * p = Polygon(b) # <<<<<<<<<<<<<<
- * pout.append(p)
+ * gout = GEOSGetGeometryN(g3, 0)
+ * b = _get_coords(gout) # <<<<<<<<<<<<<<
+ * p = Polygon(b)
 * elif typeid == GEOS_MULTILINESTRING:
 */
- __pyx_4 = PyTuple_New(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1;}
- Py_INCREF(__pyx_v_b);
- PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_b);
- __pyx_3 = PyObject_Call(((PyObject*)__pyx_ptype_8_geoslib_Polygon), ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1;}
- Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
- Py_DECREF(__pyx_v_p);
- __pyx_v_p = __pyx_3;
- __pyx_3 = 0;
+ __pyx_4 = __pyx_f_8_geoslib__get_coords(__pyx_v_gout); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ Py_DECREF(__pyx_v_b);
+ __pyx_v_b = __pyx_4;
+ __pyx_4 = 0;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":184
- * b = _get_coords(gout)
- * p = Polygon(b)
- * pout.append(p) # <<<<<<<<<<<<<<
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":177
+ * gout = GEOSGetGeometryN(g3, 0)
+ * b = _get_coords(gout)
+ * p = Polygon(b) # <<<<<<<<<<<<<<
 * elif typeid == GEOS_MULTILINESTRING:
 * numgeoms = GEOSGetNumGeometries(g3)
 */
- __pyx_4 = __Pyx_PyObject_Append(__pyx_v_pout, __pyx_v_p); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1;}
- Py_DECREF(__pyx_4); __pyx_4 = 0;
- }
- goto __pyx_L5;
+ __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ Py_INCREF(__pyx_v_b);
+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_b);
+ __pyx_4 = PyObject_Call(((PyObject*)__pyx_ptype_8_geoslib_Polygon), ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
+ Py_DECREF(__pyx_v_p);
+ __pyx_v_p = __pyx_4;
+ __pyx_4 = 0;
+ goto __pyx_L4;
 }
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":185
- * p = Polygon(b)
- * pout.append(p)
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":178
+ * b = _get_coords(gout)
+ * p = Polygon(b)
 * elif typeid == GEOS_MULTILINESTRING: # <<<<<<<<<<<<<<
 * numgeoms = GEOSGetNumGeometries(g3)
- * pout = []
+ * gout = GEOSGetGeometryN(g3, 0)
 */
- __pyx_1 = (__pyx_v_typeid == GEOS_MULTILINESTRING);
- if (__pyx_1) {
+ __pyx_2 = (__pyx_v_typeid == GEOS_MULTILINESTRING);
+ if (__pyx_2) {
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":186
- * pout.append(p)
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":179
+ * p = Polygon(b)
 * elif typeid == GEOS_MULTILINESTRING:
 * numgeoms = GEOSGetNumGeometries(g3) # <<<<<<<<<<<<<<
- * pout = []
- * for i from 0 <= i < numgeoms:
+ * gout = GEOSGetGeometryN(g3, 0)
+ * b = _get_coords(gout)
 */
 __pyx_v_numgeoms = GEOSGetNumGeometries(__pyx_v_g3);
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":187
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":180
 * elif typeid == GEOS_MULTILINESTRING:
 * numgeoms = GEOSGetNumGeometries(g3)
- * pout = [] # <<<<<<<<<<<<<<
- * for i from 0 <= i < numgeoms:
- * gout = GEOSGetGeometryN(g3, i)
+ * gout = GEOSGetGeometryN(g3, 0) # <<<<<<<<<<<<<<
+ * b = _get_coords(gout)
+ * p = LineString(b)
 */
- __pyx_3 = PyList_New(0); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1;}
- Py_DECREF(__pyx_v_pout);
- __pyx_v_pout = ((PyObject *)__pyx_3);
- __pyx_3 = 0;
+ __pyx_v_gout = GEOSGetGeometryN(__pyx_v_g3, 0);
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":188
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":181
 * numgeoms = GEOSGetNumGeometries(g3)
- * pout = []
- * for i from 0 <= i < numgeoms: # <<<<<<<<<<<<<<
- * gout = GEOSGetGeometryN(g3, i)
- * b = _get_coords(gout)
- */
- for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_numgeoms; __pyx_v_i++) {
-
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":189
- * pout = []
- * for i from 0 <= i < numgeoms:
- * gout = GEOSGetGeometryN(g3, i) # <<<<<<<<<<<<<<
- * b = _get_coords(gout)
- * p = LineString(b)
- */
- __pyx_v_gout = GEOSGetGeometryN(__pyx_v_g3, __pyx_v_i);
-
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":190
- * for i from 0 <= i < numgeoms:
- * gout = GEOSGetGeometryN(g3, i)
- * b = _get_coords(gout) # <<<<<<<<<<<<<<
- * p = LineString(b)
- * pout.append(p)
- */
- __pyx_4 = __pyx_f_8_geoslib__get_coords(__pyx_v_gout); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1;}
- Py_DECREF(__pyx_v_b);
- __pyx_v_b = __pyx_4;
- __pyx_4 = 0;
-
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":191
- * gout = GEOSGetGeometryN(g3, i)
- * b = _get_coords(gout)
- * p = LineString(b) # <<<<<<<<<<<<<<
- * pout.append(p)
+ * gout = GEOSGetGeometryN(g3, 0)
+ * b = _get_coords(gout) # <<<<<<<<<<<<<<
+ * p = LineString(b)
 * else:
 */
- __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1;}
- Py_INCREF(__pyx_v_b);
- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_b);
- __pyx_4 = PyObject_Call(((PyObject*)__pyx_ptype_8_geoslib_LineString), ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1;}
- Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
- Py_DECREF(__pyx_v_p);
- __pyx_v_p = __pyx_4;
- __pyx_4 = 0;
+ __pyx_3 = __pyx_f_8_geoslib__get_coords(__pyx_v_gout); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ Py_DECREF(__pyx_v_b);
+ __pyx_v_b = __pyx_3;
+ __pyx_3 = 0;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":192
- * b = _get_coords(gout)
- * p = LineString(b)
- * pout.append(p) # <<<<<<<<<<<<<<
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":182
+ * gout = GEOSGetGeometryN(g3, 0)
+ * b = _get_coords(gout)
+ * p = LineString(b) # <<<<<<<<<<<<<<
 * else:
 * type = PyString_FromString(GEOSGeomType(g3))
 */
- __pyx_3 = __Pyx_PyObject_Append(__pyx_v_pout, __pyx_v_p); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1;}
- Py_DECREF(__pyx_3); __pyx_3 = 0;
- }
- goto __pyx_L5;
+ __pyx_4 = PyTuple_New(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ Py_INCREF(__pyx_v_b);
+ PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_b);
+ __pyx_3 = PyObject_Call(((PyObject*)__pyx_ptype_8_geoslib_LineString), ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
+ Py_DECREF(__pyx_v_p);
+ __pyx_v_p = __pyx_3;
+ __pyx_3 = 0;
+ goto __pyx_L4;
 }
 /*else*/ {
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":194
- * pout.append(p)
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":184
+ * p = LineString(b)
 * else:
 * type = PyString_FromString(GEOSGeomType(g3)) # <<<<<<<<<<<<<<
 * raise NotImplementedError("intersections of type '%s' not yet implemented" % (type))
 * GEOSGeom_destroy(g3)
 */
- __pyx_4 = PyString_FromString(GEOSGeomType(__pyx_v_g3)); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_4 = PyString_FromString(GEOSGeomType(__pyx_v_g3)); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1;}
 Py_DECREF(__pyx_v_type);
 __pyx_v_type = __pyx_4;
 __pyx_4 = 0;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":195
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":185
 * else:
 * type = PyString_FromString(GEOSGeomType(g3))
 * raise NotImplementedError("intersections of type '%s' not yet implemented" % (type)) # <<<<<<<<<<<<<<
 * GEOSGeom_destroy(g3)
- * return pout
+ * return p
 */
- __pyx_3 = PyNumber_Remainder(__pyx_kp_5, __pyx_v_type); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1;}
- __pyx_4 = PyTuple_New(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_3 = PyNumber_Remainder(__pyx_kp_5, __pyx_v_type); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1;}
 PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
 __pyx_3 = 0;
- __pyx_3 = PyObject_Call(__pyx_builtin_NotImplementedError, ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_3 = PyObject_Call(__pyx_builtin_NotImplementedError, ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1;}
 Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
 __Pyx_Raise(__pyx_3, 0, 0);
 Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1;}
 }
- __pyx_L5:;
+ __pyx_L4:;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":196
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":186
 * type = PyString_FromString(GEOSGeomType(g3))
 * raise NotImplementedError("intersections of type '%s' not yet implemented" % (type))
 * GEOSGeom_destroy(g3) # <<<<<<<<<<<<<<
- * return pout
+ * return p
 * 
 */
 GEOSGeom_destroy(__pyx_v_g3);
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":197
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":187
 * raise NotImplementedError("intersections of type '%s' not yet implemented" % (type))
 * GEOSGeom_destroy(g3)
- * return pout # <<<<<<<<<<<<<<
+ * return p # <<<<<<<<<<<<<<
 * 
 * def intersects(self, BaseGeometry geom):
 */
- Py_INCREF(__pyx_v_pout);
- __pyx_r = __pyx_v_pout;
+ Py_INCREF(__pyx_v_p);
+ __pyx_r = __pyx_v_p;
 goto __pyx_L0;
 
 __pyx_r = Py_None; Py_INCREF(Py_None);
@@ -1289,13 +1168,12 @@
 __pyx_L0:;
 Py_DECREF(__pyx_v_b);
 Py_DECREF(__pyx_v_p);
- Py_DECREF(__pyx_v_pout);
 Py_DECREF(__pyx_v_type);
 return __pyx_r;
 }
 
-/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":199
- * return pout
+/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":189
+ * return p
 * 
 * def intersects(self, BaseGeometry geom): # <<<<<<<<<<<<<<
 * cdef GEOSGeom *g1, *g2
@@ -1309,9 +1187,9 @@
 char __pyx_v_answer;
 PyObject *__pyx_r;
 char __pyx_1;
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_geom), __pyx_ptype_8_geoslib_BaseGeometry, 1, "geom", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_geom), __pyx_ptype_8_geoslib_BaseGeometry, 1, "geom", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1;}
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":202
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":192
 * cdef GEOSGeom *g1, *g2
 * cdef char answer
 * g1 = self._geom # <<<<<<<<<<<<<<
@@ -1320,7 +1198,7 @@
 */
 __pyx_v_g1 = ((struct __pyx_obj_8_geoslib_BaseGeometry *)__pyx_v_self)->_geom;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":203
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":193
 * cdef char answer
 * g1 = self._geom
 * g2 = geom._geom # <<<<<<<<<<<<<<
@@ -1329,7 +1207,7 @@
 */
 __pyx_v_g2 = ((struct __pyx_obj_8_geoslib_BaseGeometry *)__pyx_v_geom)->_geom;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":204
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":194
 * g1 = self._geom
 * g2 = geom._geom
 * answer = GEOSIntersects(g1, g2) # <<<<<<<<<<<<<<
@@ -1338,7 +1216,7 @@
 */
 __pyx_v_answer = GEOSIntersects(__pyx_v_g1, __pyx_v_g2);
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":205
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":195
 * g2 = geom._geom
 * answer = GEOSIntersects(g1, g2)
 * if answer: # <<<<<<<<<<<<<<
@@ -1348,7 +1226,7 @@
 __pyx_1 = __pyx_v_answer;
 if (__pyx_1) {
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":206
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":196
 * answer = GEOSIntersects(g1, g2)
 * if answer:
 * return True # <<<<<<<<<<<<<<
@@ -1362,7 +1240,7 @@
 }
 /*else*/ {
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":208
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":198
 * return True
 * else:
 * return False # <<<<<<<<<<<<<<
@@ -1384,7 +1262,7 @@
 return __pyx_r;
 }
 
-/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":210
+/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":200
 * return False
 * 
 * def intersection(self, BaseGeometry geom): # <<<<<<<<<<<<<<
@@ -1392,6 +1270,10 @@
 * cdef char answer
 */
 
+static char __pyx_k_append[] = "append";
+
+static PyObject *__pyx_kp_append;
+
 static PyObject *__pyx_kp_6;
 
 static char __pyx_k_6[] = "intersections of type '%s' not yet implemented";
@@ -1417,9 +1299,9 @@
 __pyx_v_p = Py_None; Py_INCREF(Py_None);
 __pyx_v_pout = Py_None; Py_INCREF(Py_None);
 __pyx_v_type = Py_None; Py_INCREF(Py_None);
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_geom), __pyx_ptype_8_geoslib_BaseGeometry, 1, "geom", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_geom), __pyx_ptype_8_geoslib_BaseGeometry, 1, "geom", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L1;}
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":214
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":204
 * cdef char answer
 * cdef int numgeoms, i, typeid
 * g1 = self._geom # <<<<<<<<<<<<<<
@@ -1428,7 +1310,7 @@
 */
 __pyx_v_g1 = ((struct __pyx_obj_8_geoslib_BaseGeometry *)__pyx_v_self)->_geom;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":215
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":205
 * cdef int numgeoms, i, typeid
 * g1 = self._geom
 * g2 = geom._geom # <<<<<<<<<<<<<<
@@ -1437,7 +1319,7 @@
 */
 __pyx_v_g2 = ((struct __pyx_obj_8_geoslib_BaseGeometry *)__pyx_v_geom)->_geom;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":216
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":206
 * g1 = self._geom
 * g2 = geom._geom
 * g3 = GEOSIntersection(g1, g2) # <<<<<<<<<<<<<<
@@ -1446,7 +1328,7 @@
 */
 __pyx_v_g3 = GEOSIntersection(__pyx_v_g1, __pyx_v_g2);
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":217
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":207
 * g2 = geom._geom
 * g3 = GEOSIntersection(g1, g2)
 * typeid = GEOSGeomTypeId(g3) # <<<<<<<<<<<<<<
@@ -1455,7 +1337,7 @@
 */
 __pyx_v_typeid = GEOSGeomTypeId(__pyx_v_g3);
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":218
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":208
 * g3 = GEOSIntersection(g1, g2)
 * typeid = GEOSGeomTypeId(g3)
 * if typeid == GEOS_POLYGON: # <<<<<<<<<<<<<<
@@ -1465,42 +1347,42 @@
 __pyx_1 = (__pyx_v_typeid == GEOS_POLYGON);
 if (__pyx_1) {
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":219
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":209
 * typeid = GEOSGeomTypeId(g3)
 * if typeid == GEOS_POLYGON:
 * b = _get_coords(g3) # <<<<<<<<<<<<<<
 * p = Polygon(b)
 * pout = [p]
 */
- __pyx_2 = __pyx_f_8_geoslib__get_coords(__pyx_v_g3); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_2 = __pyx_f_8_geoslib__get_coords(__pyx_v_g3); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1;}
 Py_DECREF(__pyx_v_b);
 __pyx_v_b = __pyx_2;
 __pyx_2 = 0;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":220
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":210
 * if typeid == GEOS_POLYGON:
 * b = _get_coords(g3)
 * p = Polygon(b) # <<<<<<<<<<<<<<
 * pout = [p]
 * elif typeid == GEOS_LINESTRING:
 */
- __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1;}
 Py_INCREF(__pyx_v_b);
 PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_b);
- __pyx_3 = PyObject_Call(((PyObject*)__pyx_ptype_8_geoslib_Polygon), ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_3 = PyObject_Call(((PyObject*)__pyx_ptype_8_geoslib_Polygon), ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1;}
 Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
 Py_DECREF(__pyx_v_p);
 __pyx_v_p = __pyx_3;
 __pyx_3 = 0;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":221
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":211
 * b = _get_coords(g3)
 * p = Polygon(b)
 * pout = [p] # <<<<<<<<<<<<<<
 * elif typeid == GEOS_LINESTRING:
 * b = _get_coords(g3)
 */
- __pyx_2 = PyList_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_2 = PyList_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1;}
 Py_INCREF(__pyx_v_p);
 PyList_SET_ITEM(__pyx_2, 0, __pyx_v_p);
 Py_DECREF(__pyx_v_pout);
@@ -1509,7 +1391,7 @@
 goto __pyx_L4;
 }
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":222
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":212
 * p = Polygon(b)
 * pout = [p]
 * elif typeid == GEOS_LINESTRING: # <<<<<<<<<<<<<<
@@ -1519,42 +1401,42 @@
 __pyx_1 = (__pyx_v_typeid == GEOS_LINESTRING);
 if (__pyx_1) {
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":223
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":213
 * pout = [p]
 * elif typeid == GEOS_LINESTRING:
 * b = _get_coords(g3) # <<<<<<<<<<<<<<
 * p = LineString(b)
 * pout = [p]
 */
- __pyx_3 = __pyx_f_8_geoslib__get_coords(__pyx_v_g3); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_3 = __pyx_f_8_geoslib__get_coords(__pyx_v_g3); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1;}
 Py_DECREF(__pyx_v_b);
 __pyx_v_b = __pyx_3;
 __pyx_3 = 0;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":224
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":214
 * elif typeid == GEOS_LINESTRING:
 * b = _get_coords(g3)
 * p = LineString(b) # <<<<<<<<<<<<<<
 * pout = [p]
 * elif typeid == GEOS_MULTIPOLYGON:
 */
- __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1;}
 Py_INCREF(__pyx_v_b);
 PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_b);
- __pyx_3 = PyObject_Call(((PyObject*)__pyx_ptype_8_geoslib_LineString), ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_3 = PyObject_Call(((PyObject*)__pyx_ptype_8_geoslib_LineString), ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1;}
 Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
 Py_DECREF(__pyx_v_p);
 __pyx_v_p = __pyx_3;
 __pyx_3 = 0;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":225
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":215
 * b = _get_coords(g3)
 * p = LineString(b)
 * pout = [p] # <<<<<<<<<<<<<<
 * elif typeid == GEOS_MULTIPOLYGON:
 * numgeoms = GEOSGetNumGeometries(g3)
 */
- __pyx_2 = PyList_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_2 = PyList_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1;}
 Py_INCREF(__pyx_v_p);
 PyList_SET_ITEM(__pyx_2, 0, __pyx_v_p);
 Py_DECREF(__pyx_v_pout);
@@ -1563,7 +1445,7 @@
 goto __pyx_L4;
 }
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":226
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":216
 * p = LineString(b)
 * pout = [p]
 * elif typeid == GEOS_MULTIPOLYGON: # <<<<<<<<<<<<<<
@@ -1573,7 +1455,7 @@
 __pyx_1 = (__pyx_v_typeid == GEOS_MULTIPOLYGON);
 if (__pyx_1) {
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":227
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":217
 * pout = [p]
 * elif typeid == GEOS_MULTIPOLYGON:
 * numgeoms = GEOSGetNumGeometries(g3) # <<<<<<<<<<<<<<
@@ -1582,19 +1464,19 @@
 */
 __pyx_v_numgeoms = GEOSGetNumGeometries(__pyx_v_g3);
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":228
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":218
 * elif typeid == GEOS_MULTIPOLYGON:
 * numgeoms = GEOSGetNumGeometries(g3)
 * pout = [] # <<<<<<<<<<<<<<
 * for i from 0 <= i < numgeoms:
 * gout = GEOSGetGeometryN(g3, i)
 */
- __pyx_3 = PyList_New(0); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_3 = PyList_New(0); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1;}
 Py_DECREF(__pyx_v_pout);
 __pyx_v_pout = ((PyObject *)__pyx_3);
 __pyx_3 = 0;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":229
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":219
 * numgeoms = GEOSGetNumGeometries(g3)
 * pout = []
 * for i from 0 <= i < numgeoms: # <<<<<<<<<<<<<<
@@ -1603,7 +1485,7 @@
 */
 for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_numgeoms; __pyx_v_i++) {
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":230
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":220
 * pout = []
 * for i from 0 <= i < numgeoms:
 * gout = GEOSGetGeometryN(g3, i) # <<<<<<<<<<<<<<
@@ -1612,48 +1494,48 @@
 */
 __pyx_v_gout = GEOSGetGeometryN(__pyx_v_g3, __pyx_v_i);
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":231
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":221
 * for i from 0 <= i < numgeoms:
 * gout = GEOSGetGeometryN(g3, i)
 * b = _get_coords(gout) # <<<<<<<<<<<<<<
 * p = Polygon(b)
 * pout.append(p)
 */
- __pyx_2 = __pyx_f_8_geoslib__get_coords(__pyx_v_gout); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_2 = __pyx_f_8_geoslib__get_coords(__pyx_v_gout); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1;}
 Py_DECREF(__pyx_v_b);
 __pyx_v_b = __pyx_2;
 __pyx_2 = 0;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":232
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":222
 * gout = GEOSGetGeometryN(g3, i)
 * b = _get_coords(gout)
 * p = Polygon(b) # <<<<<<<<<<<<<<
 * pout.append(p)
 * elif typeid == GEOS_MULTILINESTRING:
 */
- __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1;}
 Py_INCREF(__pyx_v_b);
 PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_b);
- __pyx_2 = PyObject_Call(((PyObject*)__pyx_ptype_8_geoslib_Polygon), ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_2 = PyObject_Call(((PyObject*)__pyx_ptype_8_geoslib_Polygon), ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1;}
 Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
 Py_DECREF(__pyx_v_p);
 __pyx_v_p = __pyx_2;
 __pyx_2 = 0;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":233
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":223
 * b = _get_coords(gout)
 * p = Polygon(b)
 * pout.append(p) # <<<<<<<<<<<<<<
 * elif typeid == GEOS_MULTILINESTRING:
 * numgeoms = GEOSGetNumGeometries(g3)
 */
- __pyx_3 = __Pyx_PyObject_Append(__pyx_v_pout, __pyx_v_p); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_3 = __Pyx_PyObject_Append(__pyx_v_pout, __pyx_v_p); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1;}
 Py_DECREF(__pyx_3); __pyx_3 = 0;
 }
 goto __pyx_L4;
 }
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":234
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":224
 * p = Polygon(b)
 * pout.append(p)
 * elif typeid == GEOS_MULTILINESTRING: # <<<<<<<<<<<<<<
@@ -1663,7 +1545,7 @@
 __pyx_1 = (__pyx_v_typeid == GEOS_MULTILINESTRING);
 if (__pyx_1) {
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":235
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":225
 * pout.append(p)
 * elif typeid == GEOS_MULTILINESTRING:
 * numgeoms = GEOSGetNumGeometries(g3) # <<<<<<<<<<<<<<
@@ -1672,19 +1554,19 @@
 */
 __pyx_v_numgeoms = GEOSGetNumGeometries(__pyx_v_g3);
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":236
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":226
 * elif typeid == GEOS_MULTILINESTRING:
 * numgeoms = GEOSGetNumGeometries(g3)
 * pout = [] # <<<<<<<<<<<<<<
 * for i from 0 <= i < numgeoms:
 * gout = GEOSGetGeometryN(g3, i)
 */
- __pyx_2 = PyList_New(0); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_2 = PyList_New(0); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1;}
 Py_DECREF(__pyx_v_pout);
 __pyx_v_pout = ((PyObject *)__pyx_2);
 __pyx_2 = 0;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":237
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":227
 * numgeoms = GEOSGetNumGeometries(g3)
 * pout = []
 * for i from 0 <= i < numgeoms: # <<<<<<<<<<<<<<
@@ -1693,7 +1575,7 @@
 */
 for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_numgeoms; __pyx_v_i++) {
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":238
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":228
 * pout = []
 * for i from 0 <= i < numgeoms:
 * gout = GEOSGetGeometryN(g3, i) # <<<<<<<<<<<<<<
@@ -1702,80 +1584,80 @@
 */
 __pyx_v_gout = GEOSGetGeometryN(__pyx_v_g3, __pyx_v_i);
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":239
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":229
 * for i from 0 <= i < numgeoms:
 * gout = GEOSGetGeometryN(g3, i)
 * b = _get_coords(gout) # <<<<<<<<<<<<<<
 * p = LineString(b)
 * pout.append(p)
 */
- __pyx_3 = __pyx_f_8_geoslib__get_coords(__pyx_v_gout); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_3 = __pyx_f_8_geoslib__get_coords(__pyx_v_gout); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1;}
 Py_DECREF(__pyx_v_b);
 __pyx_v_b = __pyx_3;
 __pyx_3 = 0;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":240
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":230
 * gout = GEOSGetGeometryN(g3, i)
 * b = _get_coords(gout)
 * p = LineString(b) # <<<<<<<<<<<<<<
 * pout.append(p)
 * else:
 */
- __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1;}
 Py_INCREF(__pyx_v_b);
 PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_b);
- __pyx_3 = PyObject_Call(((PyObject*)__pyx_ptype_8_geoslib_LineString), ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_3 = PyObject_Call(((PyObject*)__pyx_ptype_8_geoslib_LineString), ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1;}
 Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
 Py_DECREF(__pyx_v_p);
 __pyx_v_p = __pyx_3;
 __pyx_3 = 0;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":241
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":231
 * b = _get_coords(gout)
 * p = LineString(b)
 * pout.append(p) # <<<<<<<<<<<<<<
 * else:
 * type = PyString_FromString(GEOSGeomType(g3))
 */
- __pyx_2 = __Pyx_PyObject_Append(__pyx_v_pout, __pyx_v_p); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_2 = __Pyx_PyObject_Append(__pyx_v_pout, __pyx_v_p); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1;}
 Py_DECREF(__pyx_2); __pyx_2 = 0;
 }
 goto __pyx_L4;
 }
 /*else*/ {
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":243
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":233
 * pout.append(p)
 * else:
 * type = PyString_FromString(GEOSGeomType(g3)) # <<<<<<<<<<<<<<
 * raise NotImplementedError("intersections of type '%s' not yet implemented" % (type))
 * GEOSGeom_destroy(g3)
 */
- __pyx_3 = PyString_FromString(GEOSGeomType(__pyx_v_g3)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_3 = PyString_FromString(GEOSGeomType(__pyx_v_g3)); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1;}
 Py_DECREF(__pyx_v_type);
 __pyx_v_type = __pyx_3;
 __pyx_3 = 0;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":244
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":234
 * else:
 * type = PyString_FromString(GEOSGeomType(g3))
 * raise NotImplementedError("intersections of type '%s' not yet implemented" % (type)) # <<<<<<<<<<<<<<
 * GEOSGeom_destroy(g3)
 * return pout
 */
- __pyx_2 = PyNumber_Remainder(__pyx_kp_6, __pyx_v_type); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1;}
- __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_2 = PyNumber_Remainder(__pyx_kp_6, __pyx_v_type); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1;}
 PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
 __pyx_2 = 0;
- __pyx_2 = PyObject_Call(__pyx_builtin_NotImplementedError, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_2 = PyObject_Call(__pyx_builtin_NotImplementedError, ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1;}
 Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
 __Pyx_Raise(__pyx_2, 0, 0);
 Py_DECREF(__pyx_2); __pyx_2 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1;}
 }
 __pyx_L4:;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":245
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":235
 * type = PyString_FromString(GEOSGeomType(g3))
 * raise NotImplementedError("intersections of type '%s' not yet implemented" % (type))
 * GEOSGeom_destroy(g3) # <<<<<<<<<<<<<<
@@ -1784,7 +1666,7 @@
 */
 GEOSGeom_destroy(__pyx_v_g3);
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":246
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":236
 * raise NotImplementedError("intersections of type '%s' not yet implemented" % (type))
 * GEOSGeom_destroy(g3)
 * return pout # <<<<<<<<<<<<<<
@@ -1810,7 +1692,7 @@
 return __pyx_r;
 }
 
-/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":248
+/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":238
 * return pout
 * 
 * def get_coords(self): # <<<<<<<<<<<<<<
@@ -1823,14 +1705,14 @@
 PyObject *__pyx_r;
 PyObject *__pyx_1 = 0;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":249
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":239
 * 
 * def get_coords(self):
 * return _get_coords(self._geom) # <<<<<<<<<<<<<<
 * 
 * def __dealloc__(self):
 */
- __pyx_1 = __pyx_f_8_geoslib__get_coords(((struct __pyx_obj_8_geoslib_BaseGeometry *)__pyx_v_self)->_geom); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_1 = __pyx_f_8_geoslib__get_coords(((struct __pyx_obj_8_geoslib_BaseGeometry *)__pyx_v_self)->_geom); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1;}
 __pyx_r = __pyx_1;
 __pyx_1 = 0;
 goto __pyx_L0;
@@ -1845,7 +1727,7 @@
 return __pyx_r;
 }
 
-/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":251
+/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":241
 * return _get_coords(self._geom)
 * 
 * def __dealloc__(self): # <<<<<<<<<<<<<<
@@ -1857,7 +1739,7 @@
 static char __pyx_doc_8_geoslib_12BaseGeometry___dealloc__[] = "destroy GEOS geometry";
 static void __pyx_pf_8_geoslib_12BaseGeometry___dealloc__(PyObject *__pyx_v_self) {
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":253
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":243
 * def __dealloc__(self):
 * """destroy GEOS geometry"""
 * GEOSGeom_destroy(self._geom) # <<<<<<<<<<<<<<
@@ -1868,7 +1750,7 @@
 
 }
 
-/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":255
+/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":245
 * GEOSGeom_destroy(self._geom)
 * 
 * def __reduce__(self): # <<<<<<<<<<<<<<
@@ -1888,18 +1770,18 @@
 PyObject *__pyx_2 = 0;
 PyObject *__pyx_3 = 0;
 
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":257
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":247
 * def __reduce__(self):
 * """special method that allows geos instance to be pickled"""
 * return (self.__class__,(self.boundary,)) # <<<<<<<<<<<<<<
 * 
 * cdef class Polygon(BaseGeometry):
 */
- __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_kp___class__); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0];...
 
[truncated message content]
From: <js...@us...> - 2008年08月09日 14:49:45
Revision: 6012
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6012&view=rev
Author: jswhit
Date: 2008年08月09日 14:49:42 +0000 (2008年8月09日)
Log Message:
-----------
print proj4string attribute.
Modified Paths:
--------------
 trunk/toolkits/basemap/examples/test.py
Modified: trunk/toolkits/basemap/examples/test.py
===================================================================
--- trunk/toolkits/basemap/examples/test.py	2008年08月09日 12:58:30 UTC (rev 6011)
+++ trunk/toolkits/basemap/examples/test.py	2008年08月09日 14:49:42 UTC (rev 6012)
@@ -51,7 +51,7 @@
 m.drawmeridians(meridians,labels=[1,0,0,1])
 plt.title('Cylindrical Equidistant')
 print 'plotting Cylindrical Equidistant example ...'
-print m.srs
+print m.proj4string
 
 # create new figure
 fig=plt.figure()
@@ -71,7 +71,7 @@
 m.drawmeridians(meridians,labels=[1,1,1,1])
 plt.title('Miller Cylindrical',y=1.1)
 print 'plotting Miller Cylindrical example ...'
-print m.srs
+print m.proj4string
 
 # create new figure
 fig=plt.figure()
@@ -95,7 +95,7 @@
 m.drawmeridians(meridians,labels=[1,1,1,1])
 plt.title('Mercator',y=1.1)
 print 'plotting Mercator example ...'
-print m.srs
+print m.proj4string
 
 # create new figure
 fig=plt.figure()
@@ -127,7 +127,7 @@
 m.drawmeridians(meridians,labels=[1,0,0,1],fontsize=10)
 plt.title('Cassini-Soldner Projection')
 print 'plotting Cassini-Soldner example ...'
-print m.srs
+print m.proj4string
 
 # create new figure
 fig=plt.figure()
@@ -160,7 +160,7 @@
 m.drawmeridians(meridians,labels=[1,0,0,1],fontsize=10)
 plt.title('Gnomonic Projection')
 print 'plotting Gnomonic example ...'
-print m.srs
+print m.proj4string
 
 # create new figure
 fig=plt.figure()
@@ -192,7 +192,7 @@
 m.drawmeridians(meridians,labels=[1,0,0,0],fontsize=10)
 plt.title('Transverse Mercator Projection')
 print 'plotting Transverse Mercator example ...'
-print m.srs
+print m.proj4string
 
 # create new figure
 fig=plt.figure()
@@ -221,7 +221,7 @@
 m.drawmeridians(np.arange(-180,181,30),labels=[0,0,0,1],fontsize=10)
 plt.title('Oblique Mercator Projection')
 print 'plotting Oblique Mercator example ...'
-print m.srs
+print m.proj4string
 
 # create new figure
 fig=plt.figure()
@@ -254,7 +254,7 @@
 m.drawmeridians(meridians,labels=[1,0,0,1],fontsize=10)
 plt.title('Polyconic Projection')
 print 'plotting Polyconic example ...'
-print m.srs
+print m.proj4string
 
 # create new figure
 fig=plt.figure()
@@ -287,7 +287,7 @@
 m.drawmeridians(meridians,labels=[0,0,0,1])
 plt.title('Equidistant Conic')
 print 'plotting Equidistant Conic example ...'
-print m.srs
+print m.proj4string
 
 # create new figure
 fig=plt.figure()
@@ -321,7 +321,7 @@
 m.drawmeridians(meridians,labels=[1,1,0,1])
 plt.title('Lambert Conformal Conic')
 print 'plotting Lambert Conformal example ...'
-print m.srs
+print m.proj4string
 
 # create new figure
 fig=plt.figure()
@@ -354,7 +354,7 @@
 m.drawmeridians(meridians,labels=[1,1,1,1])
 plt.title('Albers Equal Area Conic',y=1.075)
 print 'plotting Albers Equal Area example ...'
-print m.srs
+print m.proj4string
 
 # create new figure
 fig=plt.figure()
@@ -385,7 +385,7 @@
 m.drawmeridians(meridians,labels=[1,1,1,1])
 plt.title('Polar Stereographic',y=1.075)
 print 'plotting Stereographic example ...'
-print m.srs
+print m.proj4string
 
 # create new figure
 fig=plt.figure()
@@ -417,7 +417,7 @@
 m.drawmeridians(meridians,labels=[1,1,1,1])
 plt.title('Lambert Azimuthal Equal Area',y=1.075)
 print 'plotting Lambert Azimuthal example ...'
-print m.srs
+print m.proj4string
 
 # create new figure
 fig=plt.figure()
@@ -449,7 +449,7 @@
 m.drawmeridians(meridians,labels=[1,1,1,1])
 plt.title('Azimuthal Equidistant',y=1.075)
 print 'plotting Azimuthal Equidistant example ...'
-print m.srs
+print m.proj4string
 
 # projections with elliptical boundaries (orthographic, sinusoidal,
 # mollweide and robinson)
@@ -492,7 +492,7 @@
 m.drawmapboundary()
 plt.title('Orthographic')
 print 'plotting Orthographic example ...'
-print m.srs
+print m.proj4string
 
 # create new figure
 fig=plt.figure()
@@ -533,7 +533,7 @@
 m.drawmapboundary()
 plt.title('Geostationary')
 print 'plotting Geostationary example ...'
-print m.srs
+print m.proj4string
 
 # create new figure
 fig=plt.figure()
@@ -560,7 +560,7 @@
 m.drawmapboundary()
 plt.title('Sinusoidal')
 print 'plotting Sinusoidal example ...'
-print m.srs
+print m.proj4string
 
 # create new figure
 fig=plt.figure()
@@ -587,7 +587,7 @@
 m.drawmapboundary()
 plt.title('Mollweide')
 print 'plotting Mollweide example ...'
-print m.srs
+print m.proj4string
 
 # create new figure
 fig=plt.figure()
@@ -614,7 +614,7 @@
 m.drawmapboundary()
 plt.title('Robinson')
 print 'plotting Robinson example ...'
-print m.srs
+print m.proj4string
 plt.show()
 
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <js...@us...> - 2008年08月09日 12:58:33
Revision: 6011
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6011&view=rev
Author: jswhit
Date: 2008年08月09日 12:58:30 +0000 (2008年8月09日)
Log Message:
-----------
update to pupynere 1.0.2
Modified Paths:
--------------
 trunk/toolkits/basemap/Changelog
Modified: trunk/toolkits/basemap/Changelog
===================================================================
--- trunk/toolkits/basemap/Changelog	2008年08月09日 12:57:54 UTC (rev 6010)
+++ trunk/toolkits/basemap/Changelog	2008年08月09日 12:58:30 UTC (rev 6011)
@@ -1,5 +1,5 @@
 version 0.99.2 (not yet released)
- * updated NetCDFFile to use pupynere 1.0.1 (now can write as well
+ * updated NetCDFFile to use pupynere 1.0.2 (now can write as well
 as read!).
 * now works with geos version 3.
 * added "proj4string" Basemap instance variable.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6010
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6010&view=rev
Author: jswhit
Date: 2008年08月09日 12:57:54 +0000 (2008年8月09日)
Log Message:
-----------
update to pupynere 1.0.2
Modified Paths:
--------------
 trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
 trunk/toolkits/basemap/lib/mpl_toolkits/basemap/netcdf.py
 trunk/toolkits/basemap/lib/mpl_toolkits/basemap/pupynere.py
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py	2008年08月08日 20:52:12 UTC (rev 6009)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py	2008年08月09日 12:57:54 UTC (rev 6010)
@@ -3641,19 +3641,25 @@
 return corners
 
 def NetCDFFile(file, mode='r', maskandscale=True):
- """NetCDF File reader. API is the same as Scientific.IO.NetCDF.
+ """NetCDF File reader/writer. API is the same as Scientific.IO.NetCDF.
+
 If ``file`` is a URL that starts with `http`, it is assumed
- to be a remote OPenDAP dataset, and the python dap client is used
+ to be a remote OPenDAP dataset, and pydap is used
 to retrieve the data. Only the OPenDAP Array and Grid data
 types are recognized. If file does not start with `http`, it
- is assumed to be a local netCDF file. Data will
- automatically be converted to masked arrays if the variable has either
- a ``missing_value`` or ``_FillValue`` attribute, and some data points
- are equal to the value specified by that attribute. In addition,
- variables stored as integers that have the ``scale_factor`` and
- ``add_offset`` attribute will automatically be rescaled to floats when
- read. To suppress these automatic conversions, set the
- ``maskandscale`` keyword to False. 
+ is assumed to be a local netCDF file and is read
+ with scipy.io.netcdf. Both pydap and scipy.io.netcdf are written
+ by Roberto De Almeida.
+
+ Data will
+ automatically be converted to and from masked arrays if the variable
+ has either a ``missing_value`` or ``_FillValue`` attribute, and
+ some data points are equal to the value specified by that attribute.
+ In addition, variables that have the ``scale_factor`` and ``add_offset``
+ attribute will automatically be converted to and from short integers.
+ To suppress these automatic conversions, set the ``maskandscale``
+ keyword to False. 
+
 """
 if file.startswith('http'):
 return netcdf._RemoteFile(file,maskandscale=maskandscale)
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/netcdf.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/netcdf.py	2008年08月08日 20:52:12 UTC (rev 6009)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/netcdf.py	2008年08月09日 12:57:54 UTC (rev 6010)
@@ -1,5 +1,5 @@
 from numpy import ma, squeeze
-from pupynere import netcdf_file, _maskandscale
+from pupynere import netcdf_file, _unmaskandscale
 from dap.client import open as open_remote
 from dap.dtypes import ArrayType, GridType, typemap
 
@@ -68,7 +68,7 @@
 # - create a masked array using missing_value or _FillValue attribute
 # - apply scale_factor and add_offset to packed integer data
 if self._maskandscale:
- return _maskandscale(self,datout)
+ return _unmaskandscale(self,datout)
 else:
 return datout
 
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/pupynere.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/pupynere.py	2008年08月08日 20:52:12 UTC (rev 6009)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/pupynere.py	2008年08月09日 12:57:54 UTC (rev 6010)
@@ -128,9 +128,7 @@
 
 """
 def __init__(self, filename, mode='r', maskandscale=False):
-
 self._maskandscale = maskandscale
-
 self.filename = filename
 
 assert mode in 'rw', "Mode must be either 'r' or 'w'."
@@ -181,7 +179,7 @@
 if size > 1: dtype_ += str(size)
 
 data = empty(shape_, dtype=dtype_)
- self.variables[name] = netcdf_variable(data, typecode, shape, dimensions)
+ self.variables[name] = netcdf_variable(data, typecode, shape, dimensions, maskandscale=self._maskandscale)
 return self.variables[name]
 
 def flush(self):
@@ -204,7 +202,7 @@
 def _write_numrecs(self):
 # Get highest record count from all record variables.
 for var in self.variables.values():
- if not var.shape[0] and len(var.data) > self._recs:
+ if not var._shape[0] and len(var.data) > self._recs:
 self.__dict__['_recs'] = len(var.data)
 self._pack_int(self._recs)
 
@@ -238,7 +236,7 @@
 
 # Sort variables non-recs first, then recs.
 variables = self.variables.items()
- variables.sort(key=lambda (k, v): v.shape and v.shape[0] is not None)
+ variables.sort(key=lambda (k, v): v._shape and v._shape[0] is not None)
 variables.reverse()
 variables = [k for (k, v) in variables]
 
@@ -249,7 +247,7 @@
 # each record variable, so we can calculate recsize.
 self.__dict__['_recsize'] = sum([
 var._vsize for var in self.variables.values()
- if var.shape[0] is None])
+ if var._shape[0] is None])
 # Set the data for all variables.
 for name in variables:
 self._write_var_data(name)
@@ -270,13 +268,13 @@
 nc_type = REVERSE[var.typecode()]
 self.fp.write(nc_type)
 
- if var.shape[0]:
+ if var._shape[0]:
 vsize = var.data.size * var.data.itemsize
 vsize += -vsize % 4
 else: # record variable
 vsize = var.data[0].size * var.data.itemsize
 rec_vars = len([var for var in self.variables.values()
- if var.shape[0] is None])
+ if var._shape[0] is None])
 if rec_vars > 1:
 vsize += -vsize % 4
 self.variables[name].__dict__['_vsize'] = vsize
@@ -296,7 +294,7 @@
 self.fp.seek(the_beguine)
 
 # Write data.
- if var.shape[0]:
+ if var._shape[0]:
 self.fp.write(var.data.tostring()) 
 count = var.data.size * var.data.itemsize
 self.fp.write('0' * (var._vsize - count))
@@ -413,7 +411,7 @@
 
 # Add variable.
 self.variables[name] = netcdf_variable(
- data, typecode, shape, dimensions, attributes)
+ data, typecode, shape, dimensions, attributes, maskandscale=self._maskandscale)
 
 if rec_vars:
 # Remove padding when only one record variable.
@@ -527,7 +525,7 @@
 attribute of the ``netcdf_variable`` object.
 
 """
- def __init__(self, data, typecode, shape, dimensions, attributes=None, maskandscale=True):
+ def __init__(self, data, typecode, shape, dimensions, attributes=None, maskandscale=False):
 self.data = data
 self._typecode = typecode
 self._shape = shape
@@ -561,13 +559,15 @@
 return self._typecode
 
 def __getitem__(self, index):
- datout = squeeze(self.data[index])
+ data = squeeze(self.data[index])
 if self._maskandscale:
- return _maskandscale(self,datout)
+ return _unmaskandscale(self,data)
 else:
- return datout
+ return data
 
 def __setitem__(self, index, data):
+ if self._maskandscale:
+ data = _maskandscale(self,data)
 # Expand data for record vars?
 if not self._shape[0]:
 if isinstance(index, tuple):
@@ -600,24 +600,55 @@
 'q':-2147483647L,
 'f':9.9692099683868690e+36,
 'd':9.9692099683868690e+36}
-def _maskandscale(var,datout):
- totalmask = zeros(datout.shape,bool)
- fillval = None
- if hasattr(var, 'missing_value') and (datout == var.missing_value).any():
- fillval = var.missing_value
- totalmask += datout==fillval
- if hasattr(var, '_FillValue') and (datout == var._FillValue).any():
- if fillval is None:
+def _unmaskandscale(var,data):
+ # if _maskandscale mode set to True, perform
+ # automatic unpacking using scale_factor/add_offset
+ # and automatic conversion to masked array using
+ # missing_value/_Fill_Value.
+ totalmask = zeros(data.shape, bool)
+ fill_value = None
+ if hasattr(var, 'missing_value') and (data == var.missing_value).any():
+ mask=data==var.missing_value
+ fill_value = var.missing_value
+ totalmask += mask
+ if hasattr(var, '_FillValue') and (data == var._FillValue).any():
+ mask=data==var._FillValue
+ if fill_value is None:
+ fill_value = var._FillValue
+ totalmask += mask
+ else:
+ fillval = _default_fillvals[var.typecode()]
+ if (data == fillval).any():
+ mask=data==fillval
+ if fill_value is None:
+ fill_value = fillval
+ totalmask += mask
+ # all values where data == missing_value or _FillValue are
+ # masked. fill_value set to missing_value if it exists,
+ # otherwise _FillValue.
+ if fill_value is not None:
+ data = ma.masked_array(data,mask=totalmask,fill_value=fill_value)
+ # if variable has scale_factor and add_offset attributes, rescale.
+ if hasattr(var, 'scale_factor') and hasattr(var, 'add_offset'):
+ data = var.scale_factor*data + var.add_offset
+ return data
+
+def _maskandscale(var,data):
+ # if _maskandscale mode set to True, perform
+ # automatic packing using scale_factor/add_offset
+ # and automatic filling of masked arrays using
+ # missing_value/_Fill_Value.
+ # use missing_value as fill value.
+ # if no missing value set, use _FillValue.
+ if hasattr(data,'mask'):
+ if hasattr(var, 'missing_value'):
+ fillval = var.missing_value
+ elif hasattr(var, '_FillValue'):
 fillval = var._FillValue
- totalmask += datout==var._FillValue
- elif (datout == _default_fillvals[var.typecode()]).any():
- if fillval is None:
+ else:
 fillval = _default_fillvals[var.typecode()]
- totalmask += datout==_default_fillvals[var.dtype]
- if fillval is not None:
- datout = ma.masked_array(datout,mask=totalmask,fill_value=fillval)
- try:
- datout = var.scale_factor*datout + var.add_offset
- except:
- pass
- return datout
+ data = data.filled(fill_value=fillval)
+ # pack using scale_factor and add_offset.
+ if hasattr(var, 'scale_factor') and hasattr(var, 'add_offset'):
+ data = (data - var.add_offset)/var.scale_factor
+ return data
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <js...@us...> - 2008年08月08日 20:52:14
Revision: 6009
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6009&view=rev
Author: jswhit
Date: 2008年08月08日 20:52:12 +0000 (2008年8月08日)
Log Message:
-----------
updated pupynere
Modified Paths:
--------------
 trunk/toolkits/basemap/Changelog
Modified: trunk/toolkits/basemap/Changelog
===================================================================
--- trunk/toolkits/basemap/Changelog	2008年08月08日 20:23:52 UTC (rev 6008)
+++ trunk/toolkits/basemap/Changelog	2008年08月08日 20:52:12 UTC (rev 6009)
@@ -1,4 +1,6 @@
 version 0.99.2 (not yet released)
+ * updated NetCDFFile to use pupynere 1.0.1 (now can write as well
+ as read!).
 * now works with geos version 3.
 * added "proj4string" Basemap instance variable.
 * testgdal example now uses gdal to read topo data from a raster
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <js...@us...> - 2008年08月08日 20:23:57
Revision: 6008
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6008&view=rev
Author: jswhit
Date: 2008年08月08日 20:23:52 +0000 (2008年8月08日)
Log Message:
-----------
split contents of pupynere.py into two files (netcdf.py and pupynere.py)
Modified Paths:
--------------
 trunk/toolkits/basemap/MANIFEST.in
Modified: trunk/toolkits/basemap/MANIFEST.in
===================================================================
--- trunk/toolkits/basemap/MANIFEST.in	2008年08月08日 20:22:50 UTC (rev 6007)
+++ trunk/toolkits/basemap/MANIFEST.in	2008年08月08日 20:23:52 UTC (rev 6008)
@@ -72,6 +72,7 @@
 include lib/mpl_toolkits/basemap/proj.py
 include lib/mpl_toolkits/basemap/pyproj.py
 include lib/mpl_toolkits/basemap/cm.py
+include lib/mpl_toolkits/basemap/netcdf.py
 include lib/mpl_toolkits/basemap/pupynere.py
 include lib/mpl_toolkits/basemap/netcdftime.py
 include pyshapelib/README pyshapelib/COPYING pyshapelib/ChangeLog pyshapelib/NEWS
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6007
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6007&view=rev
Author: jswhit
Date: 2008年08月08日 20:22:50 +0000 (2008年8月08日)
Log Message:
-----------
update pupynere to 1.0.1
Modified Paths:
--------------
 trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
 trunk/toolkits/basemap/lib/mpl_toolkits/basemap/pupynere.py
Added Paths:
-----------
 trunk/toolkits/basemap/lib/mpl_toolkits/basemap/netcdf.py
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py	2008年08月08日 12:19:47 UTC (rev 6006)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py	2008年08月08日 20:22:50 UTC (rev 6007)
@@ -36,7 +36,7 @@
 import numpy as np
 import numpy.ma as ma
 from shapelib import ShapeFile
-import _geoslib, pupynere, netcdftime
+import _geoslib, netcdf, netcdftime
 
 # basemap data files now installed in lib/matplotlib/toolkits/basemap/data
 basemap_datadir = os.sep.join([os.path.dirname(__file__), 'data'])
@@ -3640,7 +3640,7 @@
 else:
 return corners
 
-def NetCDFFile(file, maskandscale=True):
+def NetCDFFile(file, mode='r', maskandscale=True):
 """NetCDF File reader. API is the same as Scientific.IO.NetCDF.
 If ``file`` is a URL that starts with `http`, it is assumed
 to be a remote OPenDAP dataset, and the python dap client is used
@@ -3656,9 +3656,9 @@
 ``maskandscale`` keyword to False. 
 """
 if file.startswith('http'):
- return pupynere._RemoteFile(file,maskandscale)
+ return netcdf._RemoteFile(file,maskandscale=maskandscale)
 else:
- return pupynere._LocalFile(file,maskandscale)
+ return netcdf.netcdf_file(file,mode=mode,maskandscale=maskandscale)
 
 def num2date(times,units='days since 0001年01月01日 00:00:00',calendar='proleptic_gregorian'):
 """
Added: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/netcdf.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/netcdf.py	 (rev 0)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/netcdf.py	2008年08月08日 20:22:50 UTC (rev 6007)
@@ -0,0 +1,76 @@
+from numpy import ma, squeeze
+from pupynere import netcdf_file, _maskandscale
+from dap.client import open as open_remote
+from dap.dtypes import ArrayType, GridType, typemap
+
+_typecodes = dict([[_v,_k] for _k,_v in typemap.items()])
+
+class _RemoteFile(object):
+ """A NetCDF file reader. API is the same as Scientific.IO.NetCDF."""
+
+ def __init__(self, file, maskandscale=False):
+ self._buffer = open_remote(file)
+ self._maskandscale = maskandscale
+ self._parse()
+
+ def read(self, size=-1):
+ """Alias for reading the file buffer."""
+ return self._buffer.read(size)
+
+ def _parse(self):
+ """Initial parsing of the header."""
+ # Read header info.
+ self._dim_array()
+ self._gatt_array()
+ self._var_array()
+
+ def _dim_array(self):
+ """Read a dict with dimensions names and sizes."""
+ self.dimensions = {}
+ self._dims = []
+ for k,d in self._buffer.iteritems():
+ if (isinstance(d, ArrayType) or isinstance(d, GridType)) and len(d.shape) == 1 and k == d.dimensions[0]:
+ name = k
+ length = len(d)
+ self.dimensions[name] = length
+ self._dims.append(name) # preserve dim order
+
+ def _gatt_array(self):
+ """Read global attributes."""
+ self.__dict__.update(self._buffer.attributes)
+
+ def _var_array(self):
+ """Read all variables."""
+ # Read variables.
+ self.variables = {}
+ for k,d in self._buffer.iteritems():
+ if isinstance(d, GridType) or isinstance(d, ArrayType):
+ name = k
+ self.variables[name] = _RemoteVariable(d,self._maskandscale)
+
+ def close(self):
+ # this is a no-op provided for compatibility
+ pass
+
+class _RemoteVariable(object):
+ def __init__(self, var, maskandscale):
+ self._var = var
+ self._maskandscale = maskandscale
+ self.dtype = var.type
+ self.shape = var.shape
+ self.dimensions = var.dimensions
+ self.__dict__.update(var.attributes)
+
+ def __getitem__(self, index):
+ datout = squeeze(self._var.__getitem__(index))
+ # automatically
+ # - remove singleton dimensions
+ # - create a masked array using missing_value or _FillValue attribute
+ # - apply scale_factor and add_offset to packed integer data
+ if self._maskandscale:
+ return _maskandscale(self,datout)
+ else:
+ return datout
+
+ def typecode(self):
+ return _typecodes[self.dtype]
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/pupynere.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/pupynere.py	2008年08月08日 12:19:47 UTC (rev 6006)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/pupynere.py	2008年08月08日 20:22:50 UTC (rev 6007)
@@ -1,45 +1,89 @@
-"""NetCDF reader.
+"""
+NetCDF reader/writer module.
 
-Pupynere implements a PUre PYthon NEtcdf REader.
+This module implements the Scientific.IO.NetCDF API to read and create
+NetCDF files. The same API is also used in the PyNIO and pynetcdf
+modules, allowing these modules to be used interchangebly when working
+with NetCDF files. The major advantage of ``scipy.io.netcdf`` over other 
+modules is that it doesn't require the code to be linked to the NetCDF
+libraries as the other modules do.
 
-Copyright (c) 2003-2006 Roberto De Almeida <ro...@py...>
+The code is based on the `NetCDF file format specification
+<http://www.unidata.ucar.edu/software/netcdf/guide_15.html>`_. A NetCDF
+file is a self-describing binary format, with a header followed by
+data. The header contains metadata describing dimensions, variables
+and the position of the data in the file, so access can be done in an
+efficient manner without loading unnecessary data into memory. We use
+the ``mmap`` module to create Numpy arrays mapped to the data on disk,
+for the same purpose.
 
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject
-to the following conditions:
+The structure of a NetCDF file is as follows:
 
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
+ C D F <VERSION BYTE> <NUMBER OF RECORDS>
+ <DIMENSIONS> <GLOBAL ATTRIBUTES> <VARIABLES METADATA>
+ <NON-RECORD DATA> <RECORD DATA>
 
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
-ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
-CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+Record data refers to data where the first axis can be expanded at
+will. All record variables share a same dimension at the first axis,
+and they are stored at the end of the file per record, ie
+
+ A[0], B[0], ..., A[1], B[1], ..., etc,
+ 
+so that new data can be appended to the file without changing its original
+structure. Non-record data are padded to a 4n bytes boundary. Record data
+are also padded, unless there is exactly one record variable in the file,
+in which case the padding is dropped. All data is stored in big endian
+byte order.
+
+The Scientific.IO.NetCDF API allows attributes to be added directly to
+instances of ``netcdf_file`` and ``netcdf_variable``. To differentiate
+between user-set attributes and instance attributes, user-set attributes
+are automatically stored in the ``_attributes`` attribute by overloading
+``__setattr__``. This is the reason why the code sometimes uses
+``obj.__dict__['key'] = value``, instead of simply ``obj.key = value``;
+otherwise the key would be inserted into userspace attributes.
+
+To create a NetCDF file::
+
+ >>> import time
+ >>> f = netcdf_file('simple.nc', 'w')
+ >>> f.history = 'Created for a test'
+ >>> f.createDimension('time', 10)
+ >>> time = f.createVariable('time', 'i', ('time',))
+ >>> time[:] = range(10)
+ >>> time.units = 'days since 2008年01月01日'
+ >>> f.close()
+
+To read the NetCDF file we just created::
+
+ >>> f = netcdf_file('simple.nc', 'r')
+ >>> print f.history
+ Created for a test
+ >>> time = f.variables['time']
+ >>> print time.units
+ days since 2008年01月01日
+ >>> print time.shape
+ (10,)
+ >>> print time[-1]
+ 9
+ >>> f.close()
+
+TODO: properly implement ``_FillValue``.
 """
 
-__author__ = "Roberto De Almeida <ro...@py...>"
+__all__ = ['netcdf_file', 'netcdf_variable']
 
 
-import struct
-import itertools
-import mmap
+from operator import mul
+from mmap import mmap, ACCESS_READ
 
-from numpy import ndarray, empty, array, ma, squeeze, zeros
-import numpy
+from numpy import fromstring, ndarray, dtype, empty, array, asarray, squeeze, zeros, ma
+from numpy import little_endian as LITTLE_ENDIAN
 
-from dap.client import open as open_remote
-from dap.dtypes import ArrayType, GridType, typemap
 
-ABSENT = '\x00' * 8
-ZERO = '\x00' * 4
-NC_BYTE = '\x00\x00\x00\x01' 
+ABSENT = '\x00\x00\x00\x00\x00\x00\x00\x00' 
+ZERO = '\x00\x00\x00\x00'
+NC_BYTE = '\x00\x00\x00\x01'
 NC_CHAR = '\x00\x00\x00\x02'
 NC_SHORT = '\x00\x00\x00\x03'
 NC_INT = '\x00\x00\x00\x04'
@@ -49,360 +93,531 @@
 NC_VARIABLE = '\x00\x00\x00\x0b'
 NC_ATTRIBUTE = '\x00\x00\x00\x0c'
 
-_typecodes = dict([[_v,_k] for _k,_v in typemap.items()])
-# default _FillValue for netcdf types (apply also to corresponding
-# DAP types).
-_default_fillvals = {'c':'0円',
- 'S':"",
- 'b':-127,
- 'B':-127,
- 'h':-32767,
- 'H':65535,
- 'i':-2147483647L,
- 'L':4294967295L,
- 'q':-2147483647L,
- 'f':9.9692099683868690e+36,
- 'd':9.9692099683868690e+36}
 
-def NetCDFFile(file, maskandscale=True):
- """NetCDF File reader. API is the same as Scientific.IO.NetCDF.
- If 'file' is a URL that starts with 'http', it is assumed
- to be a remote OPenDAP dataset, and the python dap client is used
- to retrieve the data. Only the OPenDAP Array and Grid data
- types are recognized. If file does not start with 'http', it
- is assumed to be a local netCDF file. Data will
- automatically be converted to masked arrays if the variable has either
- a 'missing_value' or '_FillValue' attribute, and some data points
- are equal to the value specified by that attribute. In addition,
- variables stored as integers that have the 'scale_factor' and
- 'add_offset' attribute will automatically be rescaled to floats when
- read. To suppress these automatic conversions, set the
- maskandscale keyword to False. 
+TYPEMAP = { NC_BYTE: ('b', 1),
+ NC_CHAR: ('c', 1),
+ NC_SHORT: ('h', 2),
+ NC_INT: ('i', 4),
+ NC_FLOAT: ('f', 4),
+ NC_DOUBLE: ('d', 8) }
+
+REVERSE = { 'b': NC_BYTE,
+ 'c': NC_CHAR,
+ 'h': NC_SHORT,
+ 'i': NC_INT,
+ 'f': NC_FLOAT,
+ 'd': NC_DOUBLE,
+
+ # these come from asarray(1).dtype.char and asarray('foo').dtype.char,
+ # used when getting the types from generic attributes.
+ 'l': NC_INT,
+ 'S': NC_CHAR }
+
+
+class netcdf_file(object):
 """
- if file.startswith('http'):
- return _RemoteFile(file,maskandscale)
- else:
- return _LocalFile(file,maskandscale)
- 
-def _maskandscale(var,datout):
- totalmask = zeros(datout.shape,numpy.bool)
- fillval = None
- if hasattr(var, 'missing_value') and (datout == var.missing_value).any():
- fillval = var.missing_value
- totalmask += datout==fillval
- if hasattr(var, '_FillValue') and (datout == var._FillValue).any():
- if fillval is None:
- fillval = var._FillValue
- totalmask += datout==var._FillValue
- elif (datout == _default_fillvals[var.typecode()]).any():
- if fillval is None:
- fillval = _default_fillvals[var.typecode()]
- totalmask += datout==_default_fillvals[var.dtype]
- if fillval is not None:
- datout = ma.masked_array(datout,mask=totalmask,fill_value=fillval)
- try:
- datout = var.scale_factor*datout + var.add_offset
- except:
- pass
- return datout
+ A ``netcdf_file`` object has two standard attributes: ``dimensions`` and
+ ``variables``. The values of both are dictionaries, mapping dimension
+ names to their associated lengths and variable names to variables,
+ respectively. Application programs should never modify these
+ dictionaries.
 
-class _RemoteFile(object):
- """A NetCDF file reader. API is the same as Scientific.IO.NetCDF."""
+ All other attributes correspond to global attributes defined in the
+ NetCDF file. Global file attributes are created by assigning to an
+ attribute of the ``netcdf_file`` object.
 
- def __init__(self, file, maskandscale):
- self._buffer = open_remote(file)
+ """
+ def __init__(self, filename, mode='r', maskandscale=False):
+
 self._maskandscale = maskandscale
- self._parse()
 
- def read(self, size=-1):
- """Alias for reading the file buffer."""
- return self._buffer.read(size)
+ self.filename = filename
 
- def _parse(self):
- """Initial parsing of the header."""
- # Read header info.
- self._dim_array()
- self._gatt_array()
- self._var_array()
+ assert mode in 'rw', "Mode must be either 'r' or 'w'."
+ self.mode = mode
 
- def _dim_array(self):
- """Read a dict with dimensions names and sizes."""
 self.dimensions = {}
+ self.variables = {}
+
 self._dims = []
- for k,d in self._buffer.iteritems():
- if (isinstance(d, ArrayType) or isinstance(d, GridType)) and len(d.shape) == 1 and k == d.dimensions[0]:
- name = k
- length = len(d)
- self.dimensions[name] = length
- self._dims.append(name) # preserve dim order
+ self._recs = 0
+ self._recsize = 0
 
- def _gatt_array(self):
- """Read global attributes."""
- self.__dict__.update(self._buffer.attributes)
+ self.fp = open(self.filename, '%sb' % mode)
 
- def _var_array(self):
- """Read all variables."""
- # Read variables.
- self.variables = {}
- for k,d in self._buffer.iteritems():
- if isinstance(d, GridType) or isinstance(d, ArrayType):
- name = k
- self.variables[name] = _RemoteVariable(d,self._maskandscale)
+ self._attributes = {}
 
+ if mode is 'r':
+ self._read()
+
+ def __setattr__(self, attr, value):
+ # Store user defined attributes in a separate dict,
+ # so we can save them to file later.
+ try:
+ self._attributes[attr] = value
+ except AttributeError:
+ pass
+ self.__dict__[attr] = value
+
 def close(self):
- # this is a no-op provided for compatibility
- pass
+ if not self.fp.closed:
+ try:
+ self.flush()
+ finally:
+ self.fp.close()
+ __del__ = close
 
+ def createDimension(self, name, length):
+ self.dimensions[name] = length
+ self._dims.append(name)
 
-class _RemoteVariable(object):
- def __init__(self, var, maskandscale):
- self._var = var
- self._maskandscale = maskandscale
- self.dtype = var.type
- self.shape = var.shape
- self.dimensions = var.dimensions
- self.__dict__.update(var.attributes)
+ def createVariable(self, name, type, dimensions):
+ shape = tuple([self.dimensions[dim] for dim in dimensions]) 
+ shape_ = tuple([dim or 0 for dim in shape]) # replace None with 0 for numpy
 
- def __getitem__(self, index):
- datout = squeeze(self._var.__getitem__(index))
- # automatically
- # - remove singleton dimensions
- # - create a masked array using missing_value or _FillValue attribute
- # - apply scale_factor and add_offset to packed integer data
- if self._maskandscale:
- return _maskandscale(self,datout)
+ if isinstance(type, basestring): type = dtype(type)
+ typecode, size = type.char, type.itemsize
+ dtype_ = '>%s' % typecode
+ if size > 1: dtype_ += str(size)
+
+ data = empty(shape_, dtype=dtype_)
+ self.variables[name] = netcdf_variable(data, typecode, shape, dimensions)
+ return self.variables[name]
+
+ def flush(self):
+ if self.mode is 'w':
+ self._write()
+ sync = flush
+
+ def _write(self):
+ self.fp.write('CDF')
+
+ self.__dict__['version_byte'] = 1
+ self.fp.write(array(1, '>b').tostring())
+
+ # Write headers and data.
+ self._write_numrecs()
+ self._write_dim_array()
+ self._write_gatt_array()
+ self._write_var_array()
+
+ def _write_numrecs(self):
+ # Get highest record count from all record variables.
+ for var in self.variables.values():
+ if not var.shape[0] and len(var.data) > self._recs:
+ self.__dict__['_recs'] = len(var.data)
+ self._pack_int(self._recs)
+
+ def _write_dim_array(self):
+ if self.dimensions:
+ self.fp.write(NC_DIMENSION)
+ self._pack_int(len(self.dimensions))
+ for name, length in self.dimensions.items():
+ self._pack_string(name)
+ self._pack_int(length or 0) # replace None with 0 for record dimension
 else:
- return datout
+ self.fp.write(ABSENT)
 
- def typecode(self):
- return _typecodes[self.dtype]
+ def _write_gatt_array(self):
+ self._write_att_array(self._attributes)
 
+ def _write_att_array(self, attributes):
+ if attributes:
+ self.fp.write(NC_ATTRIBUTE)
+ self._pack_int(len(attributes))
+ for name, values in attributes.items():
+ self._pack_string(name)
+ self._write_values(values)
+ else:
+ self.fp.write(ABSENT)
 
-class _LocalFile(object):
- """A NetCDF file reader. API is the same as Scientific.IO.NetCDF."""
+ def _write_var_array(self):
+ if self.variables:
+ self.fp.write(NC_VARIABLE)
+ self._pack_int(len(self.variables))
 
- def __init__(self, file, maskandscale):
- self._buffer = open(file, 'rb')
- self._maskandscale = maskandscale
- self._parse()
+ # Sort variables non-recs first, then recs.
+ variables = self.variables.items()
+ variables.sort(key=lambda (k, v): v.shape and v.shape[0] is not None)
+ variables.reverse()
+ variables = [k for (k, v) in variables]
 
- def read(self, size=-1):
- """Alias for reading the file buffer."""
- return self._buffer.read(size)
+ # Set the metadata for all variables.
+ for name in variables:
+ self._write_var_metadata(name)
+ # Now that we have the metadata, we know the vsize of
+ # each record variable, so we can calculate recsize.
+ self.__dict__['_recsize'] = sum([
+ var._vsize for var in self.variables.values()
+ if var.shape[0] is None])
+ # Set the data for all variables.
+ for name in variables:
+ self._write_var_data(name)
+ else:
+ self.fp.write(ABSENT)
 
- def _parse(self):
- """Initial parsing of the header."""
- # Check magic bytes.
- assert self.read(3) == 'CDF'
+ def _write_var_metadata(self, name):
+ var = self.variables[name]
 
- # Read version byte.
- byte = self.read(1)
- self.version_byte = struct.unpack('>b', byte)[0]
+ self._pack_string(name)
+ self._pack_int(len(var.dimensions))
+ for dimname in var.dimensions:
+ dimid = self._dims.index(dimname)
+ self._pack_int(dimid)
 
- # Read header info.
- self._numrecs()
- self._dim_array()
- self._gatt_array()
- self._var_array()
+ self._write_att_array(var._attributes)
 
- def _numrecs(self):
- """Read number of records."""
- self._nrecs = self._unpack_int()
+ nc_type = REVERSE[var.typecode()]
+ self.fp.write(nc_type)
 
- def _dim_array(self):
- """Read a dict with dimensions names and sizes."""
- assert self.read(4) in [ZERO, NC_DIMENSION]
+ if var.shape[0]:
+ vsize = var.data.size * var.data.itemsize
+ vsize += -vsize % 4
+ else: # record variable
+ vsize = var.data[0].size * var.data.itemsize
+ rec_vars = len([var for var in self.variables.values()
+ if var.shape[0] is None])
+ if rec_vars > 1:
+ vsize += -vsize % 4
+ self.variables[name].__dict__['_vsize'] = vsize
+ self._pack_int(vsize)
+
+ # Pack a bogus begin, and set the real value later.
+ self.variables[name].__dict__['_begin'] = self.fp.tell()
+ self._pack_begin(0)
+
+ def _write_var_data(self, name):
+ var = self.variables[name]
+ 
+ # Set begin in file header.
+ the_beguine = self.fp.tell()
+ self.fp.seek(var._begin)
+ self._pack_begin(the_beguine)
+ self.fp.seek(the_beguine)
+
+ # Write data.
+ if var.shape[0]:
+ self.fp.write(var.data.tostring()) 
+ count = var.data.size * var.data.itemsize
+ self.fp.write('0' * (var._vsize - count))
+ else: # record variable
+ # Handle rec vars with shape[0] < nrecs.
+ if self._recs > len(var.data):
+ shape = (self._recs,) + var.data.shape[1:]
+ var.data.resize(shape)
+
+ pos0 = pos = self.fp.tell()
+ for rec in var.data:
+ # Apparently scalars cannot be converted to big endian. If we
+ # try to convert a ``=i4`` scalar to, say, '>i4' the dtype
+ # will remain as ``=i4``.
+ if not rec.shape and (rec.dtype.byteorder == '<' or
+ (rec.dtype.byteorder == '=' and LITTLE_ENDIAN)):
+ rec = rec.byteswap()
+ self.fp.write(rec.tostring())
+ # Padding
+ count = rec.size * rec.itemsize
+ self.fp.write('0' * (var._vsize - count))
+ pos += self._recsize
+ self.fp.seek(pos)
+ self.fp.seek(pos0 + var._vsize)
+
+ def _write_values(self, values):
+ values = asarray(values) 
+ values = values.astype(values.dtype.newbyteorder('>'))
+
+ nc_type = REVERSE[values.dtype.char]
+ self.fp.write(nc_type)
+
+ if values.dtype.char == 'S':
+ nelems = values.itemsize
+ else:
+ nelems = values.size
+ self._pack_int(nelems)
+
+ if not values.shape and (values.dtype.byteorder == '<' or
+ (values.dtype.byteorder == '=' and LITTLE_ENDIAN)):
+ values = values.byteswap()
+ self.fp.write(values.tostring())
+ count = values.size * values.itemsize
+ self.fp.write('0' * (-count % 4)) # pad
+
+ def _read(self):
+ # Check magic bytes and version
+ assert self.fp.read(3) == 'CDF', "Error: %s is not a valid NetCDF 3 file" % self.filename
+ self.__dict__['version_byte'] = fromstring(self.fp.read(1), '>b')[0]
+
+ # Read file headers and set data.
+ self._read_numrecs()
+ self._read_dim_array()
+ self._read_gatt_array()
+ self._read_var_array()
+
+ def _read_numrecs(self):
+ self.__dict__['_recs'] = self._unpack_int()
+
+ def _read_dim_array(self):
+ assert self.fp.read(4) in [ZERO, NC_DIMENSION]
 count = self._unpack_int()
 
- self.dimensions = {}
- self._dims = []
 for dim in range(count):
- name = self._read_string()
- length = self._unpack_int()
- if length == 0: length = None # record dimension
+ name = self._unpack_string()
+ length = self._unpack_int() or None # None for record dimension
 self.dimensions[name] = length
- self._dims.append(name) # preserve dim order
+ self._dims.append(name) # preserve order
 
- def _gatt_array(self):
- """Read global attributes."""
- self.attributes = self._att_array()
+ def _read_gatt_array(self):
+ for k, v in self._read_att_array().items():
+ self.__setattr__(k, v)
 
- # Update __dict__ for compatibility with S.IO.N
- self.__dict__.update(self.attributes)
-
- def _att_array(self):
- """Read a dict with attributes."""
- assert self.read(4) in [ZERO, NC_ATTRIBUTE]
+ def _read_att_array(self):
+ assert self.fp.read(4) in [ZERO, NC_ATTRIBUTE]
 count = self._unpack_int()
 
- # Read attributes.
 attributes = {}
- for attribute in range(count):
- name = self._read_string()
- nc_type = self._unpack_int()
- n = self._unpack_int()
+ for attr in range(count):
+ name = self._unpack_string()
+ attributes[name] = self._read_values()
+ return attributes
 
- # Read value for attributes.
- attributes[name] = self._read_values(n, nc_type)
+ def _read_var_array(self):
+ assert self.fp.read(4) in [ZERO, NC_VARIABLE]
 
- return attributes
+ begin = 0
+ dtypes = {'names': [], 'formats': []}
+ rec_vars = []
+ count = self._unpack_int()
+ for var in range(count):
+ name, dimensions, shape, attributes, typecode, size, dtype_, begin_, vsize = self._read_var()
+ if shape and shape[0] is None:
+ rec_vars.append(name)
+ self.__dict__['_recsize'] += vsize
+ if begin == 0: begin = begin_
+ dtypes['names'].append(name)
+ dtypes['formats'].append(str(shape[1:]) + dtype_)
 
- def _var_array(self):
- """Read all variables."""
- assert self.read(4) in [ZERO, NC_VARIABLE]
+ # Handle padding with a virtual variable.
+ if typecode in 'bch':
+ actual_size = reduce(mul, (1,) + shape[1:]) * size
+ padding = -actual_size % 4
+ if padding:
+ dtypes['names'].append('_padding_%d' % var)
+ dtypes['formats'].append('(%d,)>b' % padding)
 
- # Read size of each record, in bytes.
- self._read_recsize()
+ # Data will be set later.
+ data = None
+ else:
+ mm = mmap(self.fp.fileno(), begin_+vsize, access=ACCESS_READ)
+ data = ndarray.__new__(ndarray, shape, dtype=dtype_,
+ buffer=mm, offset=begin_, order=0)
 
- # Read variables.
- self.variables = {}
- count = self._unpack_int()
- for variable in range(count):
- name = self._read_string()
- self.variables[name] = self._read_var()
+ # Add variable.
+ self.variables[name] = netcdf_variable(
+ data, typecode, shape, dimensions, attributes)
 
- def _read_recsize(self):
- """Read all variables and compute record bytes."""
- pos = self._buffer.tell()
- 
- recsize = 0
- count = self._unpack_int()
- for variable in range(count):
- name = self._read_string()
- n = self._unpack_int()
- isrec = False
- for i in range(n):
- dimid = self._unpack_int()
- name = self._dims[dimid]
- dim = self.dimensions[name]
- if dim is None and i == 0:
- isrec = True
- attributes = self._att_array()
- nc_type = self._unpack_int()
- vsize = self._unpack_int()
- begin = [self._unpack_int, self._unpack_int64][self.version_byte-1]()
+ if rec_vars:
+ # Remove padding when only one record variable.
+ if len(rec_vars) == 1:
+ dtypes['names'] = dtypes['names'][:1]
+ dtypes['formats'] = dtypes['formats'][:1]
 
- if isrec: recsize += vsize
+ # Build rec array.
+ mm = mmap(self.fp.fileno(), begin+self._recs*self._recsize, access=ACCESS_READ)
+ rec_array = ndarray.__new__(ndarray, (self._recs,), dtype=dtypes,
+ buffer=mm, offset=begin, order=0)
 
- self._recsize = recsize
- self._buffer.seek(pos)
+ for var in rec_vars:
+ self.variables[var].__dict__['data'] = rec_array[var]
 
 def _read_var(self):
+ name = self._unpack_string()
 dimensions = []
 shape = []
- n = self._unpack_int()
- isrec = False
- for i in range(n):
+ dims = self._unpack_int()
+ 
+ for i in range(dims):
 dimid = self._unpack_int()
- name = self._dims[dimid]
- dimensions.append(name)
- dim = self.dimensions[name]
- if dim is None and i == 0:
- dim = self._nrecs
- isrec = True
+ dimname = self._dims[dimid]
+ dimensions.append(dimname)
+ dim = self.dimensions[dimname]
 shape.append(dim)
 dimensions = tuple(dimensions)
 shape = tuple(shape)
 
- attributes = self._att_array()
- nc_type = self._unpack_int()
+ attributes = self._read_att_array()
+ nc_type = self.fp.read(4)
 vsize = self._unpack_int()
- 
- # Read offset.
 begin = [self._unpack_int, self._unpack_int64][self.version_byte-1]()
 
- return _LocalVariable(self._buffer.fileno(), nc_type, vsize, begin, shape, dimensions, attributes, isrec, self._recsize, maskandscale=self._maskandscale)
+ typecode, size = TYPEMAP[nc_type]
+ if typecode is 'c':
+ dtype_ = '>c'
+ else:
+ dtype_ = '>%s' % typecode
+ if size > 1: dtype_ += str(size)
 
- def _read_values(self, n, nc_type):
- bytes = [1, 1, 2, 4, 4, 8]
- typecodes = ['b', 'c', 'h', 'i', 'f', 'd']
- 
- count = n * bytes[nc_type-1]
- values = self.read(count)
- padding = self.read((4 - (count % 4)) % 4)
- 
- typecode = typecodes[nc_type-1]
- if nc_type != 2: # not char 
- values = struct.unpack('>%s' % (typecode * n), values)
- values = array(values, dtype=typecode) 
+ return name, dimensions, shape, attributes, typecode, size, dtype_, begin, vsize
+
+ def _read_values(self):
+ nc_type = self.fp.read(4)
+ n = self._unpack_int()
+
+ typecode, size = TYPEMAP[nc_type]
+
+ count = n*size
+ values = self.fp.read(count)
+ self.fp.read(-count % 4) # read padding
+
+ if typecode is not 'c':
+ values = fromstring(values, dtype='>%s%d' % (typecode, size))
+ if values.shape == (1,): values = values[0]
 else:
- # Remove EOL terminator.
- if values.endswith('\x00'): values = values[:-1]
-
+ values = values.rstrip('\x00') 
 return values
 
+ def _pack_begin(self, begin):
+ if self.version_byte == 1:
+ self._pack_int(begin)
+ elif self.version_byte == 2:
+ self._pack_int64(begin)
+
+ def _pack_int(self, value):
+ self.fp.write(array(value, '>i').tostring())
+ _pack_int32 = _pack_int
+
 def _unpack_int(self):
- return struct.unpack('>i', self.read(4))[0]
+ return fromstring(self.fp.read(4), '>i')[0]
 _unpack_int32 = _unpack_int
 
+ def _pack_int64(self, value):
+ self.fp.write(array(value, '>q').tostring())
+
 def _unpack_int64(self):
- return struct.unpack('>q', self.read(8))[0]
+ return fromstring(self.fp.read(8), '>q')[0]
 
- def _read_string(self):
- count = struct.unpack('>i', self.read(4))[0]
- s = self.read(count)
- # Remove EOL terminator.
- if s.endswith('\x00'): s = s[:-1]
- padding = self.read((4 - (count % 4)) % 4)
+ def _pack_string(self, s):
+ count = len(s)
+ self._pack_int(count)
+ self.fp.write(s)
+ self.fp.write('0' * (-count % 4)) # pad
+
+ def _unpack_string(self):
+ count = self._unpack_int()
+ s = self.fp.read(count).rstrip('\x00')
+ self.fp.read(-count % 4) # read padding
 return s
 
- def close(self):
- self._buffer.close()
 
+class netcdf_variable(object):
+ """
+ ``netcdf_variable`` objects are constructed by calling the method
+ ``createVariable`` on the netcdf_file object.
 
-class _LocalVariable(object):
- def __init__(self, fileno, nc_type, vsize, begin, shape, dimensions, attributes, isrec=False, recsize=0, maskandscale=True):
- self._nc_type = nc_type
- self._vsize = vsize
- self._begin = begin
- self.shape = shape
+ ``netcdf_variable`` objects behave much like array objects defined in
+ Numpy, except that their data resides in a file. Data is read by
+ indexing and written by assigning to an indexed subset; the entire
+ array can be accessed by the index ``[:]`` or using the methods
+ ``getValue`` and ``assignValue``. ``netcdf_variable`` objects also
+ have attribute ``shape`` with the same meaning as for arrays, but
+ the shape cannot be modified. There is another read-only attribute
+ ``dimensions``, whose value is the tuple of dimension names.
+
+ All other attributes correspond to variable attributes defined in
+ the NetCDF file. Variable attributes are created by assigning to an
+ attribute of the ``netcdf_variable`` object.
+
+ """
+ def __init__(self, data, typecode, shape, dimensions, attributes=None, maskandscale=True):
+ self.data = data
+ self._typecode = typecode
+ self._shape = shape
 self.dimensions = dimensions
- self.attributes = attributes # for ``dap.plugins.netcdf``
- self.__dict__.update(attributes)
- self._is_record = isrec
 self._maskandscale = maskandscale
 
- # Number of bytes and type.
- self._bytes = [1, 1, 2, 4, 4, 8][self._nc_type-1]
- type_ = ['i', 'S', 'i', 'i', 'f', 'f'][self._nc_type-1]
- dtype = '>%s%d' % (type_, self._bytes)
- bytes = self._begin + self._vsize 
+ self._attributes = attributes or {}
+ for k, v in self._attributes.items():
+ self.__dict__[k] = v
 
- if isrec:
- # Record variables are not stored contiguosly on disk, so we 
- # need to create a separate array for each record.
- self.__array_data__ = empty(shape, dtype)
- bytes += (shape[0] - 1) * recsize
- for n in range(shape[0]):
- offset = self._begin + (n * recsize)
- mm = mmap.mmap(fileno, bytes, access=mmap.ACCESS_READ)
- self.__array_data__[n] = ndarray.__new__(ndarray, shape[1:], dtype=dtype, buffer=mm, offset=offset, order=0)
- else:
- # Create buffer and data.
- mm = mmap.mmap(fileno, bytes, access=mmap.ACCESS_READ)
- self.__array_data__ = ndarray.__new__(ndarray, shape, dtype=dtype, buffer=mm, offset=self._begin, order=0)
+ def __setattr__(self, attr, value):
+ # Store user defined attributes in a separate dict,
+ # so we can save them to file later.
+ try:
+ self._attributes[attr] = value
+ except AttributeError:
+ pass
+ self.__dict__[attr] = value
 
- # N-D array interface
- self.__array_interface__ = {'shape' : shape,
- 'typestr': dtype,
- 'data' : self.__array_data__,
- 'version': 3,
- }
+ @property
+ def shape(self):
+ return self.data.shape
 
+ def getValue(self):
+ return self.data.item()
+
+ def assignValue(self, value):
+ self.data.itemset(value)
+
+ def typecode(self):
+ return self._typecode
+
 def __getitem__(self, index):
- datout = squeeze(self.__array_data__.__getitem__(index))
- # automatically
- # - remove singleton dimensions
- # - create a masked array using missing_value or _FillValue attribute
- # - apply scale_factor and add_offset to packed integer data
+ datout = squeeze(self.data[index])
 if self._maskandscale:
 return _maskandscale(self,datout)
 else:
 return datout
 
- def getValue(self):
- """For scalars."""
- return self.__array_data__.item()
+ def __setitem__(self, index, data):
+ # Expand data for record vars?
+ if not self._shape[0]:
+ if isinstance(index, tuple):
+ rec_index = index[0]
+ else:
+ rec_index = index
+ if isinstance(rec_index, slice):
+ recs = (rec_index.start or 0) + len(data)
+ else:
+ recs = rec_index + 1
+ if recs > len(self.data):
+ shape = (recs,) + self._shape[1:]
+ self.data.resize(shape)
+ self.data[index] = data
 
- def typecode(self):
- return ['b', 'c', 'h', 'i', 'f', 'd'][self._nc_type-1]
+
+NetCDFFile = netcdf_file
+NetCDFVariable = netcdf_variable
+
+# default _FillValue for netcdf types (apply also to corresponding
+# DAP types).
+_default_fillvals = {'c':'0円',
+ 'S':"",
+ 'b':-127,
+ 'B':-127,
+ 'h':-32767,
+ 'H':65535,
+ 'i':-2147483647L,
+ 'L':4294967295L,
+ 'q':-2147483647L,
+ 'f':9.9692099683868690e+36,
+ 'd':9.9692099683868690e+36}
+def _maskandscale(var,datout):
+ totalmask = zeros(datout.shape,bool)
+ fillval = None
+ if hasattr(var, 'missing_value') and (datout == var.missing_value).any():
+ fillval = var.missing_value
+ totalmask += datout==fillval
+ if hasattr(var, '_FillValue') and (datout == var._FillValue).any():
+ if fillval is None:
+ fillval = var._FillValue
+ totalmask += datout==var._FillValue
+ elif (datout == _default_fillvals[var.typecode()]).any():
+ if fillval is None:
+ fillval = _default_fillvals[var.typecode()]
+ totalmask += datout==_default_fillvals[var.dtype]
+ if fillval is not None:
+ datout = ma.masked_array(datout,mask=totalmask,fill_value=fillval)
+ try:
+ datout = var.scale_factor*datout + var.add_offset
+ except:
+ pass
+ return datout
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

Showing results of 115

<< < 1 2 3 4 5 > >> (Page 2 of 5)
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /