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
(6)
2
(17)
3
(11)
4
(12)
5
(16)
6
(6)
7
(5)
8
(8)
9
(24)
10
(15)
11
(12)
12
(22)
13
(30)
14
(16)
15
(6)
16
(15)
17
(20)
18
(4)
19
(11)
20
(16)
21
(2)
22
(17)
23
(16)
24
(18)
25
(4)
26
(9)
27
(12)
28
(2)
29
30
(4)





Showing 12 results of 12

Revision: 5477
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5477&view=rev
Author: mdboom
Date: 2008年06月11日 11:35:01 -0700 (2008年6月11日)
Log Message:
-----------
Fix capitalization.
Modified Paths:
--------------
 trunk/matplotlib/doc/sphinxext/math_symbol_table.py
Modified: trunk/matplotlib/doc/sphinxext/math_symbol_table.py
===================================================================
--- trunk/matplotlib/doc/sphinxext/math_symbol_table.py	2008年06月11日 18:33:05 UTC (rev 5476)
+++ trunk/matplotlib/doc/sphinxext/math_symbol_table.py	2008年06月11日 18:35:01 UTC (rev 5477)
@@ -21,12 +21,12 @@
 5,
 r"""\bigcap \bigcup \bigodot \bigoplus \bigotimes \biguplus
 \bigvee \bigwedge \coprod \oint \prod \sum \int"""],
- ["Standard Function Names",
+ ["Standard function names",
 4,
 r"""\arccos \csc \ker \min \arcsin \deg \lg \Pr \arctan \det \lim
 \gcd \ln \sup \cot \hom \log \tan \coth \inf \max \tanh
 \sec \arg \dim \liminf \sin \cos \exp \limsup \sinh \cosh"""],
- ["Binary Operation and Relation Symbols",
+ ["Binary operation and relation symbols",
 3,
 r"""\ast \pm \slash \cap \star \mp \cup \cdot \uplus
 \triangleleft \circ \odot \sqcap \triangleright \bullet \ominus
@@ -61,7 +61,7 @@
 \backcong \Doteq \eqdef \wedgeq \questeq \eqgtr \cupdot
 \veeeq \nsubset \eqcolon \ne
 """],
- ["Arrow Symbols",
+ ["Arrow symbols",
 2,
 r"""\leftarrow \longleftarrow \uparrow \Leftarrow \Longleftarrow
 \Uparrow \rightarrow \longrightarrow \downarrow \Rightarrow
@@ -86,7 +86,7 @@
 \twoheaduparrow \updownarrowbar \leftsquigarrow \rightzigzagarrow
 \twoheaddownarrow \downzigzagarrow
 """],
- ["Miscellaneous Symbols",
+ ["Miscellaneous symbols",
 3,
 r"""\neg \invnot \turnednot \infty \forall \wp \exists \bigstar
 \angle \partial \nexists \measuredangle \eth \emptyset
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2008年06月11日 18:33:11
Revision: 5476
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5476&view=rev
Author: mdboom
Date: 2008年06月11日 11:33:05 -0700 (2008年6月11日)
Log Message:
-----------
Removing debugging output
Modified Paths:
--------------
 trunk/matplotlib/src/_png.cpp
Modified: trunk/matplotlib/src/_png.cpp
===================================================================
--- trunk/matplotlib/src/_png.cpp	2008年06月11日 18:05:21 UTC (rev 5475)
+++ trunk/matplotlib/src/_png.cpp	2008年06月11日 18:33:05 UTC (rev 5476)
@@ -32,7 +32,6 @@
 };
 
 static void write_png_data(png_structp png_ptr, png_bytep data, png_size_t length) {
- printf("%x %x %d %x\n", png_ptr, data, *data, length);
 PyObject* py_file_obj = (PyObject*)png_get_io_ptr(png_ptr);
 PyObject* write_method = PyObject_GetAttrString(py_file_obj, "write");
 PyObject* result = NULL;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2008年06月11日 18:05:32
Revision: 5475
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5475&view=rev
Author: mdboom
Date: 2008年06月11日 11:05:21 -0700 (2008年6月11日)
Log Message:
-----------
Fix silly typo in _png.cpp that broke usetex support.
Modified Paths:
--------------
 trunk/matplotlib/src/_png.cpp
Modified: trunk/matplotlib/src/_png.cpp
===================================================================
--- trunk/matplotlib/src/_png.cpp	2008年06月11日 17:24:57 UTC (rev 5474)
+++ trunk/matplotlib/src/_png.cpp	2008年06月11日 18:05:21 UTC (rev 5475)
@@ -19,7 +19,7 @@
 {
 add_varargs_method("write_png", &_png_module::write_png,
 "write_png(buffer, width, height, fileobj, dpi=None)");
- add_varargs_method("read_png", &_png_module::write_png,
+ add_varargs_method("read_png", &_png_module::read_png,
 "read_png(fileobj)");
 initialize("Module to write PNG files");
 }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5474
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5474&view=rev
Author: mdboom
Date: 2008年06月11日 10:24:57 -0700 (2008年6月11日)
Log Message:
-----------
Fix docutils 0.4 incompatibility.
Modified Paths:
--------------
 trunk/matplotlib/doc/sphinxext/math_symbol_table.py
Modified: trunk/matplotlib/doc/sphinxext/math_symbol_table.py
===================================================================
--- trunk/matplotlib/doc/sphinxext/math_symbol_table.py	2008年06月11日 17:05:42 UTC (rev 5473)
+++ trunk/matplotlib/doc/sphinxext/math_symbol_table.py	2008年06月11日 17:24:57 UTC (rev 5474)
@@ -100,48 +100,61 @@
 \iiint \iint \iint \oiiint"""]
 ]
 
-from docutils import nodes, statemachine
-from docutils.parsers.rst import Directive
-class math_symbol_table_directive(Directive):
- has_content = True
- def run(self):
- def get_n(n, l):
- part = []
- for x in l:
- part.append(x)
- if len(part) == n:
- yield part
- part = []
- yield part
+def run(state_machine):
+ def get_n(n, l):
+ part = []
+ for x in l:
+ part.append(x)
+ if len(part) == n:
+ yield part
+ part = []
+ yield part
 
- lines = []
- for category, columns, syms in symbols:
- syms = syms.split()
- syms.sort()
- lines.append("**%s**" % category)
+ lines = []
+ for category, columns, syms in symbols:
+ syms = syms.split()
+ syms.sort()
+ lines.append("**%s**" % category)
+ lines.append('')
+ max_width = 0
+ for sym in syms:
+ max_width = max(max_width, len(sym))
+ max_width = max_width * 2 + 16
+ header = " " + (('=' * max_width) + ' ') * columns
+ format = '%%%ds' % max_width
+ for chunk in get_n(20, get_n(columns, syms)):
+ lines.append(header)
+ for part in chunk:
+ line = []
+ for sym in part:
+ line.append(format % (":math:`%s` ``%s``" % (sym, sym)))
+ lines.append(" " + " ".join(line))
+ lines.append(header)
 lines.append('')
- max_width = 0
- for sym in syms:
- max_width = max(max_width, len(sym))
- max_width = max_width * 2 + 16
- header = " " + (('=' * max_width) + ' ') * columns
- format = '%%%ds' % max_width
- for chunk in get_n(20, get_n(columns, syms)):
- lines.append(header)
- for part in chunk:
- line = []
- for sym in part:
- line.append(format % (":math:`%s` ``%s``" % (sym, sym)))
- lines.append(" " + " ".join(line))
- lines.append(header)
- lines.append('')
- self.state_machine.insert_input(lines, "Symbol table")
- return []
 
-from docutils.parsers.rst import directives
-directives.register_directive('math_symbol_table',
- math_symbol_table_directive)
+ state_machine.insert_input(lines, "Symbol table")
+ return []
 
+try:
+ from docutils.parsers.rst import Directive
+except ImportError:
+ from docutils.parsers.rst.directives import _directives
+ def math_symbol_table_directive(name, arguments, options, content, lineno,
+ content_offset, block_text, state, state_machine):
+ return run(state_machine)
+ math_symbol_table_directive.arguments = None
+ math_symbol_table_directive.options = {}
+ math_symbol_table_directive.content = False
+ _directives['math_symbol_table'] = math_symbol_table_directive
+else:
+ class math_symbol_table_directive(Directive):
+ has_content = False
+ def run(self):
+ return run(self.state_machine)
+ from docutils.parsers.rst import directives
+ directives.register_directive('math_symbol_table',
+ math_symbol_table_directive)
+
 if __name__ == "__main__":
 # Do some verification of the tables
 from matplotlib import _mathtext_data
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2008年06月11日 17:06:11
Revision: 5473
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5473&view=rev
Author: mdboom
Date: 2008年06月11日 10:05:42 -0700 (2008年6月11日)
Log Message:
-----------
Fix Python 2.4 incompatibility.
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/pyparsing.py
Modified: trunk/matplotlib/lib/matplotlib/pyparsing.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/pyparsing.py	2008年06月11日 16:24:12 UTC (rev 5472)
+++ trunk/matplotlib/lib/matplotlib/pyparsing.py	2008年06月11日 17:05:42 UTC (rev 5473)
@@ -213,8 +213,7 @@
 ErrorStop indicates that parsing is to stop immediately because
 an unbacktrackable syntax error has been found"""
 def __init__(self, pe):
- super(ParseSyntaxException, self).__init__(
- pe.pstr, pe.loc, pe.msg, pe.parserElement)
+ ParseFatalException.__init__(self, pe.pstr, pe.loc, pe.msg, pe.parserElement)
 
 #~ class ReparseException(ParseBaseException):
 #~ """Experimental class - parse actions can raise this exception to cause
@@ -3481,16 +3480,16 @@
 return ret
 
 def indentedBlock(blockStatementExpr, indentStack, indent=True):
- """Helper method for defining space-delimited indentation blocks, such as 
+ """Helper method for defining space-delimited indentation blocks, such as
 those used to define block statements in Python source code.
- 
+
 Parameters:
- - blockStatementExpr - expression defining syntax of statement that 
+ - blockStatementExpr - expression defining syntax of statement that
 is repeated within the indented block
 - indentStack - list created by caller to manage indentation stack
 (multiple statementWithIndentedBlock expressions within a single grammar
 should share a common indentStack)
- - indent - boolean indicating whether block must be indented beyond the 
+ - indent - boolean indicating whether block must be indented beyond the
 the current level; set to False for block of left-most statements
 (default=True)
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2008年06月11日 16:24:16
Revision: 5472
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5472&view=rev
Author: mdboom
Date: 2008年06月11日 09:24:12 -0700 (2008年6月11日)
Log Message:
-----------
Forgot this file
Added Paths:
-----------
 trunk/matplotlib/src/_png.cpp
Added: trunk/matplotlib/src/_png.cpp
===================================================================
--- trunk/matplotlib/src/_png.cpp	 (rev 0)
+++ trunk/matplotlib/src/_png.cpp	2008年06月11日 16:24:12 UTC (rev 5472)
@@ -0,0 +1,293 @@
+#include <png.h>
+
+// To remove a gcc warning
+#ifdef _POSIX_C_SOURCE
+#undef _POSIX_C_SOURCE
+#endif
+
+// TODO: Un CXX-ify this module
+#include "CXX/Extensions.hxx"
+#include "numpy/arrayobject.h"
+#include "mplutils.h"
+
+// the extension module
+class _png_module : public Py::ExtensionModule<_png_module>
+{
+public:
+ _png_module()
+ : Py::ExtensionModule<_png_module>( "_png" )
+ {
+ add_varargs_method("write_png", &_png_module::write_png,
+ "write_png(buffer, width, height, fileobj, dpi=None)");
+ add_varargs_method("read_png", &_png_module::write_png,
+ "read_png(fileobj)");
+ initialize("Module to write PNG files");
+ }
+
+ virtual ~_png_module() {}
+
+private:
+ Py::Object write_png(const Py::Tuple& args);
+ Py::Object read_png(const Py::Tuple& args);
+};
+
+static void write_png_data(png_structp png_ptr, png_bytep data, png_size_t length) {
+ printf("%x %x %d %x\n", png_ptr, data, *data, length);
+ PyObject* py_file_obj = (PyObject*)png_get_io_ptr(png_ptr);
+ PyObject* write_method = PyObject_GetAttrString(py_file_obj, "write");
+ PyObject* result = NULL;
+ if (write_method)
+ result = PyObject_CallFunction(write_method, (char *)"s#", data, length);
+ Py_XDECREF(write_method);
+ Py_XDECREF(result);
+}
+
+static void flush_png_data(png_structp png_ptr) {
+ PyObject* py_file_obj = (PyObject*)png_get_io_ptr(png_ptr);
+ PyObject* flush_method = PyObject_GetAttrString(py_file_obj, "flush");
+ PyObject* result = NULL;
+ if (flush_method)
+ result = PyObject_CallFunction(flush_method, (char *)"");
+ Py_XDECREF(flush_method);
+ Py_XDECREF(result);
+}
+
+// this code is heavily adapted from the paint license, which is in
+// the file paint.license (BSD compatible) included in this
+// distribution. TODO, add license file to MANIFEST.in and CVS
+Py::Object _png_module::write_png(const Py::Tuple& args)
+{
+ args.verify_length(4, 5);
+
+ FILE *fp = NULL;
+ bool close_file = false;
+ Py::Object buffer_obj = Py::Object(args[0]);
+ PyObject* buffer = buffer_obj.ptr();
+ if (!PyObject_CheckReadBuffer(buffer)) {
+ throw Py::TypeError("First argument must be an rgba buffer.");
+ }
+
+ const void* pixBufferPtr = NULL;
+ Py_ssize_t pixBufferLength = 0;
+ if (PyObject_AsReadBuffer(buffer, &pixBufferPtr, &pixBufferLength)) {
+ throw Py::ValueError("Couldn't get data from read buffer.");
+ }
+
+ png_byte* pixBuffer = (png_byte*)pixBufferPtr;
+ int width = (int)Py::Int(args[1]);
+ int height = (int)Py::Int(args[2]);
+
+ if (pixBufferLength < width * height * 4) {
+ throw Py::ValueError("Buffer and width, height don't seem to match.");
+ }
+
+ Py::Object py_fileobj = Py::Object(args[3]);
+ if (py_fileobj.isString()) {
+ std::string fileName = Py::String(py_fileobj);
+ const char *file_name = fileName.c_str();
+ if ((fp = fopen(file_name, "wb")) == NULL)
+ throw Py::RuntimeError( Printf("Could not open file %s", file_name).str() );
+ close_file = true;
+ } else if (PyFile_CheckExact(py_fileobj.ptr())) {
+ fp = PyFile_AsFile(py_fileobj.ptr());
+ }
+ else {
+ PyObject* write_method = PyObject_GetAttrString(py_fileobj.ptr(), "write");
+ if (!(write_method && PyCallable_Check(write_method))) {
+ Py_XDECREF(write_method);
+ throw Py::TypeError("Object does not appear to be a 8-bit string path or a Python file-like object");
+ }
+ Py_XDECREF(write_method);
+ }
+
+ png_bytep *row_pointers = NULL;
+ png_structp png_ptr = NULL;
+ png_infop info_ptr = NULL;
+
+ try {
+ struct png_color_8_struct sig_bit;
+ png_uint_32 row;
+
+ row_pointers = new png_bytep[height];
+ for (row = 0; row < (png_uint_32)height; ++row) {
+ row_pointers[row] = pixBuffer + row * width * 4;
+ }
+
+ png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
+ if (png_ptr == NULL) {
+ throw Py::RuntimeError("Could not create write struct");
+ }
+
+ info_ptr = png_create_info_struct(png_ptr);
+ if (info_ptr == NULL) {
+ throw Py::RuntimeError("Could not create info struct");
+ }
+
+ if (setjmp(png_ptr->jmpbuf)) {
+ throw Py::RuntimeError("Error building image");
+ }
+
+ if (fp) {
+ png_init_io(png_ptr, fp);
+ } else {
+ png_set_write_fn(png_ptr, (void*)py_fileobj.ptr(),
+		 &write_png_data, &flush_png_data);
+ }
+ png_set_IHDR(png_ptr, info_ptr,
+		 width, height, 8,
+		 PNG_COLOR_TYPE_RGB_ALPHA, PNG_INTERLACE_NONE,
+		 PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
+
+ // Save the dpi of the image in the file
+ if (args.size() == 5) {
+ double dpi = Py::Float(args[4]);
+ size_t dots_per_meter = (size_t)(dpi / (2.54 / 100.0));
+ png_set_pHYs(png_ptr, info_ptr, dots_per_meter, dots_per_meter, PNG_RESOLUTION_METER);
+ }
+
+ // this a a color image!
+ sig_bit.gray = 0;
+ sig_bit.red = 8;
+ sig_bit.green = 8;
+ sig_bit.blue = 8;
+ /* if the image has an alpha channel then */
+ sig_bit.alpha = 8;
+ png_set_sBIT(png_ptr, info_ptr, &sig_bit);
+
+ png_write_info(png_ptr, info_ptr);
+ png_write_image(png_ptr, row_pointers);
+ png_write_end(png_ptr, info_ptr);
+ } catch (...) {
+ if (fp && close_file) fclose(fp);
+ delete [] row_pointers;
+ /* Changed calls to png_destroy_write_struct to follow
+ http://www.libpng.org/pub/png/libpng-manual.txt.
+ This ensures the info_ptr memory is released.
+ */
+ if (png_ptr && info_ptr) png_destroy_write_struct(&png_ptr, &info_ptr);
+ throw;
+ }
+
+ png_destroy_write_struct(&png_ptr, &info_ptr);
+ delete [] row_pointers;
+ if (fp && close_file) fclose(fp);
+
+ return Py::Object();
+}
+
+
+Py::Object
+_png_module::read_png(const Py::Tuple& args) {
+
+ args.verify_length(1);
+ std::string fname = Py::String(args[0]);
+
+ png_byte header[8];	// 8 is the maximum size that can be checked
+
+ FILE *fp = fopen(fname.c_str(), "rb");
+ if (!fp)
+ throw Py::RuntimeError(Printf("_image_module::readpng could not open PNG file %s for reading", fname.c_str()).str());
+
+ if (fread(header, 1, 8, fp) != 8)
+ throw Py::RuntimeError("_image_module::readpng: error reading PNG header");
+ if (png_sig_cmp(header, 0, 8))
+ throw Py::RuntimeError("_image_module::readpng: file not recognized as a PNG file");
+
+
+ /* initialize stuff */
+ png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
+
+ if (!png_ptr)
+ throw Py::RuntimeError("_image_module::readpng: png_create_read_struct failed");
+
+ png_infop info_ptr = png_create_info_struct(png_ptr);
+ if (!info_ptr)
+ throw Py::RuntimeError("_image_module::readpng: png_create_info_struct failed");
+
+ if (setjmp(png_jmpbuf(png_ptr)))
+ throw Py::RuntimeError("_image_module::readpng: error during init_io");
+
+ png_init_io(png_ptr, fp);
+ png_set_sig_bytes(png_ptr, 8);
+
+ png_read_info(png_ptr, info_ptr);
+
+ png_uint_32 width = info_ptr->width;
+ png_uint_32 height = info_ptr->height;
+
+ // convert misc color types to rgb for simplicity
+ if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY ||
+ info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
+ png_set_gray_to_rgb(png_ptr);
+ else if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
+ png_set_palette_to_rgb(png_ptr);
+
+
+ int bit_depth = info_ptr->bit_depth;
+ if (bit_depth == 16) png_set_strip_16(png_ptr);
+
+
+ png_set_interlace_handling(png_ptr);
+ png_read_update_info(png_ptr, info_ptr);
+
+ bool rgba = info_ptr->color_type == PNG_COLOR_TYPE_RGBA;
+ if ( (info_ptr->color_type != PNG_COLOR_TYPE_RGB) && !rgba) {
+ std::cerr << "Found color type " << (int)info_ptr->color_type << std::endl;
+ throw Py::RuntimeError("_image_module::readpng: cannot handle color_type");
+ }
+
+ /* read file */
+ if (setjmp(png_jmpbuf(png_ptr)))
+ throw Py::RuntimeError("_image_module::readpng: error during read_image");
+
+ png_bytep *row_pointers = new png_bytep[height];
+ png_uint_32 row;
+
+ for (row = 0; row < height; row++)
+ row_pointers[row] = new png_byte[png_get_rowbytes(png_ptr,info_ptr)];
+
+ png_read_image(png_ptr, row_pointers);
+
+
+
+ int dimensions[3];
+ dimensions[0] = height; //numrows
+ dimensions[1] = width; //numcols
+ dimensions[2] = 4;
+
+ PyArrayObject *A = (PyArrayObject *) PyArray_FromDims(3, dimensions, PyArray_FLOAT);
+
+
+ for (png_uint_32 y = 0; y < height; y++) {
+ png_byte* row = row_pointers[y];
+ for (png_uint_32 x = 0; x < width; x++) {
+
+ png_byte* ptr = (rgba) ? &(row[x*4]) : &(row[x*3]);
+ size_t offset = y*A->strides[0] + x*A->strides[1];
+ //if ((y<10)&&(x==10)) std::cout << "r = " << ptr[0] << " " << ptr[0]/255.0 << std::endl;
+ *(float*)(A->data + offset + 0*A->strides[2]) = (float)(ptr[0]/255.0f);
+ *(float*)(A->data + offset + 1*A->strides[2]) = (float)(ptr[1]/255.0f);
+ *(float*)(A->data + offset + 2*A->strides[2]) = (float)(ptr[2]/255.0f);
+ *(float*)(A->data + offset + 3*A->strides[2]) = rgba ? (float)(ptr[3]/255.0f) : 1.0f;
+ }
+ }
+
+ //free the png memory
+ png_read_end(png_ptr, info_ptr);
+ png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
+ fclose(fp);
+ for (row = 0; row < height; row++)
+ delete [] row_pointers[row];
+ delete [] row_pointers;
+ return Py::asObject((PyObject*)A);
+}
+
+extern "C"
+ DL_EXPORT(void)
+ init_png(void)
+{
+ import_array();
+
+ static _png_module* _png = NULL;
+ _png = new _png_module;
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2008年06月11日 15:49:22
Revision: 5471
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5471&view=rev
Author: mdboom
Date: 2008年06月11日 08:49:11 -0700 (2008年6月11日)
Log Message:
-----------
Fix some mathtext scaling bugs
Add new mathtext symbols
Use mathtext to render math in the docs (the dog-fooding patch!)
Move PNG reading/writing to its own module and remove it from
_backend_agg and _image
Modified Paths:
--------------
 trunk/matplotlib/CHANGELOG
 trunk/matplotlib/doc/conf.py
 trunk/matplotlib/doc/devel/outline.rst
 trunk/matplotlib/doc/sphinxext/mathpng.py
 trunk/matplotlib/doc/users/mathtext.rst
 trunk/matplotlib/examples/pylab_examples/mathtext_examples.py
 trunk/matplotlib/lib/matplotlib/_mathtext_data.py
 trunk/matplotlib/lib/matplotlib/backends/backend_agg.py
 trunk/matplotlib/lib/matplotlib/backends/backend_svg.py
 trunk/matplotlib/lib/matplotlib/image.py
 trunk/matplotlib/lib/matplotlib/mathtext.py
 trunk/matplotlib/lib/matplotlib/texmanager.py
 trunk/matplotlib/matplotlibrc.template
 trunk/matplotlib/setup.py
 trunk/matplotlib/setupext.py
 trunk/matplotlib/src/_backend_agg.cpp
 trunk/matplotlib/src/_backend_agg.h
 trunk/matplotlib/src/_image.cpp
 trunk/matplotlib/src/_image.h
 trunk/matplotlib/src/ft2font.cpp
 trunk/matplotlib/src/ft2font.h
Added Paths:
-----------
 trunk/matplotlib/doc/sphinxext/math_symbol_table.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG	2008年06月11日 15:31:21 UTC (rev 5470)
+++ trunk/matplotlib/CHANGELOG	2008年06月11日 15:49:11 UTC (rev 5471)
@@ -1,3 +1,13 @@
+2008年06月11日 Use matplotlib.mathtext to render math expressions in
+ online docs - MGD
+
+2008年06月11日 Move PNG loading/saving to its own extension module, and
+ remove duplicate code in _backend_agg.cpp and _image.cpp
+ that does the same thing - MGD
+
+2008年06月11日 Numerous mathtext bugfixes, primarily related to
+ dpi-independence - MGD
+
 2008年06月10日 Bar now applies the label only to the first patch only, and
 sets '_nolegend_' for the other patch labels. This lets
 autolegend work as expected for hist and bar - see
Modified: trunk/matplotlib/doc/conf.py
===================================================================
--- trunk/matplotlib/doc/conf.py	2008年06月11日 15:31:21 UTC (rev 5470)
+++ trunk/matplotlib/doc/conf.py	2008年06月11日 15:49:11 UTC (rev 5471)
@@ -27,7 +27,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 = ['mathpng', 'sphinx.ext.autodoc']
+extensions = ['mathpng', 'math_symbol_table', 'sphinx.ext.autodoc']
 
 # Add any paths that contain templates here, relative to this directory.
 templates_path = ['_templates']
@@ -150,7 +150,11 @@
 latex_logo = None
 
 # Additional stuff for the LaTeX preamble.
-latex_preamble = ''
+latex_preamble = """
+ \usepackage{amsmath}
+ \usepackage{amsfonts}
+ \usepackage{amssymb}
+"""
 
 # Documents to append as an appendix to all manuals.
 latex_appendices = []
Modified: trunk/matplotlib/doc/devel/outline.rst
===================================================================
--- trunk/matplotlib/doc/devel/outline.rst	2008年06月11日 15:31:21 UTC (rev 5470)
+++ trunk/matplotlib/doc/devel/outline.rst	2008年06月11日 15:49:11 UTC (rev 5471)
@@ -113,13 +113,29 @@
 ported over to rest and included in the API so the links from the
 user's guide tutorial work.
 
+ - There's nothing in the mathtext module that I really consider a
+ "public" API (i.e. that would be useful to people just doing
+ plots). If mathtext.py were to be documented, I would put it in
+ the developer's docs. Maybe I should just take the link in the
+ user's guide out. - MGD
+
 #. This section might also benefit from a little more detail on the
 customizations that are possible (eg an example fleshing out the rc
 options a little bit). Admittedly, this is pretty clear from
 readin ghte rc file, but it might be helpful to a newbie.
 
+ - The only rcParam that is currently useful is mathtext.fontset,
+ which is documented here. The others only apply when
+ mathtext.fontset == 'custom', which I'd like to declare
+ "unsupported". It's really hard to get a good set of math fonts
+ working that way, though it might be useful in a bind when
+ someone has to use a specific wacky font for mathtext and only
+ needs basics, like sub/superscripts. - MGD
+
 #. There is still a TODO in the file to include a complete list of symbols
 
+ - Done. It's pretty extensive, thanks to STIX... - MGD
+
 coding guide (reviewed by EF)
 -----------------------------
 
Added: trunk/matplotlib/doc/sphinxext/math_symbol_table.py
===================================================================
--- trunk/matplotlib/doc/sphinxext/math_symbol_table.py	 (rev 0)
+++ trunk/matplotlib/doc/sphinxext/math_symbol_table.py	2008年06月11日 15:49:11 UTC (rev 5471)
@@ -0,0 +1,164 @@
+symbols = [
+ ["Lower-case Greek",
+ 5,
+ r"""\alpha \beta \gamma \chi \delta \epsilon \eta \iota \kappa
+ \lambda \mu \nu \omega \phi \pi \psi \rho \sigma \tau \theta
+ \upsilon \xi \zeta \digamma \varepsilon \varkappa \varphi
+ \varpi \varrho \varsigma \vartheta"""],
+ ["Upper-case Greek",
+ 6,
+ r"""\Delta \Gamma \Lambda \Omega \Phi \Pi \Psi \Sigma \Theta
+ \Upsilon \Xi \mho \nabla"""],
+ ["Hebrew",
+ 4,
+ r"""\aleph \beth \daleth \gimel"""],
+ ["Delimiters",
+ 6,
+ r"""| \{ \lfloor / \Uparrow \llcorner \vert \} \rfloor \backslash
+ \uparrow \lrcorner \| \langle \lceil [ \Downarrow \ulcorner
+ \Vert \rangle \rceil ] \downarrow \urcorner"""],
+ ["Big symbols",
+ 5,
+ r"""\bigcap \bigcup \bigodot \bigoplus \bigotimes \biguplus
+ \bigvee \bigwedge \coprod \oint \prod \sum \int"""],
+ ["Standard Function Names",
+ 4,
+ r"""\arccos \csc \ker \min \arcsin \deg \lg \Pr \arctan \det \lim
+ \gcd \ln \sup \cot \hom \log \tan \coth \inf \max \tanh
+ \sec \arg \dim \liminf \sin \cos \exp \limsup \sinh \cosh"""],
+ ["Binary Operation and Relation Symbols",
+ 3,
+ r"""\ast \pm \slash \cap \star \mp \cup \cdot \uplus
+ \triangleleft \circ \odot \sqcap \triangleright \bullet \ominus
+ \sqcup \bigcirc \oplus \wedge \diamond \oslash \vee
+ \bigtriangledown \times \otimes \dag \bigtriangleup \div \wr
+ \ddag \barwedge \veebar \boxplus \curlywedge \curlyvee \boxminus
+ \Cap \Cup \boxtimes \bot \top \dotplus \boxdot \intercal
+ \rightthreetimes \divideontimes \leftthreetimes \equiv \leq \geq
+ \perp \cong \prec \succ \mid \neq \preceq \succeq \parallel \sim
+ \ll \gg \bowtie \simeq \subset \supset \Join \approx \subseteq
+ \supseteq \ltimes \asymp \sqsubset \sqsupset \rtimes \doteq
+ \sqsubseteq \sqsupseteq \smile \propto \dashv \vdash \frown
+ \models \in \ni \notin \approxeq \leqq \geqq \lessgtr \leqslant
+ \geqslant \lesseqgtr \backsim \lessapprox \gtrapprox \lesseqqgtr
+ \backsimeq \lll \ggg \gtreqqless \triangleq \lessdot \gtrdot
+ \gtreqless \circeq \lesssim \gtrsim \gtrless \bumpeq \eqslantless
+ \eqslantgtr \backepsilon \Bumpeq \precsim \succsim \between
+ \doteqdot \precapprox \succapprox \pitchfork \Subset \Supset
+ \fallingdotseq \subseteqq \supseteqq \risingdotseq \sqsubset
+ \sqsupset \varpropto \preccurlyeq \succcurlyeq \Vdash \therefore
+ \curlyeqprec \curlyeqsucc \vDash \because \blacktriangleleft
+ \blacktriangleright \Vvdash \eqcirc \trianglelefteq
+ \trianglerighteq \neq \vartriangleleft \vartriangleright \ncong
+ \nleq \ngeq \nsubseteq \nmid \nsupseteq \nparallel \nless \ngtr
+ \nprec \nsucc \subsetneq \nsim \supsetneq \nVDash \precnapprox
+ \succnapprox \subsetneqq \nvDash \precnsim \succnsim \supsetneqq
+ \nvdash \lnapprox \gnapprox \ntriangleleft \ntrianglelefteq
+ \lneqq \gneqq \ntriangleright \lnsim \gnsim \ntrianglerighteq
+ \approxident \origof \imageof \coloneq \triangleeq \stareq \nsime
+ \dotminus \eqsim \nequiv \Equiv \measeq \napprox \eqless
+ \kernelcontraction \nsupset \doublebarwedge \nVdash \arceq
+ \backcong \Doteq \eqdef \wedgeq \questeq \eqgtr \cupdot
+ \veeeq \nsubset \eqcolon \ne
+ """],
+ ["Arrow Symbols",
+ 2,
+ r"""\leftarrow \longleftarrow \uparrow \Leftarrow \Longleftarrow
+ \Uparrow \rightarrow \longrightarrow \downarrow \Rightarrow
+ \Longrightarrow \Downarrow \leftrightarrow \updownarrow
+ \longleftrightarrow \updownarrow \Leftrightarrow
+ \Longleftrightarrow \Updownarrow \mapsto \longmapsto \nearrow
+ \hookleftarrow \hookrightarrow \searrow \leftharpoonup
+ \rightharpoonup \swarrow \leftharpoondown \rightharpoondown
+ \nwarrow \rightleftharpoons \leadsto \dashrightarrow
+ \dashleftarrow \leftleftarrows \leftrightarrows \Lleftarrow
+ \Rrightarrow \twoheadleftarrow \leftarrowtail \looparrowleft
+ \leftrightharpoons \curvearrowleft \circlearrowleft \Lsh
+ \upuparrows \upharpoonleft \downharpoonleft \multimap
+ \leftrightsquigarrow \rightrightarrows \rightleftarrows
+ \rightrightarrows \rightleftarrows \twoheadrightarrow
+ \rightarrowtail \looparrowright \rightleftharpoons
+ \curvearrowright \circlearrowright \Rsh \downdownarrows
+ \upharpoonright \downharpoonright \rightsquigarrow \nleftarrow
+ \nrightarrow \nLeftarrow \nRightarrow \nleftrightarrow
+ \nLeftrightarrow \to \Swarrow \Searrow \Nwarrow \Nearrow
+ \barleftarrow \mapsup \mapsdown \mapsfrom \rightarrowbar
+ \twoheaduparrow \updownarrowbar \leftsquigarrow \rightzigzagarrow
+ \twoheaddownarrow \downzigzagarrow
+ """],
+ ["Miscellaneous Symbols",
+ 3,
+ r"""\neg \invnot \turnednot \infty \forall \wp \exists \bigstar
+ \angle \partial \nexists \measuredangle \eth \emptyset
+ \sphericalangle \clubsuit \varnothing \complement \diamondsuit
+ \imath \Finv \triangledown \heartsuit \jmath \Game \spadesuit
+ \ell \hbar \vartriangle \cdots \hslash \vdots \blacksquare \ldots
+ \blacktriangle \ddots \sharp \prime \blacktriangledown \Im \flat
+ \backprime \Re \natural \circledS \P \O \copyright \ss \Ldsh
+ \frakZ \l \carriagereturn \circledR \S \sterling \L \yen \danger
+ \d \OE \AA \AE \scurel \oe \o \checkmark \Rdsh \ae \ac \prurel \$
+ \iiint \iint \iint \oiiint"""]
+]
+
+from docutils import nodes, statemachine
+from docutils.parsers.rst import Directive
+class math_symbol_table_directive(Directive):
+ has_content = True
+ def run(self):
+ def get_n(n, l):
+ part = []
+ for x in l:
+ part.append(x)
+ if len(part) == n:
+ yield part
+ part = []
+ yield part
+
+ lines = []
+ for category, columns, syms in symbols:
+ syms = syms.split()
+ syms.sort()
+ lines.append("**%s**" % category)
+ lines.append('')
+ max_width = 0
+ for sym in syms:
+ max_width = max(max_width, len(sym))
+ max_width = max_width * 2 + 16
+ header = " " + (('=' * max_width) + ' ') * columns
+ format = '%%%ds' % max_width
+ for chunk in get_n(20, get_n(columns, syms)):
+ lines.append(header)
+ for part in chunk:
+ line = []
+ for sym in part:
+ line.append(format % (":math:`%s` ``%s``" % (sym, sym)))
+ lines.append(" " + " ".join(line))
+ lines.append(header)
+ lines.append('')
+ self.state_machine.insert_input(lines, "Symbol table")
+ return []
+
+from docutils.parsers.rst import directives
+directives.register_directive('math_symbol_table',
+ math_symbol_table_directive)
+
+if __name__ == "__main__":
+ # Do some verification of the tables
+ from matplotlib import _mathtext_data
+
+ print "SYMBOLS NOT IN STIX:"
+ all_symbols = {}
+ for category, columns, syms in symbols:
+ if category == "Standard Function Names":
+ continue
+ syms = syms.split()
+ for sym in syms:
+ if len(sym) > 1:
+ all_symbols[sym[1:]] = None
+ if sym[1:] not in _mathtext_data.tex2uni:
+ print sym
+
+ print "SYMBOLS NOT IN TABLE:"
+ for sym in _mathtext_data.tex2uni:
+ if sym not in all_symbols:
+ print sym
Modified: trunk/matplotlib/doc/sphinxext/mathpng.py
===================================================================
--- trunk/matplotlib/doc/sphinxext/mathpng.py	2008年06月11日 15:31:21 UTC (rev 5470)
+++ trunk/matplotlib/doc/sphinxext/mathpng.py	2008年06月11日 15:49:11 UTC (rev 5471)
@@ -3,7 +3,7 @@
 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
@@ -39,7 +39,7 @@
 else:
 class math_directive(Directive):
 has_content = True
- def run(self): 
+ def run(self):
 latex = ' '.join(self.content)
 node = latex_math(self.block_text)
 node['latex'] = latex
@@ -75,26 +75,44 @@
 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)
+
+# This uses mathtext to render the expression
+def latex2png(latex, filename):
+ from matplotlib import rcParams
+ from matplotlib import _png
+ from matplotlib.mathtext import MathTextParser
+ rcParams['mathtext.fontset'] = 'cm'
+ mathtext_parser = MathTextParser("Bitmap")
+ ftimage = mathtext_parser.parse("$%s$" % latex, 120)
+ _png.write_png(ftimage.as_rgba_str(), ftimage.get_width(),
+ ftimage.get_height(), filename)
+
 # LaTeX to HTML translation stuff:
 def latex2html(node, source):
 inline = isinstance(node.parent, nodes.TextElement)
 latex = node['latex']
- print latex
- name = 'math-' + md5(latex).hexdigest()[-10:]
- if not isfile('_static/%s.png' % 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 _static/%s.png math.dvi > /dev/null' % name)
+ 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):
@@ -110,3 +128,4 @@
 else:
 cls = 'class="center" '
 return '<img src="%s/%s.png" %s%s/>' % (path, name, align, cls)
+
Modified: trunk/matplotlib/doc/users/mathtext.rst
===================================================================
--- trunk/matplotlib/doc/users/mathtext.rst	2008年06月11日 15:31:21 UTC (rev 5470)
+++ trunk/matplotlib/doc/users/mathtext.rst	2008年06月11日 15:49:11 UTC (rev 5471)
@@ -3,13 +3,11 @@
 Writing mathematical expressions
 ================================
 
-
-You can use TeX markup in any matplotlib text string; see the
-:mod:`matplotlib.mathtext` module documentation for details. Note
-that you do not need to have TeX installed, since matplotlib ships its
-own TeX expression parser, layout engine and fonts. The layout engine
-is a fairly direct adaptation of the layout algorithms in Donald
-Knuth's TeX, so the quality is quite good (matplotlib also provides a
+You can use TeX markup in any matplotlib text string. Note that you
+do not need to have TeX installed, since matplotlib ships its own TeX
+expression parser, layout engine and fonts. The layout engine is a
+fairly direct adaptation of the layout algorithms in Donald Knuth's
+TeX, so the quality is quite good (matplotlib also provides a
 ``usetex`` option for those who do want to call out to TeX to generate
 their text (see :ref:`usetex-tutorial`).
 
@@ -37,9 +35,6 @@
 
 produces ":math:`\alpha > \beta`".
 
-.. TODO: Include a complete list here
-
-
 Subscripts and superscripts
 ---------------------------
 
@@ -106,7 +101,7 @@
 Radicals
 --------
 
-Radicals can be produced with the ``\sqrt[]{}`` command. For example:
+Radicals can be produced with the ``\sqrt[]{}`` command. For example::
 
 r'$\sqrt{2}$'
 
@@ -116,7 +111,7 @@
 
 Any base can (optionally) be provided inside square brackets. Note
 that the base must be a simple expression, and can not contain layout
-commands such as fractions or sub/superscripts.
+commands such as fractions or sub/superscripts::
 
 r'$\sqrt[3]{x}$'
 
@@ -181,6 +176,42 @@
 
 .. image:: ../_static/stixsans_fontset.png
 
+Custom fonts
+~~~~~~~~~~~~
+
+mathtext also provides a way to use custom fonts for math. This
+method is fairly tricky to use, and should be considered an
+experimental feature for patient users only. By setting the rcParam
+``mathtext.fontset`` to ``custom``, you can then set the following
+parameters, which control which font file to use for a particular set
+of math characters.
+
+ ============================== =================================
+ Parameter Corresponds to
+ ============================== =================================
+ ``mathtext.it`` ``\mathit{}`` or default italic
+ ``mathtext.rm`` ``\mathrm{}`` Roman (upright)
+ ``mathtext.tt`` ``\mathtt{}`` Typewriter (monospace)
+ ``mathtext.bf`` ``\mathbf{}`` bold italic
+ ``mathtext.cal`` ``\mathcal{}`` calligraphic
+ ``mathtext.sf`` ``\mathsf{}`` sans-serif
+ ============================== =================================
+
+Each parameter should be set to a fontconfig font descriptor (as
+defined in the yet-to-be-written font chapter).
+
+.. TODO: Link to font chapter
+
+The fonts used should have a Unicode mapping in order to find any
+non-Latin characters, such as Greek. If you want to use a math symbol
+that is not contained in your custom fonts, you can set the rcParam
+``mathtext.fallback_to_cm`` to ``True`` which will cause the mathtext
+system to use characters from the default Computer Modern fonts
+whenever a particular character can not be found in the custom font.
+
+Note that the math glyphs specified in Unicode have evolved over time,
+and many fonts may not have glyphs in the correct place for mathtext.
+
 Accents
 -------
 
@@ -211,19 +242,29 @@
 ``\widetilde{xyz}`` :math:`\widetilde{xyz}`
 ============================== =================================
 
+Care should be taken when putting accents on lower-case i's and j's.
+Note that in the following ``\mathi`` is used to avoid the extra dot
+over the i::
 
+ r"$\hat i\ \ \hat \imath$"
+
+.. math::
+
+ \hat i\ \ \hat \imath
+
 Symbols
 -------
 
 You can also use a large number of the TeX symbols, as in ``\infty``,
-``\leftarrow``, ``\sum``, ``\int``; see :mod:`matplotlib.mathtext` for a
-complete list.
+``\leftarrow``, ``\sum``, ``\int``.
 
+.. math_symbol_table::
+
 If a particular symbol does not have a name (as is true of many of the
 more obscure symbols in the STIX fonts), Unicode characters can
 also be used::
 
- ur'Generic symbol: $\u23ce$'
+ ur'$\u23ce$'
 
 Example
 -------
Modified: trunk/matplotlib/examples/pylab_examples/mathtext_examples.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/mathtext_examples.py	2008年06月11日 15:31:21 UTC (rev 5470)
+++ trunk/matplotlib/examples/pylab_examples/mathtext_examples.py	2008年06月11日 15:49:11 UTC (rev 5471)
@@ -5,7 +5,7 @@
 import gc
 
 stests = [
- r'Kerning: AVA $AVA$ $$',
+ r'$x \doteq y$',
 r'\100ドル.00 $\alpha \_$',
 r'$\frac{\100ドル.00}{y}$',
 r'$x y$',
Modified: trunk/matplotlib/lib/matplotlib/_mathtext_data.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/_mathtext_data.py	2008年06月11日 15:31:21 UTC (rev 5470)
+++ trunk/matplotlib/lib/matplotlib/_mathtext_data.py	2008年06月11日 15:49:11 UTC (rev 5471)
@@ -37,6 +37,8 @@
 r'\}' : ('cmex10', 130),
 r'\leftangle' : ('cmex10', 97),
 r'\rightangle' : ('cmex10', 64),
+ r'\langle' : ('cmex10', 97),
+ r'\rangle' : ('cmex10', 64),
 r'\widehat' : ('cmex10', 15),
 r'\widetilde' : ('cmex10', 52),
 
@@ -1758,6 +1760,54 @@
 tex2uni = {
 'widehat': 0x0302,
 'widetilde': 0x0303,
+'langle': 0x27e8,
+'rangle': 0x27e9,
+'perp': 0x27c2,
+'neq': 0x2260,
+'Join': 0x2a1d,
+'leqslant': 0x2a7d,
+'geqslant': 0x2a7e,
+'lessapprox': 0x2a85,
+'gtrapprox': 0x2a86,
+'lesseqqgtr': 0x2a8b,
+'gtreqqless': 0x2a8c,
+'triangleeq': 0x225c,
+'eqslantless': 0x2a95,
+'eqslantgtr': 0x2a96,
+'backepsilon': 0x03f6,
+'precapprox': 0x2ab7,
+'succapprox': 0x2ab8,
+'fallingdotseq': 0x2252,
+'subseteqq': 0x2ac5,
+'supseteqq': 0x2ac6,
+'varpropto': 0x221d,
+'precnapprox': 0x2ab9,
+'succnapprox': 0x2aba,
+'subsetneqq': 0x2acb,
+'supsetneqq': 0x2acc,
+'lnapprox': 0x2ab9,
+'gnapprox': 0x2aba,
+'longleftarrow': 0x27f5,
+'longrightarrow': 0x27f6,
+'longleftrightarrow': 0x27f7,
+'Longleftarrow': 0x27f8,
+'Longrightarrow': 0x27f9,
+'Longleftrightarrow': 0x27fa,
+'longmapsto': 0x27fc,
+'leadsto': 0x21dd,
+'dashleftarrow': 0x290e,
+'dashrightarrow': 0x290f,
+'circlearrowleft': 0x21ba,
+'circlearrowright': 0x21bb,
+'leftrightsquigarrow': 0x21ad,
+'leftsquigarrow': 0x219c,
+'rightsquigarrow': 0x219d,
+'Game': 0x2141,
+'hbar': 0x0127,
+'hslash': 0x210f,
+'ldots': 0x22ef,
+'vdots': 0x22ee,
+'doteqdot': 0x2251,
 'doteq': 8784,
 'partial': 8706,
 'gg': 8811,
@@ -1922,7 +1972,7 @@
 'napprox': 8777,
 'ast': 8727,
 'twoheaduparrow': 8607,
-'doublebarwedge ?': 8966,
+'doublebarwedge': 8966,
 'Sigma': 931,
 'leftharpoonaccent': 8400,
 'ntrianglelefteq': 8940,
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_agg.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_agg.py	2008年06月11日 15:31:21 UTC (rev 5470)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_agg.py	2008年06月11日 15:49:11 UTC (rev 5471)
@@ -40,6 +40,7 @@
 from matplotlib.transforms import Affine2D, Bbox
 
 from _backend_agg import RendererAgg as _RendererAgg
+from matplotlib import _png
 
 backend_version = 'v2.2'
 
@@ -302,5 +303,9 @@
 renderer.dpi = self.figure.dpi
 if is_string_like(filename_or_obj):
 filename_or_obj = file(filename_or_obj, 'wb')
- self.get_renderer()._renderer.write_png(filename_or_obj, self.figure.dpi)
+ renderer = self.get_renderer()
+ x = renderer._renderer.buffer_rgba(0, 0)
+ _png.write_png(renderer._renderer.buffer_rgba(0, 0),
+ renderer.width, renderer.height,
+ filename_or_obj, self.figure.dpi)
 renderer.dpi = original_dpi
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_svg.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py	2008年06月11日 15:31:21 UTC (rev 5470)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_svg.py	2008年06月11日 15:49:11 UTC (rev 5471)
@@ -1,6 +1,6 @@
 from __future__ import division
 
-import os, codecs, base64, tempfile, urllib, gzip, md5
+import os, codecs, base64, tempfile, urllib, gzip, md5, cStringIO
 
 from matplotlib import verbose, __version__, rcParams
 from matplotlib.backend_bases import RendererBase, GraphicsContextBase,\
@@ -14,6 +14,7 @@
 from matplotlib.mathtext import MathTextParser
 from matplotlib.path import Path
 from matplotlib.transforms import Affine2D
+from matplotlib import _png
 
 from xml.sax.saxutils import escape as escape_xml_text
 
@@ -46,6 +47,7 @@
 self._char_defs = {}
 self._markers = {}
 self._path_collection_id = 0
+ self._imaged = {}
 self.mathtext_parser = MathTextParser('SVG')
 svgwriter.write(svgProlog%(width,height,width,height))
 
@@ -267,33 +269,20 @@
 )
 
 if rcParams['svg.image_inline']:
- class Base64Writer(object):
- def __init__(self, write_method):
- self._write_method = write_method
- self._buffer = ''
- def write(self, data):
- self._buffer += data
- while len(self._buffer) >= 64:
- self._write_method(base64.encodestring(buffer[:64]))
- self._write_method('\n')
- self._buffer = self._buffer[64:]
- def flush(self):
- self._write_method(base64.encodestring(self._buffer))
- self._write_method('\n')
-
 self._svgwriter.write("data:image/png;base64,\n")
- base64writer = Base64Writer(self._svgwriter.write)
-
+ stringio = cStringIO.StringIO()
 im.flipud_out()
- im.write_png(base64writer)
+ rows, cols, buffer = im.as_rgba_str()
+ _png.write_png(buffer, cols, rows, stringio)
 im.flipud_out()
- base64writer.flush()
+ self._svgwriter.write(base64.encodestring(stringio.getvalue()))
 else:
 self._imaged[self.basename] = self._imaged.get(self.basename,0) + 1
 filename = '%s.image%d.png'%(self.basename, self._imaged[self.basename])
 verbose.report( 'Writing image file for inclusion: %s' % filename)
 im.flipud_out()
- im.write_png(filename)
+ rows, cols, buffer = im.as_rgba_str()
+ _png.write_png(buffer, cols, rows, filename)
 im.flipud_out()
 self._svgwriter.write(filename)
 
Modified: trunk/matplotlib/lib/matplotlib/image.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/image.py	2008年06月11日 15:31:21 UTC (rev 5470)
+++ trunk/matplotlib/lib/matplotlib/image.py	2008年06月11日 15:49:11 UTC (rev 5471)
@@ -16,6 +16,7 @@
 
 # For clarity, names from _image are given explicitly in this module:
 from matplotlib import _image
+from matplotlib import _png
 
 # For user convenience, the names from _image are also imported into
 # the image namespace:
@@ -256,12 +257,13 @@
 """Write the image to png file with fname"""
 im = self.make_image()
 if noscale:
- numrows,numcols = im.get_size()
+ numrows, numcols = im.get_size()
 im.reset_matrix()
 im.set_interpolation(0)
 im.resize(numcols, numrows)
 im.flipud_out()
- im.write_png(fname)
+ rows, cols, buffer = im.as_rgba_str()
+ _png.write_png(buffer, cols, rows, fname)
 
 def set_data(self, A, shape=None):
 """
@@ -661,7 +663,8 @@
 def write_png(self, fname):
 """Write the image to png file with fname"""
 im = self.make_image()
- im.write_png(fname)
+ rows, cols, buffer = im.as_rgba_str()
+ _png.write_png(buffer, cols, rows, fname)
 
 def imread(fname):
 """
@@ -686,7 +689,7 @@
 return pil_to_array(image)
 
 
- handlers = {'png' :_image.readpng,
+ handlers = {'png' :_png.read_png,
 }
 basename, ext = os.path.splitext(fname)
 ext = ext.lower()[1:]
Modified: trunk/matplotlib/lib/matplotlib/mathtext.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mathtext.py	2008年06月11日 15:31:21 UTC (rev 5470)
+++ trunk/matplotlib/lib/matplotlib/mathtext.py	2008年06月11日 15:49:11 UTC (rev 5471)
@@ -655,8 +655,9 @@
 return xHeight
 
 def get_underline_thickness(self, font, fontsize, dpi):
- cached_font = self._get_font(font)
- return (cached_font.font.underline_thickness / 64.0 / fontsize) * (dpi)
+ # This function used to grab underline thickness from the font,
+ # but that information is just too un-reliable, so it is now hardcoded.
+ return ((0.75 / 12.0) * fontsize * dpi) / 72.0
 
 def get_kern(self, font1, fontclass1, sym1, fontsize1,
 font2, fontclass2, sym2, fontsize2, dpi):
@@ -682,6 +683,8 @@
 fontmap = {}
 
 def __init__(self, *args, **kwargs):
+ self._stix_fallback = StixFonts(*args, **kwargs)
+
 TruetypeFonts.__init__(self, *args, **kwargs)
 if not len(self.fontmap):
 for key, val in self._fontmap.iteritems():
@@ -689,6 +692,7 @@
 self.fontmap[key] = fullpath
 self.fontmap[val] = fullpath
 
+
 _slanted_symbols = Set(r"\int \oint".split())
 
 def _get_glyph(self, fontname, font_class, sym, fontsize):
@@ -717,6 +721,7 @@
 cached_font.charmap[num])
 
 if symbol_name is None:
+ return self._stix_fallback._get_glyph(fontname, font_class, sym, fontsize)
 warn("Unrecognized symbol '%s'. Substituting with a dummy symbol."
 % sym.encode('ascii', 'backslashreplace'), MathTextWarning)
 fontname = 'it'
@@ -868,6 +873,8 @@
 return self.cm_fallback._get_glyph(
 fontname, 'it', sym, fontsize)
 else:
+ if fontname == 'it' and isinstance(self, StixFonts):
+ return self._get_glyph('rm', font_class, sym, fontsize)
 warn("Substituting with a dummy symbol.", MathTextWarning)
 fontname = 'rm'
 new_fontname = fontname
@@ -2031,7 +2038,8 @@
 
 bslash = Literal('\\')
 
- accent = oneOf(self._accent_map.keys() + list(self._wide_accents))
+ accent = oneOf(self._accent_map.keys() +
+ list(self._wide_accents))
 
 function = oneOf(list(self._function_names))
 
@@ -2057,10 +2065,10 @@
 
 unicode_range = u"\U00000080-\U0001ffff"
 symbol =(Regex(UR"([a-zA-Z0-9 +\-*/<>=:,.;!'@()\[\]|%s])|(\\[%%${}\[\]_|])" % unicode_range)
- | Combine(
+ | (Combine(
 bslash
 + oneOf(tex2uni.keys())
- )
+ ) + FollowedBy(Regex("[^a-zA-Z]")))
 ).setParseAction(self.symbol).leaveWhitespace()
 
 c_over_c =(Suppress(bslash)
@@ -2486,14 +2494,14 @@
 if super is not None:
 hlist = HCentered([super])
 hlist.hpack(width, 'exactly')
- vlist.extend([hlist, Kern(rule_thickness * 2.0)])
+ vlist.extend([hlist, Kern(rule_thickness * 3.0)])
 hlist = HCentered([nucleus])
 hlist.hpack(width, 'exactly')
 vlist.append(hlist)
 if sub is not None:
 hlist = HCentered([sub])
 hlist.hpack(width, 'exactly')
- vlist.extend([Kern(rule_thickness * 2.0), hlist])
+ vlist.extend([Kern(rule_thickness * 3.0), hlist])
 shift = hlist.height + hlist.depth + rule_thickness * 2.0
 vlist = Vlist(vlist)
 vlist.shift_amount = shift + nucleus.depth * 0.5
Modified: trunk/matplotlib/lib/matplotlib/texmanager.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/texmanager.py	2008年06月11日 15:31:21 UTC (rev 5470)
+++ trunk/matplotlib/lib/matplotlib/texmanager.py	2008年06月11日 15:49:11 UTC (rev 5471)
@@ -38,7 +38,7 @@
 import numpy as np
 import matplotlib as mpl
 from matplotlib import rcParams
-from matplotlib._image import readpng
+from matplotlib._png import read_png
 
 DEBUG = False
 
@@ -364,7 +364,7 @@
 
 if alpha is None:
 pngfile = self.make_png(tex, fontsize, dpi)
- X = readpng(os.path.join(self.texcache, pngfile))
+ X = read_png(os.path.join(self.texcache, pngfile))
 
 if rcParams['text.dvipnghack'] is not None:
 hack = rcParams['text.dvipnghack']
Modified: trunk/matplotlib/matplotlibrc.template
===================================================================
--- trunk/matplotlib/matplotlibrc.template	2008年06月11日 15:31:21 UTC (rev 5470)
+++ trunk/matplotlib/matplotlibrc.template	2008年06月11日 15:49:11 UTC (rev 5471)
@@ -162,6 +162,8 @@
 # The following settings allow you to select the fonts in math mode.
 # They map from a TeX font name to a fontconfig font pattern.
 # These settings are only used if mathtext.fontset is 'custom'.
+# Note that this "custom" mode is unsupported and may go away in the
+# future.
 #mathtext.cal : cursive
 #mathtext.rm : serif
 #mathtext.tt : monospace
Modified: trunk/matplotlib/setup.py
===================================================================
--- trunk/matplotlib/setup.py	2008年06月11日 15:31:21 UTC (rev 5470)
+++ trunk/matplotlib/setup.py	2008年06月11日 15:49:11 UTC (rev 5471)
@@ -34,7 +34,7 @@
 check_for_cairo, check_provide_traits, check_provide_pytz, \
 check_provide_dateutil, check_provide_configobj, check_for_dvipng, \
 check_for_ghostscript, check_for_latex, check_for_pdftops, \
- check_for_datetime, options
+ check_for_datetime, options, build_png
 #import distutils.sysconfig
 
 # jdh
@@ -100,16 +100,20 @@
 
 print_raw("")
 print_raw("OPTIONAL BACKEND DEPENDENCIES")
+has_libpng = check_for_libpng()
 
-if check_for_libpng() and options['build_agg']:
+if has_libpng and options['build_agg']:
 build_agg(ext_modules, packages)
 rc['backend'] = 'Agg'
 else:
 rc['backend'] = 'SVG'
 
-if options['build_image']:
+if has_libpng and options['build_image']:
 build_image(ext_modules, packages)
 
+if has_libpng and options['build_agg'] or options['build_image']:
+ build_png(ext_modules, packages)
+
 if options['build_windowing'] and sys.platform=='win32':
 build_windowing(ext_modules, packages)
 
Modified: trunk/matplotlib/setupext.py
===================================================================
--- trunk/matplotlib/setupext.py	2008年06月11日 15:31:21 UTC (rev 5470)
+++ trunk/matplotlib/setupext.py	2008年06月11日 15:49:11 UTC (rev 5471)
@@ -79,6 +79,7 @@
 True = True
 False = False
 
+BUILT_PNG = False
 BUILT_AGG = False
 BUILT_FT2FONT = False
 BUILT_TTCONV = False
@@ -248,9 +249,6 @@
 
 status, output = commands.getstatusoutput(
 "%s %s %s" % (pkg_config_exec, flags, packages))
- #if packages.startswith('pygtk'):
- # print 'status', status, output
- # raise SystemExit
 if status == 0:
 for token in output.split():
 attr = _flags.get(token[:2], None)
@@ -570,12 +568,18 @@
 import numpy
 module.include_dirs.append(numpy.get_include())
 
+def add_png_flags(module):
+ try_pkgconfig(module, 'libpng', 'png')
+ add_base_flags(module)
+ add_numpy_flags(module)
+ module.libraries.append('z')
+ module.include_dirs.extend(['.'])
+ module.libraries.extend(std_libs)
+
 def add_agg_flags(module):
 'Add the module flags to build extensions which use agg'
 
 # before adding the freetype flags since -z comes later
- try_pkgconfig(module, 'libpng', 'png')
- module.libraries.append('z')
 add_base_flags(module)
 add_numpy_flags(module)
 module.include_dirs.extend(['src', '%s/include'%AGG_VERSION, '.'])
@@ -1201,7 +1205,26 @@
 ext_modules.append(module)
 BUILT_WXAGG = True
 
+def build_png(ext_modules, packages):
+ global BUILT_PNG
+ if BUILT_PNG: return # only build it if you you haven't already
 
+ deps = ['src/_png.cpp', 'src/mplutils.cpp']
+ deps.extend(glob.glob('CXX/*.cxx'))
+ deps.extend(glob.glob('CXX/*.c'))
+
+ module = Extension(
+ 'matplotlib._png',
+ deps,
+ include_dirs=numpy_inc_dirs,
+ )
+
+ add_png_flags(module)
+ ext_modules.append(module)
+
+ BUILT_PNG = True
+
+
 def build_agg(ext_modules, packages):
 global BUILT_AGG
 if BUILT_AGG: return # only build it if you you haven't already
Modified: trunk/matplotlib/src/_backend_agg.cpp
===================================================================
--- trunk/matplotlib/src/_backend_agg.cpp	2008年06月11日 15:31:21 UTC (rev 5470)
+++ trunk/matplotlib/src/_backend_agg.cpp	2008年06月11日 15:49:11 UTC (rev 5471)
@@ -1356,136 +1356,7 @@
 return Py::Object();
 }
 
-static void write_png_data(png_structp png_ptr, png_bytep data, png_size_t length) {
- PyObject* py_file_obj = (PyObject*)png_get_io_ptr(png_ptr);
- PyObject* write_method = PyObject_GetAttrString(py_file_obj, "write");
- PyObject* result = NULL;
- if (write_method)
- result = PyObject_CallFunction(write_method, (char *)"s#", data, length);
- Py_XDECREF(write_method);
- Py_XDECREF(result);
-}
-
-static void flush_png_data(png_structp png_ptr) {
- PyObject* py_file_obj = (PyObject*)png_get_io_ptr(png_ptr);
- PyObject* flush_method = PyObject_GetAttrString(py_file_obj, "flush");
- PyObject* result = NULL;
- if (flush_method)
- result = PyObject_CallFunction(flush_method, (char *)"");
- Py_XDECREF(flush_method);
- Py_XDECREF(result);
-}
-
-// this code is heavily adapted from the paint license, which is in
-// the file paint.license (BSD compatible) included in this
-// distribution. TODO, add license file to MANIFEST.in and CVS
 Py::Object
-RendererAgg::write_png(const Py::Tuple& args)
-{
- _VERBOSE("RendererAgg::write_png");
-
- args.verify_length(1, 2);
-
- FILE *fp = NULL;
- bool close_file = false;
- Py::Object py_fileobj = Py::Object(args[0]);
- if (py_fileobj.isString()) {
- std::string fileName = Py::String(py_fileobj);
- const char *file_name = fileName.c_str();
- if ((fp = fopen(file_name, "wb")) == NULL)
- throw Py::RuntimeError( Printf("Could not open file %s", file_name).str() );
- close_file = true;
- } else if (PyFile_CheckExact(py_fileobj.ptr())) {
- fp = PyFile_AsFile(py_fileobj.ptr());
- }
- else {
- PyObject* write_method = PyObject_GetAttrString(py_fileobj.ptr(), "write");
- if (!(write_method && PyCallable_Check(write_method))) {
- Py_XDECREF(write_method);
- throw Py::TypeError("Object does not appear to be a 8-bit string path or a Python file-like object");
- }
- Py_XDECREF(write_method);
- }
-
- png_bytep *row_pointers = NULL;
- png_structp png_ptr = NULL;
- png_infop info_ptr = NULL;
-
- try {
- struct png_color_8_struct sig_bit;
- png_uint_32 row;
-
- row_pointers = new png_bytep[height];
- for (row = 0; row < height; ++row) {
- row_pointers[row] = pixBuffer + row * width * 4;
- }
-
- png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
- if (png_ptr == NULL) {
- throw Py::RuntimeError("Could not create write struct");
- }
-
- info_ptr = png_create_info_struct(png_ptr);
- if (info_ptr == NULL) {
- throw Py::RuntimeError("Could not create info struct");
- }
-
- if (setjmp(png_ptr->jmpbuf)) {
- throw Py::RuntimeError("Error building image");
- }
-
- if (fp) {
- png_init_io(png_ptr, fp);
- } else {
- png_set_write_fn(png_ptr, (void*)py_fileobj.ptr(),
-		 &write_png_data, &flush_png_data);
- }
- png_set_IHDR(png_ptr, info_ptr,
-		 width, height, 8,
-		 PNG_COLOR_TYPE_RGB_ALPHA, PNG_INTERLACE_NONE,
-		 PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
-
- // Save the dpi of the image in the file
- if (args.size() == 2) {
- double dpi = Py::Float(args[1]);
- size_t dots_per_meter = (size_t)(dpi / (2.54 / 100.0));
- png_set_pHYs(png_ptr, info_ptr, dots_per_meter, dots_per_meter, PNG_RESOLUTION_METER);
- }
-
- // this a a color image!
- sig_bit.gray = 0;
- sig_bit.red = 8;
- sig_bit.green = 8;
- sig_bit.blue = 8;
- /* if the image has an alpha channel then */
- sig_bit.alpha = 8;
- png_set_sBIT(png_ptr, info_ptr, &sig_bit);
-
- png_write_info(png_ptr, info_ptr);
- png_write_image(png_ptr, row_pointers);
- png_write_end(png_ptr, info_ptr);
-
-
- } catch (...) {
- if (fp && close_file) fclose(fp);
- delete [] row_pointers;
- /* Changed calls to png_destroy_write_struct to follow
- http://www.libpng.org/pub/png/libpng-manual.txt.
- This ensures the info_ptr memory is released.
- */
- if (png_ptr && info_ptr) png_destroy_write_struct(&png_ptr, &info_ptr);
- throw;
- }
-
- png_destroy_write_struct(&png_ptr, &info_ptr);
- delete [] row_pointers;
- if (fp && close_file) fclose(fp);
-
- return Py::Object();
-}
-
-
-Py::Object
 RendererAgg::tostring_rgb(const Py::Tuple& args) {
 //"Return the rendered buffer as an RGB string";
 
@@ -1763,8 +1634,6 @@
 		 "draw_image(x, y, im)");
 add_varargs_method("write_rgba", &RendererAgg::write_rgba,
 		 "write_rgba(fname)");
- add_varargs_method("write_png", &RendererAgg::write_png,
-		 "write_png(fname, dpi=None)");
 add_varargs_method("tostring_rgb", &RendererAgg::tostring_rgb,
 		 "s = tostring_rgb()");
 add_varargs_method("tostring_argb", &RendererAgg::tostring_argb,
Modified: trunk/matplotlib/src/_backend_agg.h
===================================================================
--- trunk/matplotlib/src/_backend_agg.h	2008年06月11日 15:31:21 UTC (rev 5470)
+++ trunk/matplotlib/src/_backend_agg.h	2008年06月11日 15:49:11 UTC (rev 5471)
@@ -176,7 +176,6 @@
 
 
 Py::Object write_rgba(const Py::Tuple & args);
- Py::Object write_png(const Py::Tuple & args);
 Py::Object tostring_rgb(const Py::Tuple & args);
 Py::Object tostring_argb(const Py::Tuple & args);
 Py::Object tostring_bgra(const Py::Tuple & args);
Modified: trunk/matplotlib/src/_image.cpp
===================================================================
--- trunk/matplotlib/src/_image.cpp	2008年06月11日 15:31:21 UTC (rev 5470)
+++ trunk/matplotlib/src/_image.cpp	2008年06月11日 15:49:11 UTC (rev 5471)
@@ -1,11 +1,9 @@
-#include <png.h>
-
 // To remove a gcc warning
 #ifdef _POSIX_C_SOURCE
 #undef _POSIX_C_SOURCE
 #endif
 
-#include "Python.h" //after png.h due to setjmp bug
+#include "Python.h"
 #include <string>
 
 #include <iostream>
@@ -644,131 +642,7 @@
 return Py::Object();
 }
 
-static void write_png_data(png_structp png_ptr, png_bytep data, png_size_t length) {
- PyObject* py_file_obj = (PyObject*)png_get_io_ptr(png_ptr);
- PyObject* write_method = PyObject_GetAttrString(py_file_obj, "write");
- PyObject* result = NULL;
- if (write_method)
- result = PyObject_CallFunction(write_method, (char *)"s#", data, length);
- Py_XDECREF(write_method);
- Py_XDECREF(result);
-}
 
-static void flush_png_data(png_structp png_ptr) {
- PyObject* py_file_obj = (PyObject*)png_get_io_ptr(png_ptr);
- PyObject* flush_method = PyObject_GetAttrString(py_file_obj, "flush");
- PyObject* result = NULL;
- if (flush_method)
- result = PyObject_CallFunction(flush_method, (char *)"");
- Py_XDECREF(flush_method);
- Py_XDECREF(result);
-}
-
-// this code is heavily adapted from the paint license, which is in
-// the file paint.license (BSD compatible) included in this
-// distribution. TODO, add license file to MANIFEST.in and CVS
-char Image::write_png__doc__[] =
-"write_png(fname)\n"
-"\n"
-"Write the image to filename fname as png\n"
-;
-Py::Object
-Image::write_png(const Py::Tuple& args)
-{
- //small memory leak in this function - JDH 2004年06月08日
- _VERBOSE("Image::write_png");
-
- args.verify_length(1);
-
- FILE *fp = NULL;
- Py::Object py_fileobj = Py::Object(args[0]);
- if (py_fileobj.isString()) {
- std::string fileName = Py::String(py_fileobj);
- const char *file_name = fileName.c_str();
- if ((fp = fopen(file_name, "wb")) == NULL)
- throw Py::RuntimeError( Printf("Could not open file %s", file_name).str() );
- }
- else {
- PyObject* write_method = PyObject_GetAttrString(py_fileobj.ptr(), "write");
- if (!(write_method && PyCallable_Check(write_method))) {
- Py_XDECREF(write_method);
- throw Py::TypeError("Object does not appear to be a path or a Python file-like object");
- }
- Py_XDECREF(write_method);
- }
-
- png_structp png_ptr;
- png_infop info_ptr;
- struct png_color_8_struct sig_bit;
- png_uint_32 row=0;
-
- //todo: allocate on heap
- png_bytep *row_pointers = NULL;
- std::pair<agg::int8u*,bool> bufpair;
- bufpair.first = NULL;
- bufpair.second = false;
-
- try {
- row_pointers = new png_bytep[rowsOut];
- if (!row_pointers)
- throw Py::RuntimeError("Out of memory");
-
- bufpair = _get_output_buffer();
- for (row = 0; row < rowsOut; ++row)
- row_pointers[row] = bufpair.first + row * colsOut * 4;
-
- png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
- if (png_ptr == NULL)
- throw Py::RuntimeError("Could not create write struct");
-
- info_ptr = png_create_info_struct(png_ptr);
- if (info_ptr == NULL)
- throw Py::RuntimeError("Could not create info struct");
-
- if (setjmp(png_ptr->jmpbuf))
- throw Py::RuntimeError("Error building image");
-
- if (fp) {
- png_init_io(png_ptr, fp);
- } else {
- png_set_write_fn(png_ptr, (void*)py_fileobj.ptr(),
-		 &write_png_data, &flush_png_data);
- }
- png_set_IHDR(png_ptr, info_ptr,
- colsOut, rowsOut, 8,
- PNG_COLOR_TYPE_RGB_ALPHA, PNG_INTERLACE_NONE,
- PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
-
- // this a a color image!
- sig_bit.gray = 0;
- sig_bit.red = 8;
- sig_bit.green = 8;
- sig_bit.blue = 8;
- /* if the image has an alpha channel then */
- sig_bit.alpha = 8;
- png_set_sBIT(png_ptr, info_ptr, &sig_bit);
-
- png_write_info(png_ptr, info_ptr);
- png_write_image(png_ptr, row_pointers);
- png_write_end(png_ptr, info_ptr);
- png_destroy_write_struct(&png_ptr, &info_ptr);
- } catch (...) {
- if (bufpair.second) delete [] bufpair.first;
- if (fp) fclose(fp);
- png_destroy_write_struct(&png_ptr, &info_ptr);
- delete [] row_pointers;
- throw;
- }
-
- if (fp) fclose(fp);
- delete [] row_pointers;
- if (bufpair.second) delete [] bufpair.first;
-
- return Py::Object();
-}
-
-
-
 char Image::set_aspect__doc__[] =
 "set_aspect(scheme)\n"
 "\n"
@@ -812,7 +686,6 @@
 add_varargs_method( "set_interpolation", &Image::set_interpolation, Image::set_interpolation__doc__);
 add_varargs_method( "set_resample", &Image::set_resample, Image::set_resample__doc__);
 add_varargs_method( "set_aspect", &Image::set_aspect, Image::set_aspect__doc__);
- add_varargs_method( "write_png", &Image::write_png, Image::write_png__doc__);
 add_varargs_method( "set_bg", &Image::set_bg, Image::set_bg__doc__);
 add_varargs_method( "flipud_out", &Image::flipud_out, Image::flipud_out__doc__);
 add_varargs_method( "flipud_in", &Image::flipud_in, Image::flipud_in__doc__);
@@ -901,118 +774,6 @@
 }
 
 
-
-char _image_module_readpng__doc__[] =
-"readpng(fname)\n"
-"\n"
-"Load an image from png file into a numerix array of MxNx4 float";
-Py::Object
-_image_module::readpng(const Py::Tuple& args) {
-
- args.verify_length(1);
- std::string fname = Py::String(args[0]);
-
- png_byte header[8];	// 8 is the maximum size that can be checked
-
- FILE *fp = fopen(fname.c_str(), "rb");
- if (!fp)
- throw Py::RuntimeError(Printf("_image_module::readpng could not open PNG file %s for reading", fname.c_str()).str());
-
- if (fread(header, 1, 8, fp) != 8)
- throw Py::RuntimeError("_image_module::readpng: error reading PNG header");
- if (png_sig_cmp(header, 0, 8))
- throw Py::RuntimeError("_image_module::readpng: file not recognized as a PNG file");
-
-
- /* initialize stuff */
- png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
-
- if (!png_ptr)
- throw Py::RuntimeError("_image_module::readpng: png_create_read_struct failed");
-
- png_infop info_ptr = png_create_info_struct(png_ptr);
- if (!info_ptr)
- throw Py::RuntimeError("_image_module::readpng: png_create_info_struct failed");
-
- if (setjmp(png_jmpbuf(png_ptr)))
- throw Py::RuntimeError("_image_module::readpng: error during init_io");
-
- png_init_io(png_ptr, fp);
- png_set_sig_bytes(png_ptr, 8);
-
- png_read_info(png_ptr, info_ptr);
-
- png_uint_32 width = info_ptr->width;
- png_uint_32 height = info_ptr->height;
-
- // convert misc color types to rgb for simplicity
- if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY ||
- info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
- png_set_gray_to_rgb(png_ptr);
- else if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
- png_set_palette_to_rgb(png_ptr);
-
-
- int bit_depth = info_ptr->bit_depth;
- if (bit_depth == 16) png_set_strip_16(png_ptr);
-
-
- png_set_interlace_handling(png_ptr);
- png_read_update_info(png_ptr, info_ptr);
-
- bool rgba = info_ptr->color_type == PNG_COLOR_TYPE_RGBA;
- if ( (info_ptr->color_type != PNG_COLOR_TYPE_RGB) && !rgba) {
- std::cerr << "Found color type " << (int)info_ptr->color_type << std::endl;
- throw Py::RuntimeError("_image_module::readpng: cannot handle color_type");
- }
-
- /* read file */
- if (setjmp(png_jmpbuf(png_ptr)))
- throw Py::RuntimeError("_image_module::readpng: error during read_image");
-
- png_bytep *row_pointers = new png_bytep[height];
- png_uint_32 row;
-
- for (row = 0; row < height; row++)
- row_pointers[row] = new png_byte[png_get_rowbytes(png_ptr,info_ptr)];
-
- png_read_image(png_ptr, row_pointers);
-
-
-
- int dimensions[3];
- dimensions[0] = height; //numrows
- dimensions[1] = width; //numcols
- dimensions[2] = 4;
-
- PyArrayObject *A = (PyArrayObject *) PyArray_FromDims(3, dimensions, PyArray_FLOAT);
-
-
- for (png_uint_32 y = 0; y < height; y++) {
- png_byte* row = row_pointers[y];
- for (png_uint_32 x = 0; x < width; x++) {
-
- png_byte* ptr = (rgba) ? &(row[x*4]) : &(row[x*3]);
- size_t offset = y*A->strides[0] + x*A->strides[1];
- //if ((y<10)&&(x==10)) std::cout << "r = " << ptr[0] << " " << ptr[0]/255.0 << std::endl;
- *(float*)(A->data + offset + 0*A->strides[2]) = (float)(ptr[0]/255.0f);
- *(float*)(A->data + offset + 1*A->strides[2]) = (float)(ptr[1]/255.0f);
- *(float*)(A->data + offset + 2*A->strides[2]) = (float)(ptr[2]/255.0f);
- *(float*)(A->data + offset + 3*A->strides[2]) = rgba ? (float)(ptr[3]/255.0f) : 1.0f;
- }
- }
-
- //free the png memory
- png_read_end(png_ptr, info_ptr);
- png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
- fclose(fp);
- for (row = 0; row < height; row++)
- delete [] row_pointers[row];
- delete [] row_pointers;
- return Py::asObject((PyObject*)A);
-}
-
-
 char _image_module_fromarray__doc__[] =
 "fromarray(A, isoutput)\n"
 "\n"
Modified: trunk/matplotlib/src/_image.h
===================================================================
--- trunk/matplotlib/src/_image.h	2008年06月11日 15:31:21 UTC (rev 5470)
+++ trunk/matplotlib/src/_image.h	2008年06月11日 15:49:11 UTC (rev 5471)
@@ -38,7 +38,6 @@
 Py::Object get_interpolation(const Py::Tuple& args);
 Py::Object set_interpolation(const Py::Tuple& args);
 Py::Object set_aspect(const Py::Tuple& args);
- Py::Object write_png(const Py::Tuple& args);
 Py::Object set_bg(const Py::Tuple& args);
 Py::Object flipud_out(const Py::Tuple& args);
 Py::Object flipud_in(const Py::Tuple& args);
@@ -100,7 +99,6 @@
 static char get_interpolation__doc__[];
 static char set_interpolation__doc__[];
 static char set_aspect__doc__[];
- static char write_png__doc__[];
 static char set_bg__doc__[];
 static char flipud_out__doc__[];
 static char flipud_in__doc__[];
@@ -133,8 +131,6 @@
 		 "frombyte");
 add_varargs_method("frombuffer", &_image_module::frombuffer,
 		 "frombuffer");
- add_varargs_method("readpng", &_image_module::readpng,
-		 "readpng");
 add_varargs_method("from_images", &_image_module::from_images,
 		 "from_images");
 add_varargs_method("pcolor", &_image_module::pcolor,
@@ -153,7 +149,6 @@
 Py::Object fromarray2 (const Py::Tuple &args);
 Py::Object pcolor (const Py::Tuple &args);
 Py::Object pcolor2 (const Py::Tuple &args);
- Py::Object readpng (const Py::Tuple &args);
 Py::Object from_images (const Py::Tuple &args);
 
 static char _image_module_fromarray__doc__[];
Modified: trunk/matplotlib/src/ft2font.cpp
===================================================================
--- trunk/matplotlib/src/ft2font.cpp	2008年06月11日 15:31:21 UTC (rev 5470)
+++ trunk/matplotlib/src/ft2font.cpp	2008年06月11日 15:49:11 UTC (rev 5471)
@@ -69,7 +69,9 @@
 delete _rgbaCopy;
 }
 
-void FT2Image::resize(unsigned long width, unsigned long height) {
+void FT2Image::resize(long width, long height) {
+ if (width < 0) width = 1;
+ if (height < 0) height = 1;
 size_t numBytes = width*height;
 
 if (width != _width || height != _height) {
Modified: trunk/matplotlib/src/ft2font.h
===================================================================
--- trunk/matplotlib/src/ft2font.h	2008年06月11日 15:31:21 UTC (rev 5470)
+++ trunk/matplotlib/src/ft2font.h	2008年06月11日 15:49:11 UTC (rev 5471)
@@ -66,7 +66,7 @@
 void makeRgbCopy();
 void makeRgbaCopy();
 
- void resize(unsigned long width, unsigned long height);
+ void resize(long width, long height);
 };
 
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <jd...@us...> - 2008年06月11日 15:31:23
Revision: 5470
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5470&view=rev
Author: jdh2358
Date: 2008年06月11日 08:31:21 -0700 (2008年6月11日)
Log Message:
-----------
fixed a text layout bug where layout was cached between renderers
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/text.py
Modified: trunk/matplotlib/lib/matplotlib/text.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/text.py	2008年06月11日 12:37:21 UTC (rev 5469)
+++ trunk/matplotlib/lib/matplotlib/text.py	2008年06月11日 15:31:21 UTC (rev 5470)
@@ -394,7 +394,7 @@
 return (x, y, self._text, self._color,
 self._verticalalignment, self._horizontalalignment,
 hash(self._fontproperties), self._rotation,
- self._renderer.dpi
+ self._renderer.dpi, id(self._renderer)
 )
 
 def get_text(self):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <js...@us...> - 2008年06月11日 12:37:33
Revision: 5469
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5469&view=rev
Author: jswhit
Date: 2008年06月11日 05:37:21 -0700 (2008年6月11日)
Log Message:
-----------
add material to users guide
Modified Paths:
--------------
 trunk/toolkits/basemap/doc/users/index.rst
Added Paths:
-----------
 trunk/toolkits/basemap/doc/users/figures/ortho_full.png
 trunk/toolkits/basemap/doc/users/figures/ortho_full.py
 trunk/toolkits/basemap/doc/users/figures/ortho_partial.png
 trunk/toolkits/basemap/doc/users/figures/ortho_partial.py
 trunk/toolkits/basemap/doc/users/mapsetup.rst
 trunk/toolkits/basemap/doc/users/ortho.rst
Added: trunk/toolkits/basemap/doc/users/figures/ortho_full.png
===================================================================
(Binary files differ)
Property changes on: trunk/toolkits/basemap/doc/users/figures/ortho_full.png
___________________________________________________________________
Name: svn:mime-type
 + application/octet-stream
Added: trunk/toolkits/basemap/doc/users/figures/ortho_full.py
===================================================================
--- trunk/toolkits/basemap/doc/users/figures/ortho_full.py	 (rev 0)
+++ trunk/toolkits/basemap/doc/users/figures/ortho_full.py	2008年06月11日 12:37:21 UTC (rev 5469)
@@ -0,0 +1,14 @@
+from mpl_toolkits.basemap import Basemap
+import numpy as np
+import matplotlib.pyplot as plt
+# lon_0, lat_0 are the center point of the projection.
+# resolution = 'l' means use low resolution coastlines.
+m = Basemap(projection='ortho',lon_0=-105,lat_0=40,resolution='l')
+m.drawcoastlines()
+m.fillcontinents(color='coral',lake_color='aqua')
+# draw parallels and meridians.
+m.drawparallels(np.arange(-90.,120.,30.))
+m.drawmeridians(np.arange(0.,420.,60.))
+m.drawmapboundary(fill_color='aqua') 
+plt.title("Full Disk Orthographic Projection")
+plt.savefig('ortho_full.png')
Added: trunk/toolkits/basemap/doc/users/figures/ortho_partial.png
===================================================================
(Binary files differ)
Property changes on: trunk/toolkits/basemap/doc/users/figures/ortho_partial.png
___________________________________________________________________
Name: svn:mime-type
 + application/octet-stream
Added: trunk/toolkits/basemap/doc/users/figures/ortho_partial.py
===================================================================
--- trunk/toolkits/basemap/doc/users/figures/ortho_partial.py	 (rev 0)
+++ trunk/toolkits/basemap/doc/users/figures/ortho_partial.py	2008年06月11日 12:37:21 UTC (rev 5469)
@@ -0,0 +1,28 @@
+from mpl_toolkits.basemap import Basemap
+import numpy as np
+import matplotlib.pyplot as plt
+fig = plt.figure()
+# global ortho map centered on lon_0,lat_0
+lat_0=10.; lon_0=57.
+# resolution = None means don't process the boundary datasets.
+m1 = Basemap(projection='ortho',lon_0=lon_0,lat_0=lat_0,resolution=None)
+# add an axes with a black background
+ax = fig.add_axes([0.1,0.1,0.8,0.8],axisbg='k')
+# plot just upper right quadrant (corners determined from global map).
+# keywords llcrnrx,llcrnry,urcrnrx,urcrnry used to define the lower
+# left and upper right corners in map projection coordinates.
+# llcrnrlat,llcrnrlon,ucrnrlon,urcrnrlat could be used to define
+# lat/lon values of corners - but this won't work in cases such as this
+# where one of the corners does not lie on the earth.
+m = Basemap(projection='ortho',lon_0=lon_0,lat_0=lat_0,resolution='l',\
+ llcrnrx=0.,llcrnry=0.,urcrnrx=m1.urcrnrx/2.,urcrnry=m1.urcrnry/2.)
+m.drawcoastlines()
+m.drawmapboundary(fill_color='aqua')
+m.fillcontinents(color='coral',lake_color='aqua')
+m.drawcountries()
+# draw parallels and meridians.
+m.drawparallels(np.arange(-90.,120.,30.))
+m.drawmeridians(np.arange(0.,360.,60.))
+m.drawmapboundary()
+plt.title('Orthographic Map Showing A Quadrant of the Globe')
+plt.savefig('ortho_partial.png')
Modified: trunk/toolkits/basemap/doc/users/index.rst
===================================================================
--- trunk/toolkits/basemap/doc/users/index.rst	2008年06月11日 12:23:05 UTC (rev 5468)
+++ trunk/toolkits/basemap/doc/users/index.rst	2008年06月11日 12:37:21 UTC (rev 5469)
@@ -10,3 +10,4 @@
 .. toctree::
 
 intro.rst
+ mapsetup.rst
Added: trunk/toolkits/basemap/doc/users/mapsetup.rst
===================================================================
--- trunk/toolkits/basemap/doc/users/mapsetup.rst	 (rev 0)
+++ trunk/toolkits/basemap/doc/users/mapsetup.rst	2008年06月11日 12:37:21 UTC (rev 5469)
@@ -0,0 +1,31 @@
+.. _mapsetup:
+
+Setting up the map
+==================
+
+In order to represent the curved surface of the earth on a two-dimensional
+map, a map projection is needed. Since this cannot be done without
+distortion, there are many map projections, each with it's own advantages
+and disadvantages. Basemap provides 19 different map projections.
+Some are global, some can only represent a portion of the globe. When
+a Basemap class instance is created, the desired map projection must
+be specified, along with information about the portion of the earth's
+surface that the map projection will describe. There are two basic
+ways of doing this. One is to provide the latitude and longitude values
+of each of the four corners of the rectangular map projection region.
+The other is to provide the lat/lon value of the center of the map
+projection region along with the width and height of the region in
+map projection coordinates. 
+
+The class variable ``supported_projections`` is a dictionary containing 
+information about all the projections supported by Basemap. The keys
+are the short names (used with the ``projection`` keyword to define
+a projection when creating a ``Basemap`` class instance), and the values
+are longer, more descriptive names. The class variable ``projection_params``
+is a dictionary that provides a list of parameters that can be used to
+define the properties of each projection. Following are examples that 
+illustrate how to set up each of the supported projections.
+
+.. toctree::
+
+ ortho.rst
Added: trunk/toolkits/basemap/doc/users/ortho.rst
===================================================================
--- trunk/toolkits/basemap/doc/users/ortho.rst	 (rev 0)
+++ trunk/toolkits/basemap/doc/users/ortho.rst	2008年06月11日 12:37:21 UTC (rev 5469)
@@ -0,0 +1,15 @@
+.. _ortho:
+
+Orthographic Projection
+=======================
+
+The orthographic projection displays the earth as a satellite 
+(in an orbit infinitely high above the earth) would see it.
+
+.. literalinclude:: figures/ortho_full.py
+
+.. image:: figures/ortho_full.png
+
+.. literalinclude:: figures/ortho_partial.py
+
+.. image:: figures/ortho_partial.png
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5468
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5468&view=rev
Author: jdh2358
Date: 2008年06月11日 05:23:05 -0700 (2008年6月11日)
Log Message:
-----------
some more backend bases rest fixes
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/backend_bases.py
Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backend_bases.py	2008年06月11日 01:26:29 UTC (rev 5467)
+++ trunk/matplotlib/lib/matplotlib/backend_bases.py	2008年06月11日 12:23:05 UTC (rev 5468)
@@ -631,8 +631,8 @@
 class Event:
 """
 A matplotlib event. Attach additional attributes as defined in
- :meth:`FigureCanvasBase.connect`. The following attributes are defined and
- shown with their default values
+ :meth:`FigureCanvasBase.mpl_connect`. The following attributes
+ are defined and shown with their default values
 
 ``name``
 the event name
@@ -655,7 +655,7 @@
 """
 An event triggered by a draw operation on the canvas
 
- In addition to the :class`Event` attributes, the following event attributes are defined:
+ In addition to the :class:`Event` attributes, the following event attributes are defined:
 
 ``renderer``
 the :class:`RendererBase` instance for the draw event
@@ -669,7 +669,7 @@
 """
 An event triggered by a canvas resize
 
- In addition to the :class`Event` attributes, the following event attributes are defined:
+ In addition to the :class:`Event` attributes, the following event attributes are defined:
 
 ``width``
 width of the canvas in pixels
@@ -689,7 +689,7 @@
 The following additional attributes are defined and shown with
 their default values
 
- In addition to the :class`Event` attributes, the following event attributes are defined:
+ In addition to the :class:`Event` attributes, the following event attributes are defined:
 
 ``x``
 x position - pixels from left of canvas
@@ -752,7 +752,7 @@
 A mouse event ('button_press_event', 'button_release_event', 'scroll_event',
 'motion_notify_event').
 
- In addition to the :class`Event` and :class:`LocationEvent`
+ In addition to the :class:`Event` and :class:`LocationEvent`
 attributes, the following attributes are defined:
 
 ``button``
@@ -832,9 +832,9 @@
 A key event (key press, key release).
 
 Attach additional attributes as defined in
- :meth:`FigureCanvasBase.connect`.
+ :meth:`FigureCanvasBase.mpl_connect`.
 
- In addition to the :class`Event` and :class:`LocationEvent`
+ In addition to the :class:`Event` and :class:`LocationEvent`
 attributes, the following attributes are defined:
 
 ``key``
@@ -1468,38 +1468,40 @@
 
 backends must implement a canvas that handles connections for
 'button_press_event' and 'button_release_event'. See
- :meth:`FigureCanvasBase.connect` for more information
+ :meth:`FigureCanvasBase.mpl_connect` for more information
 
 
 They must also define
 
- :meth:`save_figure`
- save the current figure
+ :meth:`save_figure`
+	 save the current figure
 
- :meth:`set_cursor`
- if you want the pointer icon to change
+ :meth:`set_cursor`
+	 if you want the pointer icon to change
 
- :meth:`_init_toolbar`
- create your toolbar widget
+ :meth:`_init_toolbar`
+	 create your toolbar widget
 
- :meth:`draw_rubberband` (optional)
- draw the zoom to rect "rubberband" rectangle
+ :meth:`draw_rubberband` (optional)
+	 draw the zoom to rect "rubberband" rectangle
 
- :meth:`press` (optional)
- whenever a mouse button is pressed, you'll be
- notified with the event
+ :meth:`press` (optional)
+	 whenever a mouse button is pressed, you'll be
+	 notified with the event
 
 :meth:`release` (optional)
- whenever a mouse button is released, you'll be notified with the event
+	 whenever a mouse button is released, you'll be notified with
+	 the event
 
- :meth:`dynamic_update` ptional)
- dynamically update the window while navigating
+ :meth:`dynamic_update` (optional)
+	 dynamically update the window while navigating
 
- :meth:`set_message` ptional)
- display message
+ :meth:`set_message` (optional)
+	 display message
 
- :meth:`set_history_buttons` (optional)
- you can change the history back / forward buttons to indicate disabled / enabled state.
+ :meth:`set_history_buttons` (optional)
+	 you can change the history back / forward buttons to
+	 indicate disabled / enabled state.
 
 That's it, we'll do the rest!
 """
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <jd...@us...> - 2008年06月11日 01:26:34
Revision: 5467
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5467&view=rev
Author: jdh2358
Date: 2008年06月10日 18:26:29 -0700 (2008年6月10日)
Log Message:
-----------
added usetex review
Modified Paths:
--------------
 trunk/matplotlib/doc/devel/coding_guide.rst
 trunk/matplotlib/doc/devel/documenting_mpl.rst
 trunk/matplotlib/doc/devel/outline.rst
 trunk/matplotlib/doc/users/usetex.rst
Modified: trunk/matplotlib/doc/devel/coding_guide.rst
===================================================================
--- trunk/matplotlib/doc/devel/coding_guide.rst	2008年06月11日 00:29:14 UTC (rev 5466)
+++ trunk/matplotlib/doc/devel/coding_guide.rst	2008年06月11日 01:26:29 UTC (rev 5467)
@@ -1,12 +1,12 @@
 .. _coding-guide:
 
 ************
-Coding Guide
+Coding guide
 ************
 
 .. _version-control:
 
-Version Control
+Version control
 ===============
 
 svn checkouts
@@ -35,18 +35,25 @@
 
 * if your changes are non-trivial, please make an entry in the
 :file:`CHANGELOG`
-* if you change the API, please document it in :file:`API_CHANGES`, and
- consider posting to mpl-devel
-* Are your changes python2.4 compatible? We are still trying to
- support 2.4, so avoid features new to 2.5
+
+* if you change the API, please document it in :file:`API_CHANGES`,
+ and consider posting to `mpl-devel
+ <http://lists.sourceforge.net/mailman/listinfo/matplotlib-devel>`_
+
+* Are your changes python2.4 compatible? We still support 2.4, so
+ avoid features new to 2.5
+
 * Can you pass :file:`examples/tests/backend_driver.py`? This is our
 poor man's unit test.
+
 * If you have altered extension code, do you pass
 :file:`unit/memleak_hawaii.py`?
+
 * if you have added new files or directories, or reorganized existing
 ones, are the new files included in the match patterns in
 :file:`MANIFEST.in`. This file determines what goes into the source
 distribution of the mpl build.
+
 * Keep the maintenance branch and trunk in sync where it makes sense.
 If there is a bug on both that needs fixing, use `svnmerge.py
 <http://www.orcaware.com/svn/wiki/Svnmerge.py>`_ to keep them in
@@ -58,6 +65,7 @@
 svnmerge/svnmerge.py
 
 * get a svn copy of the maintenance branch and the trunk (see above)
+
 * Michael advises making the change on the branch and committing
 it. Make sure you svn upped on the trunk and have no local
 modifications, and then from the svn trunk do::
@@ -87,7 +95,7 @@
 
 .. _style-guide:
 
-Style Guide
+Style guide
 ===========
 
 Importing and name spaces
@@ -278,7 +286,7 @@
 
 .. _docstrings:
 
-Documentation and Docstrings
+Documentation and docstrings
 ============================
 
 matplotlib uses artist introspection of docstrings to support
Modified: trunk/matplotlib/doc/devel/documenting_mpl.rst
===================================================================
--- trunk/matplotlib/doc/devel/documenting_mpl.rst	2008年06月11日 00:29:14 UTC (rev 5466)
+++ trunk/matplotlib/doc/devel/documenting_mpl.rst	2008年06月11日 01:26:29 UTC (rev 5467)
@@ -1,10 +1,10 @@
 .. _documenting-matplotlib:
 
 **********************
-Documenting Matplotlib
+Documenting matplotlib
 **********************
 
-Getting Started
+Getting started
 ===============
 
 The documentation for matplotlib is generated from ReStructured Text
@@ -33,7 +33,7 @@
 The output produced by Sphinx can be configured by editing the `conf.py`
 file located in the `doc/`.
 
-Organization of Matplotlib's Documentation
+Organization of matplotlib's documentation
 ==========================================
 
 The actual ReStructured Text files are kept in `doc/users`, `doc/devel`,
@@ -96,8 +96,14 @@
 Each guide will have its own `figures/` directory for scripts to generate images
 to be included in the dcoumentation. It is not necessary to explicitly save
 the figure in the script, a figure will be saved with the same name as the
-filename when the documentation is generated.
+filename when the documentation is generated. For example, use::
 
+ .. literalinclude:: figures/pyplot_simple.py
+
+ .. image:: figures/pyplot_simple.png
+ :scale: 75
+
+
 Any figures that rely on optional system configurations should be generated
 with a script residing in doc/static_figs. The resulting figures will be saved
 to doc/_static, and will be named based on the name of the script, so we can
@@ -105,6 +111,8 @@
 the README in doc/static-figs for any additional requirements necessary to
 generate a new figure.
 
+
+
 .. _referring-to-mpl-docs:
 
 Referring to mpl documents
@@ -131,6 +139,8 @@
 .. literalinclude:: ../mpl_data/matplotlibrc
 
 
+
+
 .. _internal-section-refs:
 
 Internal section references
@@ -161,6 +171,13 @@
 
 .. _emacs-helpers:
 
+Section names, etc
+==================
+
+For everything but top level chapters, please use ``Upper lower`` for
+section titles, eg ``Possible hangups`` rather than ``Possible
+Hangups``
+
 Emacs helpers
 =============
 
@@ -182,7 +199,7 @@
 C-c TAB - rst-toc-insert
 
 Insert table of contents at point
- 
+
 C-c C-u - rst-toc-update
 
 Update the table of contents at point
Modified: trunk/matplotlib/doc/devel/outline.rst
===================================================================
--- trunk/matplotlib/doc/devel/outline.rst	2008年06月11日 00:29:14 UTC (rev 5466)
+++ trunk/matplotlib/doc/devel/outline.rst	2008年06月11日 01:26:29 UTC (rev 5467)
@@ -28,7 +28,7 @@
 animation John has author ?
 collections ? no author ?
 text - mathtext Michael in review John
-text - usetex Darren submitted ?
+text - usetex Darren in review John
 text - annotations John submitted ?
 fonts et al Michael ? no author Darren
 pyplot tut John submitted Eric
@@ -177,4 +177,40 @@
 sub-packages with the gamut of licenses, GPL to MIT?
 
 
+usetex user's guide-- reviewed by JDH
+-------------------------------------
 
+Review of :ref:`usetex-tutorial`:
+
+#. In the section on the ps distiller, you might mention that it is
+ the rasterization which some users find objectionable, and the
+ distiller pram (eg 6000) is a dpi setting for the rasterizer. Not
+ everyone will immediately grasp the controversy surrounding dumping
+ high res bitmaps into a ps file.
+
+#. ``= Possible Hangups =`` - this is moin, not rest. I have fixed
+ this already, just wanted to point it out. Also, for everything
+ but top level chapters, I refer ``Upper lower`` for section
+ titles, eg ``Possible hangups``.
+
+#. in the troubleshooting section, could you add a FAQ showing how to
+ find their .matplotlib dir (matplotlib.get_data_path) and link to
+ it. Also link to the PATH var and properly format
+ ``text.latex.preample``. For the dirs, do we want `tex.cache` or
+ ``tex.cache``? I've been using the latter. We could use rest
+ specific markup for files and dirs, but I've been resisting goin
+ whle hog onthe markup... But we may eventually decide that is the
+ better choice.
+
+#. try and use internal reference links for every section and be
+ generous with the sections. Eg, I added a section headers and
+ internal linka for the postscript and unicode sections (we will
+ want to be able to refer people to these easily from FAQs and mail
+ list posts, etc)::
+
+ .. _usetex-postscript:
+
+ Postscript options
+ ==================
+
+Looks good!
Modified: trunk/matplotlib/doc/users/usetex.rst
===================================================================
--- trunk/matplotlib/doc/users/usetex.rst	2008年06月11日 00:29:14 UTC (rev 5466)
+++ trunk/matplotlib/doc/users/usetex.rst	2008年06月11日 01:26:29 UTC (rev 5467)
@@ -52,7 +52,7 @@
 
 Here is the standard example, `tex_demo.py`:
 
- .. literalinclude:: ../mpl_examples/pylab_examples/tex_demo.py
+.. literalinclude:: ../mpl_examples/pylab_examples/tex_demo.py
 
 .. image:: ../_static/tex_demo.png
 
@@ -60,13 +60,22 @@
 command ``\displaystyle``, as in `tex_demo.py`, will produce the same
 results.
 
+.. _usetex-unicode:
+
+usetex with unicode
+===================
 It is also possible to use unicode strings with the LaTeX text manager, here is
 an example taken from `tex_unicode_demo.py`:
 
- .. literalinclude:: ../mpl_examples/pylab_examples/tex_unicode_demo.py
+.. literalinclude:: ../mpl_examples/pylab_examples/tex_unicode_demo.py
 
 .. image:: ../_static/tex_unicode_demo.png
 
+.. _usetex-postscript:
+
+Postscript options
+==================
+
 In order to produce encapsulated postscript files that can be embedded in a new
 LaTeX document, the default behavior of matplotlib is to distill the output,
 which removes some postscript operators used by LaTeX that are illegal in an
@@ -77,51 +86,60 @@
 alternative produces postscript with text that can be edited in Adobe
 Illustrator, and searched text in pdf documents.
 
+.. _usetex-hangups:
 
-= Possible Hangups =
+Possible hangups
+================
 
- * On Windows, the PATH environment variable may need to be modified to find
- the latex, dvipng and ghostscript executables. This is done by going to the
- control panel, selecting the "system" icon, selecting the "advanced" tab,
- and clicking the "environment variables" button (and people think Linux is
- complicated. Sheesh.) Select the PATH variable, and add the appropriate
- directories.
+* On Windows, the PATH environment variable may need to be modified to
+ find the latex, dvipng and ghostscript executables. This is done by
+ going to the control panel, selecting the "system" icon, selecting
+ the "advanced" tab, and clicking the "environment variables" button
+ (and people think Linux is complicated. Sheesh.) Select the PATH
+ variable, and add the appropriate directories.
 
- * Using MiKTeX with Computer Modern fonts, if you get odd -Agg and PNG
- results, go to MiKTeX/Options and update your format files
+* Using MiKTeX with Computer Modern fonts, if you get odd -Agg and PNG
+ results, go to MiKTeX/Options and update your format files
 
- * The fonts look terrible on screen. You are probably running Mac OS, and
- there is some funny business with dvipng on the mac. Set text.dvipnghack :
- True in your matplotlibrc file.
+* The fonts look terrible on screen. You are probably running Mac OS,
+ and there is some funny business with dvipng on the mac. Set
+ text.dvipnghack : True in your matplotlibrc file.
 
- * On Ubuntu and Gentoo, the base texlive install does not ship with the
- type1cm package. You may need to install some of the extra packages to get
- all the goodies that come bundled with other latex distributions.
+* On Ubuntu and Gentoo, the base texlive install does not ship with
+ the type1cm package. You may need to install some of the extra
+ packages to get all the goodies that come bundled with other latex
+ distributions.
 
- * Some progress has been made so Matplotlib uses the dvi files directly for
- text layout. This allows latex to be used for text layout with the pdf and
- svg backends, as well as the \*Agg and PS backends. In the future, a latex
- installation may be the only external dependency.
+* Some progress has been made so Matplotlib uses the dvi files
+ directly for text layout. This allows latex to be used for text
+ layout with the pdf and svg backends, as well as the \*Agg and PS
+ backends. In the future, a latex installation may be the only
+ external dependency.
 
-= In the event that things dont work =
- * Try deleting `tex.cache` from your `~/.matplotlib` directory
+.. _usetex-troubleshooting:
 
- * Make sure LaTeX, dvipng and ghostscript are each working and on your PATH.
+Trouble shooting
+================
 
- * Make sure what you are trying to do is possible in a LaTeX document, that
- your LaTeX syntax is valid and that you are using raw strings if necessary
- to avoid unintended escape sequences.
+* Try deleting `tex.cache` from your `~/.matplotlib` directory
 
- * Most problems reported on the mailing list have been cleared up by
- upgrading Ghostscript_. If possible, please try upgrading to the latest
- release before reporting problems to the list.
+* Make sure LaTeX, dvipng and ghostscript are each working and on your PATH.
 
- * The text.latex.preample rc setting is not officially supported. This option
- provides lots of flexibility, and lots of ways to cause problems. Please
- disable this option before reporting problems to the mailing list.
+* Make sure what you are trying to do is possible in a LaTeX document,
+ that your LaTeX syntax is valid and that you are using raw strings
+ if necessary to avoid unintended escape sequences.
 
- * If you still need help, please see :ref:`reporting-problems`
+* Most problems reported on the mailing list have been cleared up by
+ upgrading Ghostscript_. If possible, please try upgrading to the
+ latest release before reporting problems to the list.
 
+* The text.latex.preample rc setting is not officially supported. This
+ option provides lots of flexibility, and lots of ways to cause
+ problems. Please disable this option before reporting problems to
+ the mailing list.
+
+* If you still need help, please see :ref:`reporting-problems`
+
 .. _LaTeX: http://www.tug.org
 .. _dvipng: http://sourceforge.net/projects/dvipng
 .. _Ghostscript: http://www.cs.wisc.edu/~ghost/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5466
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5466&view=rev
Author: jdh2358
Date: 2008年06月10日 17:29:14 -0700 (2008年6月10日)
Log Message:
-----------
remove typo from backend template
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/backends/backend_template.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_template.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_template.py	2008年06月10日 22:49:02 UTC (rev 5465)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_template.py	2008年06月11日 00:29:14 UTC (rev 5466)
@@ -1,4 +1,4 @@
-M"""
+"""
 This is a fully functional do nothing backend to provide a template to
 backend writers. It is fully functional in that you can select it as
 a backend with
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

Showing 12 results of 12

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 によって変換されたページ (->オリジナル) /