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
|
From: <jo...@us...> - 2007-08-24 18:17:56
|
Revision: 3736 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3736&view=rev Author: jouni Date: 2007-08-24 11:17:51 -0700 (Fri, 24 Aug 2007) Log Message: ----------- Support get_image_magnification in pdf backend Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2007-08-23 18:02:03 UTC (rev 3735) +++ trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2007-08-24 18:17:51 UTC (rev 3736) @@ -1021,7 +1021,7 @@ class RendererPdf(RendererBase): - def __init__(self, file): + def __init__(self, file, dpi): RendererBase.__init__(self) self.file = file self.gc = self.new_gc() @@ -1033,6 +1033,7 @@ else: self.encode_string = self.encode_string_type42 self.mathtext_parser = MathTextParser("Pdf") + self.image_magnification = dpi/72.0 def finalize(self): self.gc.finalize() @@ -1120,6 +1121,9 @@ self.file.output(self.gc.close_and_paint()) + def get_image_magnification(self): + return self.image_magnification + def draw_image(self, x, y, im, bbox): #print >>sys.stderr, "draw_image called" @@ -1128,6 +1132,7 @@ self.check_gc(gc) h, w = im.get_size_out() + h, w = h/self.image_magnification, w/self.image_magnification imob = self.file.imageObject(im) self.file.output(Op.gsave, w, 0, 0, h, x, y, Op.concat_matrix, imob, Op.use_xobject, Op.grestore) @@ -1735,7 +1740,7 @@ filename += '.pdf' file = PdfFile(width, height, filename) - renderer = RendererPdf(file) + renderer = RendererPdf(file, dpi) self.figure.draw(renderer) renderer.finalize() file.close() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-08-23 18:02:04
|
Revision: 3735 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3735&view=rev Author: mdboom Date: 2007-08-23 11:02:03 -0700 (Thu, 23 Aug 2007) Log Message: ----------- There's no need to link ttconv with CXX (it hasn't used it for sometime, but I forgot to remove it from the build.) Modified Paths: -------------- trunk/matplotlib/setupext.py Modified: trunk/matplotlib/setupext.py =================================================================== --- trunk/matplotlib/setupext.py 2007-08-23 18:00:42 UTC (rev 3734) +++ trunk/matplotlib/setupext.py 2007-08-23 18:02:03 UTC (rev 3735) @@ -779,8 +779,6 @@ 'ttconv/pprdrv_tt.cpp', 'ttconv/pprdrv_tt2.cpp', 'ttconv/ttutil.cpp'] - deps.extend(glob.glob('CXX/*.cxx')) - deps.extend(glob.glob('CXX/*.c')) module = Extension('matplotlib.ttconv', deps) add_base_flags(module) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-08-23 18:00:44
|
Revision: 3734 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3734&view=rev Author: mdboom Date: 2007-08-23 11:00:42 -0700 (Thu, 23 Aug 2007) Log Message: ----------- Update PyCXX to latest upstream stable version (5.4.0) Modified Paths: -------------- trunk/matplotlib/CXX/Config.hxx trunk/matplotlib/CXX/Exception.hxx trunk/matplotlib/CXX/Extensions.hxx trunk/matplotlib/CXX/IndirectPythonInterface.cxx trunk/matplotlib/CXX/IndirectPythonInterface.hxx trunk/matplotlib/CXX/Objects.hxx trunk/matplotlib/CXX/Version.hxx trunk/matplotlib/CXX/cxx_extensions.cxx trunk/matplotlib/CXX/cxxextensions.c trunk/matplotlib/CXX/cxxsupport.cxx Added Paths: ----------- trunk/matplotlib/CXX/WrapPython.h Modified: trunk/matplotlib/CXX/Config.hxx =================================================================== --- trunk/matplotlib/CXX/Config.hxx 2007-08-23 17:59:21 UTC (rev 3733) +++ trunk/matplotlib/CXX/Config.hxx 2007-08-23 18:00:42 UTC (rev 3734) @@ -1,3 +1,40 @@ +//----------------------------------------------------------------------------- +// +// Copyright (c) 1998 - 2007, The Regents of the University of California +// Produced at the Lawrence Livermore National Laboratory +// All rights reserved. +// +// This file is part of PyCXX. For details,see http://cxx.sourceforge.net/. The +// full copyright notice is contained in the file COPYRIGHT located at the root +// of the PyCXX distribution. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// - Redistributions of source code must retain the above copyright notice, +// this list of conditions and the disclaimer below. +// - Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the disclaimer (as noted below) in the +// documentation and/or materials provided with the distribution. +// - Neither the name of the UC/LLNL nor the names of its contributors may be +// used to endorse or promote products derived from this software without +// specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OF THE UNIVERSITY OF +// CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR +// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +// DAMAGE. +// +//----------------------------------------------------------------------------- + #ifndef __PyCXX_config_hh__ #define __PyCXX_config_hh__ @@ -70,5 +107,12 @@ # define TEMPLATE_TYPENAME class #endif +// before 2.5 Py_ssize_t was missing +#ifndef PY_MAJOR_VERSION +#error not defined PY_MAJOR_VERSION +#endif +#if PY_MAJOR_VERSION < 2 || (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 5) +typedef int Py_ssize_t; +#endif #endif // __PyCXX_config_hh__ Modified: trunk/matplotlib/CXX/Exception.hxx =================================================================== --- trunk/matplotlib/CXX/Exception.hxx 2007-08-23 17:59:21 UTC (rev 3733) +++ trunk/matplotlib/CXX/Exception.hxx 2007-08-23 18:00:42 UTC (rev 3734) @@ -1,12 +1,44 @@ -//----------------------------------*-C++-*----------------------------------// -// Copyright 1998 The Regents of the University of California. -// All rights reserved. See LEGAL.LLNL for full text and disclaimer. -//---------------------------------------------------------------------------// +//----------------------------------------------------------------------------- +// +// Copyright (c) 1998 - 2007, The Regents of the University of California +// Produced at the Lawrence Livermore National Laboratory +// All rights reserved. +// +// This file is part of PyCXX. For details,see http://cxx.sourceforge.net/. The +// full copyright notice is contained in the file COPYRIGHT located at the root +// of the PyCXX distribution. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// - Redistributions of source code must retain the above copyright notice, +// this list of conditions and the disclaimer below. +// - Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the disclaimer (as noted below) in the +// documentation and/or materials provided with the distribution. +// - Neither the name of the UC/LLNL nor the names of its contributors may be +// used to endorse or promote products derived from this software without +// specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OF THE UNIVERSITY OF +// CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR +// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +// DAMAGE. +// +//----------------------------------------------------------------------------- #ifndef __CXX_Exception_h #define __CXX_Exception_h -#include "Python.h" +#include "CXX/WrapPython.h" #include "CXX/Version.hxx" #include "CXX/Config.hxx" #include "CXX/IndirectPythonInterface.hxx" @@ -16,202 +48,202 @@ // This mimics the Python structure, in order to minimize confusion namespace Py - { - class ExtensionExceptionType; +{ + class ExtensionExceptionType; - class Object; + class Object; - class Exception - { - public: - Exception( ExtensionExceptionType &exception, const std::string& reason ); - Exception( ExtensionExceptionType &exception, Object &reason ); + class Exception + { + public: + Exception( ExtensionExceptionType &exception, const std::string& reason ); + Exception( ExtensionExceptionType &exception, Object &reason ); - explicit Exception () - {} - - Exception (const std::string& reason) - { - PyErr_SetString (Py::_Exc_RuntimeError(), reason.c_str()); - } - - Exception (PyObject* exception, const std::string& reason) - { - PyErr_SetString (exception, reason.c_str()); - } - - Exception (PyObject* exception, Object &reason); + explicit Exception () + {} + + Exception (const std::string& reason) + { + PyErr_SetString (Py::_Exc_RuntimeError(), reason.c_str()); + } + + Exception (PyObject* exception, const std::string& reason) + { + PyErr_SetString (exception, reason.c_str()); + } + + Exception (PyObject* exception, Object &reason); - void clear() // clear the error - // technically but not philosophically const - { - PyErr_Clear(); - } - }; - - - // Abstract - class StandardError: public Exception - { - protected: - explicit StandardError() - {} - }; - - class LookupError: public StandardError - { - protected: - explicit LookupError() - {} - }; - - class ArithmeticError: public StandardError - { - protected: - explicit ArithmeticError() - {} - }; - - class EnvironmentError: public StandardError - { - protected: - explicit EnvironmentError() - {} - }; - - // Concrete - - class TypeError: public StandardError - { - public: - TypeError (const std::string& reason) - : StandardError() - { - PyErr_SetString (Py::_Exc_TypeError(),reason.c_str()); - } - }; - - class IndexError: public LookupError - { - public: - IndexError (const std::string& reason) - : LookupError() - { - PyErr_SetString (Py::_Exc_IndexError(), reason.c_str()); - } - }; - - class AttributeError: public StandardError - { - public: - AttributeError (const std::string& reason) - : StandardError() - { - PyErr_SetString (Py::_Exc_AttributeError(), reason.c_str()); - } - }; - - class NameError: public StandardError - { - public: - NameError (const std::string& reason) - : StandardError() - { - PyErr_SetString (Py::_Exc_NameError(), reason.c_str()); - } - }; - - class RuntimeError: public StandardError - { - public: - RuntimeError (const std::string& reason) - : StandardError() - { - PyErr_SetString (Py::_Exc_RuntimeError(), reason.c_str()); - } - }; - - class SystemError: public StandardError - { - public: - SystemError (const std::string& reason) - : StandardError() - { - PyErr_SetString (Py::_Exc_SystemError(),reason.c_str()); - } - }; - - class KeyError: public LookupError - { - public: - KeyError (const std::string& reason) - : LookupError() - { - PyErr_SetString (Py::_Exc_KeyError(),reason.c_str()); - } - }; - - - class ValueError: public StandardError - { - public: - ValueError (const std::string& reason) - : StandardError() - { - PyErr_SetString (Py::_Exc_ValueError(), reason.c_str()); - } - }; - - class OverflowError: public ArithmeticError - { - public: - OverflowError (const std::string& reason) - : ArithmeticError() - { - PyErr_SetString (Py::_Exc_OverflowError(), reason.c_str()); - } - }; - - class ZeroDivisionError: public ArithmeticError - { - public: - ZeroDivisionError (const std::string& reason) - : ArithmeticError() - { - PyErr_SetString (Py::_Exc_ZeroDivisionError(), reason.c_str()); - } - }; - - class FloatingPointError: public ArithmeticError - { - public: - FloatingPointError (const std::string& reason) - : ArithmeticError() - { - PyErr_SetString (Py::_Exc_FloatingPointError(), reason.c_str()); - } - }; - - class MemoryError: public StandardError - { - public: - MemoryError (const std::string& reason) - : StandardError() - { - PyErr_SetString (Py::_Exc_MemoryError(), reason.c_str()); - } - }; - - class SystemExit: public StandardError - { - public: - SystemExit (const std::string& reason) - : StandardError() - { - PyErr_SetString (Py::_Exc_SystemExit(),reason.c_str()); - } - }; + void clear() // clear the error + // technically but not philosophically const + { + PyErr_Clear(); + } + }; + + + // Abstract + class StandardError: public Exception + { + protected: + explicit StandardError() + {} + }; + + class LookupError: public StandardError + { + protected: + explicit LookupError() + {} + }; + + class ArithmeticError: public StandardError + { + protected: + explicit ArithmeticError() + {} + }; + + class EnvironmentError: public StandardError + { + protected: + explicit EnvironmentError() + {} + }; + + // Concrete + + class TypeError: public StandardError + { + public: + TypeError (const std::string& reason) + : StandardError() + { + PyErr_SetString (Py::_Exc_TypeError(),reason.c_str()); + } + }; + + class IndexError: public LookupError + { + public: + IndexError (const std::string& reason) + : LookupError() + { + PyErr_SetString (Py::_Exc_IndexError(), reason.c_str()); + } + }; + + class AttributeError: public StandardError + { + public: + AttributeError (const std::string& reason) + : StandardError() + { + PyErr_SetString (Py::_Exc_AttributeError(), reason.c_str()); + } + }; + + class NameError: public StandardError + { + public: + NameError (const std::string& reason) + : StandardError() + { + PyErr_SetString (Py::_Exc_NameError(), reason.c_str()); + } + }; + + class RuntimeError: public StandardError + { + public: + RuntimeError (const std::string& reason) + : StandardError() + { + PyErr_SetString (Py::_Exc_RuntimeError(), reason.c_str()); + } + }; + + class SystemError: public StandardError + { + public: + SystemError (const std::string& reason) + : StandardError() + { + PyErr_SetString (Py::_Exc_SystemError(),reason.c_str()); + } + }; + + class KeyError: public LookupError + { + public: + KeyError (const std::string& reason) + : LookupError() + { + PyErr_SetString (Py::_Exc_KeyError(),reason.c_str()); + } + }; + + + class ValueError: public StandardError + { + public: + ValueError (const std::string& reason) + : StandardError() + { + PyErr_SetString (Py::_Exc_ValueError(), reason.c_str()); + } + }; + + class OverflowError: public ArithmeticError + { + public: + OverflowError (const std::string& reason) + : ArithmeticError() + { + PyErr_SetString (Py::_Exc_OverflowError(), reason.c_str()); + } + }; + + class ZeroDivisionError: public ArithmeticError + { + public: + ZeroDivisionError (const std::string& reason) + : ArithmeticError() + { + PyErr_SetString (Py::_Exc_ZeroDivisionError(), reason.c_str()); + } + }; + + class FloatingPointError: public ArithmeticError + { + public: + FloatingPointError (const std::string& reason) + : ArithmeticError() + { + PyErr_SetString (Py::_Exc_FloatingPointError(), reason.c_str()); + } + }; + + class MemoryError: public StandardError + { + public: + MemoryError (const std::string& reason) + : StandardError() + { + PyErr_SetString (Py::_Exc_MemoryError(), reason.c_str()); + } + }; + + class SystemExit: public StandardError + { + public: + SystemExit (const std::string& reason) + : StandardError() + { + PyErr_SetString (Py::_Exc_SystemExit(),reason.c_str()); + } + }; - }// Py +}// Py #endif Modified: trunk/matplotlib/CXX/Extensions.hxx =================================================================== --- trunk/matplotlib/CXX/Extensions.hxx 2007-08-23 17:59:21 UTC (rev 3733) +++ trunk/matplotlib/CXX/Extensions.hxx 2007-08-23 18:00:42 UTC (rev 3734) @@ -1,7 +1,39 @@ -//----------------------------------*-C++-*----------------------------------// -// Copyright 1998 The Regents of the University of California. -// All rights reserved. See LEGAL.LLNL for full text and disclaimer. -//---------------------------------------------------------------------------// +//----------------------------------------------------------------------------- +// +// Copyright (c) 1998 - 2007, The Regents of the University of California +// Produced at the Lawrence Livermore National Laboratory +// All rights reserved. +// +// This file is part of PyCXX. For details,see http://cxx.sourceforge.net/. The +// full copyright notice is contained in the file COPYRIGHT located at the root +// of the PyCXX distribution. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// - Redistributions of source code must retain the above copyright notice, +// this list of conditions and the disclaimer below. +// - Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the disclaimer (as noted below) in the +// documentation and/or materials provided with the distribution. +// - Neither the name of the UC/LLNL nor the names of its contributors may be +// used to endorse or promote products derived from this software without +// specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OF THE UNIVERSITY OF +// CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR +// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +// DAMAGE. +// +//----------------------------------------------------------------------------- #ifndef __CXX_Extensions__h #define __CXX_Extensions__h @@ -13,749 +45,747 @@ #pragma warning(disable: 4786) #endif - +#include "CXX/WrapPython.h" #include "CXX/Version.hxx" #include "CXX/Config.hxx" #include "CXX/Objects.hxx" extern "C" - { - extern PyObject py_object_initializer; - } +{ + extern PyObject py_object_initializer; +} #include <vector> #include <map> namespace Py - { - class ExtensionModuleBase; - - // Make an Exception Type for use in raising custom exceptions - class ExtensionExceptionType : public Object - { - public: - ExtensionExceptionType(); - virtual ~ExtensionExceptionType(); +{ + class ExtensionModuleBase; + + // Make an Exception Type for use in raising custom exceptions + class ExtensionExceptionType : public Object + { + public: + ExtensionExceptionType(); + virtual ~ExtensionExceptionType(); - // call init to create the type - void init( ExtensionModuleBase &module, const std::string& name, ExtensionExceptionType &parent ); - void init( ExtensionModuleBase &module, const std::string& name ); - }; + // call init to create the type + void init( ExtensionModuleBase &module, const std::string& name, ExtensionExceptionType &parent ); + void init( ExtensionModuleBase &module, const std::string& name ); + }; - - class MethodTable - { - public: - MethodTable(); - virtual ~MethodTable(); - - void add(const char* method_name, PyCFunction f, const char* doc="", int flag=1); - PyMethodDef* table(); - - protected: - std::vector<PyMethodDef> t; // accumulator of PyMethodDef's - PyMethodDef *mt; // Actual method table produced when full - - static PyMethodDef method (const char* method_name, PyCFunction f, int flags = 1, const char* doc=""); - - private: - // - // prevent the compiler generating these unwanted functions - // - MethodTable(const MethodTable& m); //unimplemented - void operator=(const MethodTable& m); //unimplemented - - }; // end class MethodTable - - extern "C" - { - typedef PyObject *(*method_varargs_call_handler_t)( PyObject *_self, PyObject *_args ); - typedef PyObject *(*method_keyword_call_handler_t)( PyObject *_self, PyObject *_args, PyObject *_dict ); - }; - - template<class T> - class MethodDefExt : public PyMethodDef - { - public: - typedef Object (T::*method_varargs_function_t)( const Tuple &args ); - typedef Object (T::*method_keyword_function_t)( const Tuple &args, const Dict &kws ); - - MethodDefExt - ( - const char *_name, - method_varargs_function_t _function, - method_varargs_call_handler_t _handler, - const char *_doc - ) - { - ext_meth_def.ml_name = const_cast<char *>(_name); - ext_meth_def.ml_meth = _handler; - ext_meth_def.ml_flags = METH_VARARGS; - ext_meth_def.ml_doc = const_cast<char *>(_doc); - - ext_varargs_function = _function; - ext_keyword_function = NULL; - } - - MethodDefExt - ( - const char *_name, - method_keyword_function_t _function, - method_keyword_call_handler_t _handler, - const char *_doc - ) - { - ext_meth_def.ml_name = const_cast<char *>(_name); - ext_meth_def.ml_meth = method_varargs_call_handler_t( _handler ); - ext_meth_def.ml_flags = METH_VARARGS|METH_KEYWORDS; - ext_meth_def.ml_doc = const_cast<char *>(_doc); - - ext_varargs_function = NULL; - ext_keyword_function = _function; - } - - ~MethodDefExt() - {} - - PyMethodDef ext_meth_def; - method_varargs_function_t ext_varargs_function; - method_keyword_function_t ext_keyword_function; - }; - - class ExtensionModuleBase - { - public: - ExtensionModuleBase( const char *name ); - virtual ~ExtensionModuleBase(); - - Module module(void) const; // only valid after initialize() has been called - Dict moduleDictionary(void) const; // only valid after initialize() has been called - - virtual Object invoke_method_keyword( const std::string &_name, const Tuple &_args, const Dict &_keywords ) = 0; - virtual Object invoke_method_varargs( const std::string &_name, const Tuple &_args ) = 0; - - const std::string &name() const; - const std::string &fullName() const; - - protected: - // Initialize the module - void initialize( const char *module_doc ); - - const std::string module_name; - const std::string full_module_name; - MethodTable method_table; - - private: - - // - // prevent the compiler generating these unwanted functions - // - ExtensionModuleBase( const ExtensionModuleBase & ); //unimplemented - void operator=( const ExtensionModuleBase & ); //unimplemented - - }; - - extern "C" PyObject *method_keyword_call_handler( PyObject *_self_and_name_tuple, PyObject *_args, PyObject *_keywords ); - extern "C" PyObject *method_varargs_call_handler( PyObject *_self_and_name_tuple, PyObject *_args ); - extern "C" void do_not_dealloc( void * ); - - - template<TEMPLATE_TYPENAME T> - class ExtensionModule : public ExtensionModuleBase - { - public: - ExtensionModule( const char *name ) - : ExtensionModuleBase( name ) - {} - virtual ~ExtensionModule() - {} - - protected: - typedef Object (T::*method_varargs_function_t)( const Tuple &args ); - typedef Object (T::*method_keyword_function_t)( const Tuple &args, const Dict &kws ); - typedef std::map<std::string,MethodDefExt<T> *> method_map_t; - - static void add_varargs_method( const char *name, method_varargs_function_t function, const char *doc="" ) - { - method_map_t &mm = methods(); - - MethodDefExt<T> *method_definition = new MethodDefExt<T> - ( - name, - function, - method_varargs_call_handler, - doc - ); - - mm[std::string( name )] = method_definition; - } - - static void add_keyword_method( const char *name, method_keyword_function_t function, const char *doc="" ) - { - method_map_t &mm = methods(); - - MethodDefExt<T> *method_definition = new MethodDefExt<T> - ( - name, - function, - method_keyword_call_handler, - doc - ); - - mm[std::string( name )] = method_definition; - } + + class MethodTable + { + public: + MethodTable(); + virtual ~MethodTable(); + + void add(const char* method_name, PyCFunction f, const char* doc="", int flag=1); + PyMethodDef* table(); + + protected: + std::vector<PyMethodDef> t; // accumulator of PyMethodDef's + PyMethodDef *mt; // Actual method table produced when full + + static PyMethodDef method (const char* method_name, PyCFunction f, int flags = 1, const char* doc=""); + + private: + // + // prevent the compiler generating these unwanted functions + // + MethodTable(const MethodTable& m); //unimplemented + void operator=(const MethodTable& m); //unimplemented + + }; // end class MethodTable + + extern "C" + { + typedef PyObject *(*method_varargs_call_handler_t)( PyObject *_self, PyObject *_args ); + typedef PyObject *(*method_keyword_call_handler_t)( PyObject *_self, PyObject *_args, PyObject *_dict ); + }; + + template<class T> + class MethodDefExt : public PyMethodDef + { + public: + typedef Object (T::*method_varargs_function_t)( const Tuple &args ); + typedef Object (T::*method_keyword_function_t)( const Tuple &args, const Dict &kws ); + + MethodDefExt + ( + const char *_name, + method_varargs_function_t _function, + method_varargs_call_handler_t _handler, + const char *_doc + ) + { + ext_meth_def.ml_name = const_cast<char *>(_name); + ext_meth_def.ml_meth = _handler; + ext_meth_def.ml_flags = METH_VARARGS; + ext_meth_def.ml_doc = const_cast<char *>(_doc); + + ext_varargs_function = _function; + ext_keyword_function = NULL; + } + + MethodDefExt + ( + const char *_name, + method_keyword_function_t _function, + method_keyword_call_handler_t _handler, + const char *_doc + ) + { + ext_meth_def.ml_name = const_cast<char *>(_name); + ext_meth_def.ml_meth = method_varargs_call_handler_t( _handler ); + ext_meth_def.ml_flags = METH_VARARGS|METH_KEYWORDS; + ext_meth_def.ml_doc = const_cast<char *>(_doc); + + ext_varargs_function = NULL; + ext_keyword_function = _function; + } + + ~MethodDefExt() + {} + + PyMethodDef ext_meth_def; + method_varargs_function_t ext_varargs_function; + method_keyword_function_t ext_keyword_function; + }; + + class ExtensionModuleBase + { + public: + ExtensionModuleBase( const char *name ); + virtual ~ExtensionModuleBase(); + + Module module(void) const; // only valid after initialize() has been called + Dict moduleDictionary(void) const; // only valid after initialize() has been called + + virtual Object invoke_method_keyword( const std::string &_name, const Tuple &_args, const Dict &_keywords ) = 0; + virtual Object invoke_method_varargs( const std::string &_name, const Tuple &_args ) = 0; + + const std::string &name() const; + const std::string &fullName() const; + + protected: + // Initialize the module + void initialize( const char *module_doc ); + + const std::string module_name; + const std::string full_module_name; + MethodTable method_table; + + private: + + // + // prevent the compiler generating these unwanted functions + // + ExtensionModuleBase( const ExtensionModuleBase & ); //unimplemented + void operator=( const ExtensionModuleBase & ); //unimplemented + + }; + + extern "C" PyObject *method_keyword_call_handler( PyObject *_self_and_name_tuple, PyObject *_args, PyObject *_keywords ); + extern "C" PyObject *method_varargs_call_handler( PyObject *_self_and_name_tuple, PyObject *_args ); + extern "C" void do_not_dealloc( void * ); + + + template<TEMPLATE_TYPENAME T> + class ExtensionModule : public ExtensionModuleBase + { + public: + ExtensionModule( const char *name ) + : ExtensionModuleBase( name ) + {} + virtual ~ExtensionModule() + {} + + protected: + typedef Object (T::*method_varargs_function_t)( const Tuple &args ); + typedef Object (T::*method_keyword_function_t)( const Tuple &args, const Dict &kws ); + typedef std::map<std::string,MethodDefExt<T> *> method_map_t; + + static void add_varargs_method( const char *name, method_varargs_function_t function, const char *doc="" ) + { + method_map_t &mm = methods(); + + MethodDefExt<T> *method_definition = new MethodDefExt<T> + ( + name, + function, + method_varargs_call_handler, + doc + ); + + mm[std::string( name )] = method_definition; + } + + static void add_keyword_method( const char *name, method_keyword_function_t function, const char *doc="" ) + { + method_map_t &mm = methods(); + + MethodDefExt<T> *method_definition = new MethodDefExt<T> + ( + name, + function, + method_keyword_call_handler, + doc + ); + + mm[std::string( name )] = method_definition; + } - void initialize( const char *module_doc="" ) - { - ExtensionModuleBase::initialize( module_doc ); - Dict dict( moduleDictionary() ); - - // - // put each of the methods into the modules dictionary - // so that we get called back at the function in T. - // - method_map_t &mm = methods(); - EXPLICIT_TYPENAME method_map_t::iterator i; - - for( i=mm.begin(); i != mm.end(); ++i ) - { - MethodDefExt<T> *method_definition = (*i).second; - - static PyObject *self = PyCObject_FromVoidPtr( this, do_not_dealloc ); - - Tuple args( 2 ); - args[0] = Object( self ); - args[1] = String( (*i).first ); - - PyObject *func = PyCFunction_New - ( - &method_definition->ext_meth_def, - new_reference_to( args ) - ); - - dict[ (*i).first ] = Object( func ); - } - } - - protected: // Tom Malcolmson reports that derived classes need access to these - - static method_map_t &methods(void) - { - static method_map_t *map_of_methods = NULL; - if( map_of_methods == NULL ) - map_of_methods = new method_map_t; - - return *map_of_methods; - } - - - // this invoke function must be called from within a try catch block - virtual Object invoke_method_keyword( const std::string &name, const Tuple &args, const Dict &keywords ) - { - method_map_t &mm = methods(); - MethodDefExt<T> *meth_def = mm[ name ]; - if( meth_def == NULL ) - { - std::string error_msg( "CXX - cannot invoke keyword method named " ); - error_msg += name; - throw RuntimeError( error_msg ); - } - - // cast up to the derived class - T *self = static_cast<T *>(this); - - return (self->*meth_def->ext_keyword_function)( args, keywords ); - } - - // this invoke function must be called from within a try catch block - virtual Object invoke_method_varargs( const std::string &name, const Tuple &args ) - { - method_map_t &mm = methods(); - MethodDefExt<T> *meth_def = mm[ name ]; - if( meth_def == NULL ) - { - std::string error_msg( "CXX - cannot invoke varargs method named " ); - error_msg += name; - throw RuntimeError( error_msg ); - } - - // cast up to the derived class - T *self = static_cast<T *>(this); - - return (self->*meth_def->ext_varargs_function)( args ); - } - - private: - // - // prevent the compiler generating these unwanted functions - // - ExtensionModule( const ExtensionModule<T> & ); //unimplemented - void operator=( const ExtensionModule<T> & ); //unimplemented - }; - - - class PythonType - { - public: - // if you define one sequence method you must define - // all of them except the assigns - - PythonType (size_t base_size, int itemsize, const char *default_name ); - virtual ~PythonType (); - - const char *getName () const; - const char *getDoc () const; + void initialize( const char *module_doc="" ) + { + ExtensionModuleBase::initialize( module_doc ); + Dict dict( moduleDictionary() ); + + // + // put each of the methods into the modules dictionary + // so that we get called back at the function in T. + // + method_map_t &mm = methods(); + EXPLICIT_TYPENAME method_map_t::iterator i; + + for( i=mm.begin(); i != mm.end(); ++i ) + { + MethodDefExt<T> *method_definition = (*i).second; + + static PyObject *self = PyCObject_FromVoidPtr( this, do_not_dealloc ); + + Tuple args( 2 ); + args[0] = Object( self ); + args[1] = String( (*i).first ); + + PyObject *func = PyCFunction_New + ( + &method_definition->ext_meth_def, + new_reference_to( args ) + ); + + dict[ (*i).first ] = Object( func ); + } + } + + protected: // Tom Malcolmson reports that derived classes need access to these + + static method_map_t &methods(void) + { + static method_map_t *map_of_methods = NULL; + if( map_of_methods == NULL ) + map_of_methods = new method_map_t; + + return *map_of_methods; + } + + + // this invoke function must be called from within a try catch block + virtual Object invoke_method_keyword( const std::string &name, const Tuple &args, const Dict &keywords ) + { + method_map_t &mm = methods(); + MethodDefExt<T> *meth_def = mm[ name ]; + if( meth_def == NULL ) + { + std::string error_msg( "CXX - cannot invoke keyword method named " ); + error_msg += name; + throw RuntimeError( error_msg ); + } + + // cast up to the derived class + T *self = static_cast<T *>(this); + + return (self->*meth_def->ext_keyword_function)( args, keywords ); + } + + // this invoke function must be called from within a try catch block + virtual Object invoke_method_varargs( const std::string &name, const Tuple &args ) + { + method_map_t &mm = methods(); + MethodDefExt<T> *meth_def = mm[ name ]; + if( meth_def == NULL ) + { + std::string error_msg( "CXX - cannot invoke varargs method named " ); + error_msg += name; + throw RuntimeError( error_msg ); + } + + // cast up to the derived class + T *self = static_cast<T *>(this); + + return (self->*meth_def->ext_varargs_function)( args ); + } + + private: + // + // prevent the compiler generating these unwanted functions + // + ExtensionModule( const ExtensionModule<T> & ); //unimplemented + void operator=( const ExtensionModule<T> & ); //unimplemented + }; + + + class PythonType + { + public: + // if you define one sequence method you must define + // all of them except the assigns + + PythonType (size_t base_size, int itemsize, const char *default_name ); + virtual ~PythonType (); + + const char *getName () const; + const char *getDoc () const; - PyTypeObject* type_object () const; - void name (const char* nam); - void doc (const char* d); - void dealloc(void (*f)(PyObject*)); - - void supportPrint(void); - void supportGetattr(void); - void supportSetattr(void); - void supportGetattro(void); - void supportSetattro(void); - void supportCompare(void); - void supportRepr(void); - void supportStr(void); - void supportHash(void); - void supportCall(void); - void supportIter(void); - - void supportSequenceType(void); - void supportMappingType(void); - void supportNumberType(void); - void supportBufferType(void); - - protected: - PyTypeObject *table; - PySequenceMethods *sequence_table; - PyMappingMethods *mapping_table; - PyNumberMethods *number_table; - PyBufferProcs *buffer_table; - - void init_sequence(); - void init_mapping(); - void init_number(); - void init_buffer(); - - private: - // - // prevent the compiler generating these unwanted functions - // - PythonType (const PythonType& tb); // unimplemented - void operator=(const PythonType& t); // unimplemented - - }; // end of PythonType - - - - // Class PythonExtension is what you inherit from to create - // a new Python extension type. You give your class itself - // as the template paramter. - - // There are two ways that extension objects can get destroyed. - // 1. Their reference count goes to zero - // 2. Someone does an explicit delete on a pointer. - // In (1) the problem is to get the destructor called - // We register a special deallocator in the Python type object - // (see behaviors()) to do this. - // In (2) there is no problem, the dtor gets called. - - // PythonExtension does not use the usual Python heap allocator, - // instead using new/delete. We do the setting of the type object - // and reference count, usually done by PyObject_New, in the - // base class ctor. - - // This special deallocator does a delete on the pointer. - - - class PythonExtensionBase : public PyObject - { - public: - PythonExtensionBase(); - virtual ~PythonExtensionBase(); - - public: - virtual int print( FILE *, int ); - virtual Object getattr( const char * ) = 0; - virtual int setattr( const char *, const Object & ); - virtual Object getattro( const Object & ); - virtual int setattro( const Object &, const Object & ); - virtual int compare( const Object & ); - virtual Object repr(); - virtual Object str(); - virtual long hash(); - virtual Object call( const Object &, const Object & ); + PyTypeObject* type_object () const; + PythonType & name (const char* nam); + PythonType & doc (const char* d); + PythonType & dealloc(void (*f)(PyObject*)); + + PythonType & supportPrint(void); + PythonType & supportGetattr(void); + PythonType & supportSetattr(void); + PythonType & supportGetattro(void); + PythonType & supportSetattro(void); + PythonType & supportCompare(void); + PythonType & supportRepr(void); + PythonType & supportStr(void); + PythonType & supportHash(void); + PythonType & supportCall(void); + PythonType & supportIter(void); + + PythonType & supportSequenceType(void); + PythonType & supportMappingType(void); + PythonType & supportNumberType(void); + PythonType & supportBufferType(void); + + protected: + PyTypeObject *table; + PySequenceMethods *sequence_table; + PyMappingMethods *mapping_table; + PyNumberMethods *number_table; + PyBufferProcs *buffer_table; + + void init_sequence(); + void init_mapping(); + void init_number(); + void init_buffer(); + + private: + // + // prevent the compiler generating these unwanted functions + // + PythonType (const PythonType& tb); // unimplemented + void operator=(const PythonType& t); // unimplemented + + }; // end of PythonType + + + + // Class PythonExtension is what you inherit from to create + // a new Python extension type. You give your class itself + // as the template paramter. + + // There are two ways that extension objects can get destroyed. + // 1. Their reference count goes to zero + // 2. Someone does an explicit delete on a pointer. + // In (1) the problem is to get the destructor called + // We register a special deallocator in the Python type object + // (see behaviors()) to do this. + // In (2) there is no problem, the dtor gets called. + + // PythonExtension does not use the usual Python heap allocator, + // instead using new/delete. We do the setting of the type object + // and reference count, usually done by PyObject_New, in the + // base class ctor. + + // This special deallocator does a delete on the pointer. + + + class PythonExtensionBase : public PyObject + { + public: + PythonExtensionBase(); + virtual ~PythonExtensionBase(); + + public: + virtual int print( FILE *, int ); + virtual Object getattr( const char * ) = 0; + virtual int setattr( const char *, const Object & ); + virtual Object getattro( const Object & ); + virtual int setattro( const Object &, const Object & ); + virtual int compare( const Object & ); + virtual Object repr(); + virtual Object str(); + virtual long hash(); + virtual Object call( const Object &, const Object & ); virtual Object iter(); virtual PyObject* iternext(); - - // Sequence methods - virtual int sequence_length(); - virtual Object sequence_concat( const Object & ); - virtual Object sequence_repeat( int ); - virtual Object sequence_item( int ); - virtual Object sequence_slice( int, int ); - virtual int sequence_ass_item( int, const Object & ); - virtual int sequence_ass_slice( int, int, const Object & ); - - // Mapping - virtual int mapping_length(); - virtual Object mapping_subscript( const Object & ); - virtual int mapping_ass_subscript( const Object &, const Object & ); - - // Number - virtual int number_nonzero(); - virtual Object number_negative(); - virtual Object number_positive(); - virtual Object number_absolute(); - virtual Object number_invert(); - virtual Object number_int(); - virtual Object number_float(); - virtual Object number_long(); - virtual Object number_oct(); - virtual Object number_hex(); - virtual Object number_add( const Object & ); - virtual Object number_subtract( const Object & ); - virtual Object number_multiply( const Object & ); - virtual Object number_divide( const Object & ); - virtual Object number_remainder( const Object & ); - virtual Object number_divmod( const Object & ); - virtual Object number_lshift( const Object & ); - virtual Object number_rshift( const Object & ); - virtual Object number_and( const Object & ); - virtual Object number_xor( const Object & ); - virtual Object number_or( const Object & ); - virtual Object number_power( const Object &, const Object & ); - - // Buffer - virtual Py_ssize_t buffer_getreadbuffer( Py_ssize_t, void** ); - virtual Py_ssize_t buffer_getwritebuffer( Py_ssize_t, void** ); - virtual Py_ssize_t buffer_getsegcount( Py_ssize_t* ); - - private: - void missing_method( void ); - static PyObject *method_call_handler( PyObject *self, PyObject *args ); - }; - - template<TEMPLATE_TYPENAME T> - class PythonExtension: public PythonExtensionBase - { - public: - static PyTypeObject* type_object() - { - return behaviors().type_object(); - } - - static int check( PyObject *p ) - { - // is p like me? - return p->ob_type == type_object(); - } - - static int check( const Object& ob ) - { - return check( ob.ptr()); - } - - - // - // every object needs getattr implemented - // to support methods - // - virtual Object getattr( const char *name ) - { - return getattr_methods( name ); - } - - protected: - explicit PythonExtension() - : PythonExtensionBase() - { - #ifdef PyObject_INIT - (void)PyObject_INIT( this, type_object() ); - #else - ob_refcnt = 1; - ob_type = type_object(); - #endif - - // every object must support getattr - behaviors().supportGetattr(); - } - - virtual ~PythonExtension() - {} - - static PythonType &behaviors() - { - static PythonType* p; - if( p == NULL ) - { + + // Sequence methods + virtual int sequence_length(); + virtual Object sequence_concat( const Object & ); + virtual Object sequence_repeat( Py_ssize_t ); + virtual Object sequence_item( Py_ssize_t ); + virtual Object sequence_slice( Py_ssize_t, Py_ssize_t ); + virtual int sequence_ass_item( Py_ssize_t, const Object & ); + virtual int sequence_ass_slice( Py_ssize_t, Py_ssize_t, const Object & ); + + // Mapping + virtual int mapping_length(); + virtual Object mapping_subscript( const Object & ); + virtual int mapping_ass_subscript( const Object &, const Object & ); + + // Number + virtual int number_nonzero(); + virtual Object number_negative(); + virtual Object number_positive(); + virtual Object number_absolute(); + virtual Object number_invert(); + virtual Object number_int(); + virtual Object number_float(); + virtual Object number_long(); + virtual Object number_oct(); + virtual Object number_hex(); + virtual Object number_add( const Object & ); + virtual Object number_subtract( const Object & ); + virtual Object number_multiply( const Object & ); + virtual Object number_divide( const Object & ); + virtual Object number_remainder( const Object & ); + virtual Object number_divmod( const Object & ); + virtual Object number_lshift( const Object & ); + virtual Object number_rshift( const Object & ); + virtual Object number_and( const Object & ); + virtual Object number_xor( const Object & ); + virtual Object number_or( const Object & ); + virtual Object number_power( const Object &, const Object & ); + + // Buffer + virtual Py_ssize_t buffer_getreadbuffer( Py_ssize_t, void** ); + virtual Py_ssize_t buffer_getwritebuffer( Py_ssize_t, void** ); + virtual Py_ssize_t buffer_getsegcount( Py_ssize_t* ); + + private: + void missing_method( void ); + static PyObject *method_call_handler( PyObject *self, PyObject *args ); + }; + + template<TEMPLATE_TYPENAME T> + class PythonExtension: public PythonExtensionBase + { + public: + static PyTypeObject* type_object() + { + return behaviors().type_object(); + } + + static int check( PyObject *p ) + { + // is p like me? + return p->ob_type == type_object(); + } + + static int check( const Object& ob ) + { + return check( ob.ptr()); + } + + + // + // every object needs getattr implemented + // to support methods + // + virtual Object getattr( const char *name ) + { + return getattr_methods( name ); + } + + protected: + explicit PythonExtension() + : PythonExtensionBase() + { + #ifdef PyObject_INIT + (void)PyObject_INIT( this, type_object() ); + #else + ob_refcnt = 1; + ob_type = type_object(); + #endif + + // every object must support getattr + behaviors().supportGetattr(); + } + + virtual ~PythonExtension() + {} + + static PythonType &behaviors() + { + static PythonType* p; + if( p == NULL ) + { #if defined( _CPPRTTI ) || defined(__GNUG__) - const char *default_name = (typeid ( T )).name(); + const char *default_name = (typeid ( T )).name(); #else - const char *default_name = "unknown"; + const char *default_name = "unknown"; #endif - p = new PythonType( sizeof( T ), 0, default_name ); - p->dealloc( extension_object_deallocator ); - } - - return *p; - } - - - typedef Object (T::*method_varargs_function_t)( const Tuple &args ); - typedef Object (T::*method_keyword_function_t)( const Tuple &args, const Dict &kws ); - typedef std::map<std::string,MethodDefExt<T> *> method_map_t; - - // support the default attributes, __name__, __doc__ and methods - virtual Object getattr_default( const char *_name ) - { - std::string name( _name ); + p = new PythonType( sizeof( T ), 0, default_name ); + p->dealloc( extension_object_deallocator ); + } + + return *p; + } + + + typedef Object (T::*method_varargs_function_t)( const Tuple &args ); + typedef Object (T::*method_keyword_function_t)( const Tuple &args, const Dict &kws ); + typedef std::map<std::string,MethodDefExt<T> *> method_map_t; + + // support the default attributes, __name__, __doc__ and methods + virtual Object getattr_default( const char *_name ) + { + std::string name( _name ); - if( name == "__name__" && type_object()->tp_name != NULL ) - { - return Py::String( type_object()->tp_name ); - } - else if( name == "__doc__" && type_object()->tp_doc != NULL ) - { - return Py::String( type_object()->tp_doc ); - } + if( name == "__name__" && type_object()->tp_name != NULL ) + { + return Py::String( type_object()->tp_name ); + } + if( name == "__doc__" && type_object()->tp_doc != NULL ) + { + return Py::String( type_object()->tp_doc ); + } // trying to fake out being a class for help() -// else if( name == "__bases__" ) -// { -// return Py::Tuple(0); -// } -// else if( name == "__module__" ) -// { -// return Py::Nothing(); -// } -// else if( name == "__dict__" ) -// { -// return Py::Dict(); -// } - else - { - return getattr_methods( _name ); - } - } +// else if( name == "__bases__" ) +// { +// return Py::Tuple(0); +// } +// else if( name == "__module__" ) +// { +// return Py::Nothing(); +// } +// else if( name == "__dict__" ) +// { +// return Py::Dict(); +// } - // turn a name into function object - virtual Object getattr_methods( const char *_name ) - { - std::string name( _name ); - - method_map_t &mm = methods(); - - if( name == "__methods__" ) - { - List methods; - - for( EXPLICIT_TYPENAME method_map_t::iterator i = mm.begin(); i != mm.end(); ++i ) - methods.append( String( (*i).first ) ); - - return methods; - } - - // see if name exists - if( mm.find( name ) == mm.end() ) - throw AttributeError( name ); - - Tuple self( 2 ); - - self[0] = Object( this ); - self[1] = String( name ); - - MethodDefExt<T> *method_definition = mm[ name ]; - - PyObject *func = PyCFunction_New( &method_definition->ext_meth_def, self.ptr() ); - - return Object(func, true); - } - - static void add_varargs_method( const char *name, method_varargs_function_t function, const char *doc="" ) - { - method_map_t &mm = methods(); - - MethodDefExt<T> *method_definition = new MethodDefExt<T> - ( - name, - function, - method_varargs_call_handler, - doc - ); - - mm[std::string( name )] = method_definition; - } - - static void add_keyword_method( const char *name, method_keyword_function_t function, const char *doc="" ) - { - method_map_t &mm = methods(); - - MethodDefExt<T> *method_definition = new MethodDefExt<T> - ( - name, - function, - method_keyword_call_handler, - doc - ); - - mm[std::string( name )] = method_definition; - } - - private: - static method_map_t &methods(void) - { - static method_map_t *map_of_methods = NULL; - if( map_of_methods == NULL ) - map_of_methods = new method_map_t; - - return *map_of_methods; - } - - static PyObject *method_keyword_call_handler( PyObject *_self_and_name_tuple, PyObject *_args, PyObject *_keywords ) - { - try - { - Tuple self_and_name_tuple( _self_and_name_tuple ); - - PyObject *self_in_cobject = self_and_name_tuple[0].ptr(); - T *self = static_cast<T *>( self_in_cobject ); - - String name( self_and_name_tuple[1] ); - - method_map_t &mm = methods(); - MethodDefExt<T> *meth_def = mm[ name ]; - if( meth_def == NULL ) - return 0; - - Tuple args( _args ); + return getattr_methods( _name ); + } - // _keywords may be NULL so be careful about the way the dict is created - Dict keywords; - if( _keywords != NULL ) - keywords = Dict( _keywords ); - - Object result( (self->*meth_def->ext_keyword_function)( args, keywords ) ); - - return new_reference_to( result.ptr() ); - } - catch( Exception & ) - { - return 0; - } - } - - static PyObject *method_varargs_call_handler( PyObject *_self_and_name_tuple, PyObject *_args ) - { - try - { - Tuple self_and_name_tuple( _self_and_name_tuple ); - - PyObject *self_in_cobject = self_and_name_tuple[0].ptr(); - T *self = static_cast<T *>( self_in_cobject ); - - String name( self_and_name_tuple[1] ); - - method_map_t &mm = methods(); - MethodDefExt<T> *meth_def = mm[ name ]; - if( meth_def == NULL ) - return 0; - - Tuple args( _args ); - - Object result; - - // TMM: 7Jun'01 - Adding try & catch in case of STL debug-mode exceptions. - #ifdef _STLP_DEBUG - try - { - result = (self->*meth_def->ext_varargs_function)( args ); - } - catch (std::__stl_debug_exception) - { - // throw cxx::RuntimeError( sErrMsg ); - throw cxx::RuntimeError( "Error message not set yet." ); - } - #else - result = (self->*meth_def->ext_varargs_function)( args ); - #endif // _STLP_DEBUG - - return new_reference_to( result.ptr() ); - } - catch( Exception & ) - { - return 0; - } - } - - static void extension_object_deallocator ( PyObject* t ) - { - delete (T *)( t ); - } - - // - // prevent the compiler generating these unwanted functions - // - explicit PythonExtension( const PythonExtension<T>& other ); - void operator=( const PythonExtension<T>& rhs ); - }; - - // - // ExtensionObject<T> is an Object that will accept only T's. - // - template<TEMPLATE_TYPENAME T> - class ExtensionObject: public Object - { - public: - - explicit ExtensionObject ( PyObject *pyob ) - : Object( pyob ) - { - validate(); - } - - ExtensionObject( const ExtensionObject<T>& other ) - : Object( *other ) - { - validate(); - } - - ExtensionObject( const Object& other ) - : Object( *other ) - { - validate(); - } - - ExtensionObject& operator= ( const Object& rhs ) - { - return (*this = *rhs ); - } - - ExtensionObject& operator= ( PyObject* rhsp ) - { - if( ptr() == rhsp ) - return *this; - set( rhsp ); - return *this; - } - - virtual bool accepts ( PyObject *pyob ) const - { - return ( pyob && T::check( pyob )); - } - - // - // Obtain a pointer to the PythonExtension object - // - T *extensionObject(void) - { - return static_cast<T *>( ptr() ); - } - }; - - } // Namespace Py + // turn a name into function object + virtual Object getattr_methods( const char *_name ) + { + std::string name( _name ); + + method_map_t &mm = methods(); + + if( name == "__methods__" ) + { + List methods; + + for( EXPLICIT_TYPENAME method_map_t::iterator i = mm.begin(); i != mm.end(); ++i ) + methods.append( String( (*i).first ) ); + + return methods; + } + + // see if name exists + if( mm.find( name ) == mm.end() ) + throw AttributeError( name ); + + Tuple self( 2 ); + + self[0] = Object( this ); + self[1] = String( name ); + + MethodDefExt<T> *method_definition = mm[ name ]; + + PyObject *func = PyCFunction_New( &method_definition->ext_meth_def, self.ptr() ); + + return Object(func, true); + } + + static void add_varargs_method( const char *name, method_varargs_function_t function, const char *doc="" ) + { + method_map_t &mm = methods(); + + MethodDefExt<T> *method_definition = new MethodDefExt<T> + ( + name, + function, + method_varargs_call_handler, + doc + ); + + mm[std::string( name )] = method_definition; + } + + static void add_keyword_method( const char *name, method_keyword_function_t function, const char *doc="" ) + { + method_map_t &mm = methods(); + + MethodDefExt<T> *method_definition = new MethodDefExt<T> + ( + name, + function, + method_keyword_call_handler, + doc + ); + + mm[std::string( name )] = method_definition; + } + + private: + static method_map_t &methods(void) + { + static method_map_t *map_of_methods = NULL; + if( map_of_methods == NULL ) + map_of_methods = new method_map_t; + + return *map_of_methods; + } + + static PyObject *method_keyword_call_handler( PyObject *_self_and_name_tuple, PyObject *_args, PyObject *_keywords ) + { + try + { + Tuple self_and_name_tuple( _self_and_name_tuple ); + + PyObject *self_in_cobject = self_and_name_tuple[0].ptr(); + T *self = static_cast<T *>( self_in_cobject ); + + String name( self_and_name_tuple[1] ); + + method_map_t &mm = methods(); + MethodDefExt<T> *meth_def = mm[ name ]; + if( meth_def == NULL ) + return 0; + + Tuple args( _args ); + + // _keywords may be NULL so be careful about the way the dict is created + Dict keywords; + if( _keywords != NULL ) + keywords = Dict( _keywords ); + + Object result( (self->*meth_def->ext_keyword_function)( args, keywords ) ); + + return new_reference_to( result.ptr() ); + } + catch( Exception & ) + { + return 0; + } + } + + static PyObject *method_varargs_call_handler( PyObject *_self_and_name_tuple, PyObject *_args ) + { + try + { + Tuple self_and_name_tuple( _self_and_name_tuple ); + + PyObject *self_in_cobject = self_and_name_tuple[0].ptr(); + T *self = static_cast<T *>( self_in_cobject ); + + String name( self_and_name_tuple[1] ); + + method_map_t &mm = methods(); + MethodDefExt<T> *meth_def = mm[ name ]; + if( meth_def == NULL ) + return 0; + + Tuple args( _args ); + + Object result; + + ... [truncated message content] |
From: <md...@us...> - 2007-08-23 17:59:23
|
Revision: 3733 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3733&view=rev Author: mdboom Date: 2007-08-23 10:59:21 -0700 (Thu, 23 Aug 2007) Log Message: ----------- Extremely minor bugfix that prevents the cycle finder from printing out dictionaries. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/cbook.py Modified: trunk/matplotlib/lib/matplotlib/cbook.py =================================================================== --- trunk/matplotlib/lib/matplotlib/cbook.py 2007-08-23 17:58:49 UTC (rev 3732) +++ trunk/matplotlib/lib/matplotlib/cbook.py 2007-08-23 17:59:21 UTC (rev 3733) @@ -936,7 +936,7 @@ recurse(referent, start, all, current_path + [obj]) for obj in objects: - outstream.write("Examining: %r\n" % obj) + outstream.write("Examining: %r\n" % (obj,)) recurse(obj, obj, { }, []) if __name__=='__main__': This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-08-23 17:58:51
|
Revision: 3732 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3732&view=rev Author: mdboom Date: 2007-08-23 10:58:49 -0700 (Thu, 23 Aug 2007) Log Message: ----------- Fix \sqrt (broken when I made the parser more strict). Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/_mathtext_data.py trunk/matplotlib/lib/matplotlib/mathtext.py Modified: trunk/matplotlib/lib/matplotlib/_mathtext_data.py =================================================================== --- trunk/matplotlib/lib/matplotlib/_mathtext_data.py 2007-08-23 06:58:10 UTC (rev 3731) +++ trunk/matplotlib/lib/matplotlib/_mathtext_data.py 2007-08-23 17:58:49 UTC (rev 3732) @@ -30,6 +30,7 @@ r'\bigwedge' : ('cmex10', 4), r'\bigvee' : ('cmex10', 37), r'\coprod' : ('cmex10', 42), + r'\__sqrt__' : ('cmex10', 48), r'\leftbrace' : ('cmex10', 92), r'{' : ('cmex10', 92), r'\{' : ('cmex10', 92), @@ -316,6 +317,7 @@ r'\Pi' : ('psyr', 213), r'\prod' : ('psyr', 213), r'\surd' : ('psyr', 214), + r'\__sqrt__' : ('psyr', 214), r'\cdot' : ('psyr', 215), r'\urcorner' : ('psyr', 216), r'\vee' : ('psyr', 217), @@ -2044,6 +2046,7 @@ 'rightzigzagarrow': 8669, 'rightarrow': 8594, 'leftarrow': 8592, +'__sqrt__': 8730, 'twoheaddownarrow': 8609, 'oint': 8750, 'bigvee': 8897, @@ -2553,6 +2556,7 @@ 'rightzigzagarrow': 'uni21DD', 'rightarrow': 'uni2192', 'leftarrow': 'uni2190', +'__sqrt__': 'uni221A', 'twoheaddownarrow': 'uni21A1', 'oint': 'uni222E', 'bigvee': 'uni22C1', Modified: trunk/matplotlib/lib/matplotlib/mathtext.py =================================================================== --- trunk/matplotlib/lib/matplotlib/mathtext.py 2007-08-23 06:58:10 UTC (rev 3731) +++ trunk/matplotlib/lib/matplotlib/mathtext.py 2007-08-23 17:58:49 UTC (rev 3732) @@ -645,7 +645,7 @@ ('ex', '\xbf'), ('ex', '\x2a')], r'\rangle' : [('cal', '\x69'), ('ex', '\xae'), ('ex', '\x45'), ('ex', '\xc0'), ('ex', '\x2b')], - r'\sqrt' : [('cal', '\x70'), ('ex', '\x70'), ('ex', '\x71'), + r'\__sqrt__' : [('cal', '\x70'), ('ex', '\x70'), ('ex', '\x71'), ('ex', '\x72'), ('ex', '\x73')], r'\backslash': [('cal', '\x6e'), ('ex', '\xb2'), ('ex', '\x2f'), ('ex', '\xc2'), ('ex', '\x2d')], @@ -2296,7 +2296,7 @@ # the height so it doesn't seem cramped height = body.height - body.shift_amount + thickness * 5.0 depth = body.depth + body.shift_amount - check = AutoHeightChar(r'\sqrt', height, depth, state, always=True) + check = AutoHeightChar(r'\__sqrt__', height, depth, state, always=True) height = check.height - check.shift_amount depth = check.depth + check.shift_amount This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2007-08-23 06:58:13
|
Revision: 3731 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3731&view=rev Author: jouni Date: 2007-08-22 23:58:10 -0700 (Wed, 22 Aug 2007) Log Message: ----------- Fix a buglet affecting getp: if a numpy object has shape==(), you cannot take its length. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/artist.py Modified: trunk/matplotlib/lib/matplotlib/artist.py =================================================================== --- trunk/matplotlib/lib/matplotlib/artist.py 2007-08-22 20:11:18 UTC (rev 3730) +++ trunk/matplotlib/lib/matplotlib/artist.py 2007-08-23 06:58:10 UTC (rev 3731) @@ -588,7 +588,7 @@ if self.is_alias(func): continue try: val = func() except: continue - if hasattr(val, 'shape') and len(val)>6: + if getattr(val, 'shape', ()) != () and len(val)>6: s = str(val[:6]) + '...' else: s = str(val) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ds...@us...> - 2007-08-22 20:11:20
|
Revision: 3730 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3730&view=rev Author: dsdale Date: 2007-08-22 13:11:18 -0700 (Wed, 22 Aug 2007) Log Message: ----------- rcdefaults working with mplconfig Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/config/mplconfig.py Modified: trunk/matplotlib/lib/matplotlib/config/mplconfig.py =================================================================== --- trunk/matplotlib/lib/matplotlib/config/mplconfig.py 2007-08-22 19:38:08 UTC (rev 3729) +++ trunk/matplotlib/lib/matplotlib/config/mplconfig.py 2007-08-22 20:11:18 UTC (rev 3730) @@ -516,10 +516,14 @@ config_file) def rcdefaults(): - global mplConfig - mplConfig = MPLConfig() - rcParams.update(rcParamsDefault) + """ + Restore the default rc params - the ones that were created at + matplotlib load time + """ + for key in rcParamsDefault.keys(): + rcParams[key] = rcParamsDefault[key] + ############################################################################## # Auto-generate the mpl-data/matplotlib.conf ############################################################################## This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-08-22 19:38:18
|
Revision: 3729 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3729&view=rev Author: mdboom Date: 2007-08-22 12:38:08 -0700 (Wed, 22 Aug 2007) Log Message: ----------- Make rcParams.update(rcParamsDefault) when new traited config is switched on. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/config/mplconfig.py trunk/matplotlib/lib/matplotlib/config/mpltraits.py trunk/matplotlib/lib/matplotlib/rcsetup.py Modified: trunk/matplotlib/lib/matplotlib/config/mplconfig.py =================================================================== --- trunk/matplotlib/lib/matplotlib/config/mplconfig.py 2007-08-22 18:43:13 UTC (rev 3728) +++ trunk/matplotlib/lib/matplotlib/config/mplconfig.py 2007-08-22 19:38:08 UTC (rev 3729) @@ -161,12 +161,14 @@ dvipnghack = T.false class mathtext(TConfig): - cal = T.Trait("['cursive']", mplT.FontPropertiesHandler()) - rm = T.Trait("['serif']", mplT.FontPropertiesHandler()) - tt = T.Trait("['monospace']", mplT.FontPropertiesHandler()) - it = T.Trait("['serif'], style='oblique'", mplT.FontPropertiesHandler()) - bf = T.Trait("['serif'], weight='bold'", mplT.FontPropertiesHandler()) - sf = T.Trait("['sans-serif']", mplT.FontPropertiesHandler()) + handler = mplT.FontPropertiesHandler + proxy = handler.FontPropertiesProxy + cal = T.Trait(proxy(['cursive']), handler()) + rm = T.Trait(proxy(['serif']), handler()) + tt = T.Trait(proxy(['monospace']), handler()) + it = T.Trait(proxy(['serif'], style='oblique'), handler()) + bf = T.Trait(proxy(['serif'], weight='bold'), handler()) + sf = T.Trait(proxy(['sans-serif']), handler()) use_cm = T.true fallback_to_cm = T.true Modified: trunk/matplotlib/lib/matplotlib/config/mpltraits.py =================================================================== --- trunk/matplotlib/lib/matplotlib/config/mpltraits.py 2007-08-22 18:43:13 UTC (rev 3728) +++ trunk/matplotlib/lib/matplotlib/config/mpltraits.py 2007-08-22 19:38:08 UTC (rev 3729) @@ -146,7 +146,7 @@ 'spring_r', 'summer', 'summer_r', 'winter', 'winter_r'] class FontPropertiesHandler(T.TraitHandler): - class FontPropertiesProxy: + class FontPropertiesProxy(object): # In order to build a FontProperties object, various rcParams must # already be known in order to set default values. That means a # FontProperties object can not be created from a config file, @@ -192,8 +192,6 @@ def validate(self, object, name, value): from matplotlib.font_manager import FontProperties - if isinstance(value, FontProperties): - return value if is_string_like(value): try: proxy = eval("FontProperties(%s)" % value, @@ -202,7 +200,9 @@ pass else: return proxy + else: + return value self.error(object, name, value) def info(self): - return 'Represents a set of font properties. Must be a FontProperties object or a string containing the parameters to the FontProperties constructor.' + return 'a FontProperties object or a string containing the parameters to the FontProperties constructor.' Modified: trunk/matplotlib/lib/matplotlib/rcsetup.py =================================================================== --- trunk/matplotlib/lib/matplotlib/rcsetup.py 2007-08-22 18:43:13 UTC (rev 3728) +++ trunk/matplotlib/lib/matplotlib/rcsetup.py 2007-08-22 19:38:08 UTC (rev 3729) @@ -198,7 +198,7 @@ except ValueError: raise ValueError('not a valid font size') -class FontPropertiesProxy: +class FontPropertiesProxy(object): # In order to build a FontProperties object, various rcParams must # already be known in order to set default values. That means a # FontProperties object can not be created from a config file, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ds...@us...> - 2007-08-22 18:43:30
|
Revision: 3728 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3728&view=rev Author: dsdale Date: 2007-08-22 11:43:13 -0700 (Wed, 22 Aug 2007) Log Message: ----------- add an update method to rcParamsWrapper Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/config/mplconfig.py Modified: trunk/matplotlib/lib/matplotlib/config/mplconfig.py =================================================================== --- trunk/matplotlib/lib/matplotlib/config/mplconfig.py 2007-08-21 19:42:28 UTC (rev 3727) +++ trunk/matplotlib/lib/matplotlib/config/mplconfig.py 2007-08-22 18:43:13 UTC (rev 3728) @@ -461,7 +461,18 @@ def has_key(self, val): return self.tconfig_map.has_key(val) + def update(self, arg, **kwargs): + try: + for key in arg: + self[key] = arg[key] + except AttributeError: + for key, val in arg: + self[key] = val + + for key in kwargs: + self[key] = kwargs[key] + old_config_file = cutils.get_config_file(tconfig=False) old_config_path = os.path.split(old_config_file)[0] config_file = os.path.join(old_config_path, 'matplotlib.conf') @@ -503,8 +514,9 @@ config_file) def rcdefaults(): + global mplConfig mplConfig = MPLConfig() - rcParams = RcParamsWrapper(mplConfig) + rcParams.update(rcParamsDefault) ############################################################################## # Auto-generate the mpl-data/matplotlib.conf This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2007-08-21 19:42:37
|
Revision: 3727 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3727&view=rev Author: jouni Date: 2007-08-21 12:42:28 -0700 (Tue, 21 Aug 2007) Log Message: ----------- Run a simple sanity check to avoid attempting to parse non-AFM files as AFM. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/afm.py Modified: trunk/matplotlib/lib/matplotlib/afm.py =================================================================== --- trunk/matplotlib/lib/matplotlib/afm.py 2007-08-21 19:10:02 UTC (rev 3726) +++ trunk/matplotlib/lib/matplotlib/afm.py 2007-08-21 19:42:28 UTC (rev 3727) @@ -53,7 +53,27 @@ else: return True +def _sanity_check(fh): + """ + Check if the file at least looks like AFM. + If not, raise RuntimeError. + """ + # Remember the file position in case the caller wants to + # do something else with the file. + pos = fh.tell() + try: + line = fh.readline() + finally: + fh.seek(pos, 0) + + # AFM spec, Section 4: The StartFontMetrics keyword [followed by a + # version number] must be the first line in the file, and the + # EndFontMetrics keyword must be the last non-empty line in the + # file. We just check the first line. + if not line.startswith('StartFontMetrics'): + raise RuntimeError('Not an AFM file') + def _parse_header(fh): """ Reads the font metrics header (up to the char metrics) and returns @@ -255,6 +275,7 @@ dkernpairs : a parse_kern_pairs dict, possibly {} dcomposite : a parse_composites dict , possibly {} """ + _sanity_check(fh) dhead = _parse_header(fh) dcmetrics = _parse_char_metrics(fh) doptional = _parse_optional(fh) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-08-21 19:10:09
|
Revision: 3726 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3726&view=rev Author: mdboom Date: 2007-08-21 12:10:02 -0700 (Tue, 21 Aug 2007) Log Message: ----------- Fix message about wxAgg version requirement. Modified Paths: -------------- trunk/matplotlib/setup.py Modified: trunk/matplotlib/setup.py =================================================================== --- trunk/matplotlib/setup.py 2007-08-21 19:08:55 UTC (rev 3725) +++ trunk/matplotlib/setup.py 2007-08-21 19:10:02 UTC (rev 3726) @@ -241,7 +241,7 @@ build_wxagg(ext_modules, packages) wxagg_backend_status = "yes" else: - print_message("WxAgg extension not required for wxPython < 2.8") + print_message("WxAgg extension not required for wxPython >= 2.8") rc['backend'] = 'WXAgg' # These are informational only. We don't build This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-08-21 19:08:59
|
Revision: 3725 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3725&view=rev Author: mdboom Date: 2007-08-21 12:08:55 -0700 (Tue, 21 Aug 2007) Log Message: ----------- Fix the parser so it doesn't silently fail. Speed up by using pyparsing's packrat feature. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/_mathtext_data.py trunk/matplotlib/lib/matplotlib/mathtext.py Modified: trunk/matplotlib/lib/matplotlib/_mathtext_data.py =================================================================== --- trunk/matplotlib/lib/matplotlib/_mathtext_data.py 2007-08-21 17:25:57 UTC (rev 3724) +++ trunk/matplotlib/lib/matplotlib/_mathtext_data.py 2007-08-21 19:08:55 UTC (rev 3725) @@ -30,7 +30,6 @@ r'\bigwedge' : ('cmex10', 4), r'\bigvee' : ('cmex10', 37), r'\coprod' : ('cmex10', 42), - r'\sqrt' : ('cmex10', 48), r'\leftbrace' : ('cmex10', 92), r'{' : ('cmex10', 92), r'\{' : ('cmex10', 92), @@ -317,7 +316,6 @@ r'\Pi' : ('psyr', 213), r'\prod' : ('psyr', 213), r'\surd' : ('psyr', 214), - r'\sqrt' : ('psyr', 214), r'\cdot' : ('psyr', 215), r'\urcorner' : ('psyr', 216), r'\vee' : ('psyr', 217), @@ -2046,7 +2044,6 @@ 'rightzigzagarrow': 8669, 'rightarrow': 8594, 'leftarrow': 8592, -'sqrt': 8730, 'twoheaddownarrow': 8609, 'oint': 8750, 'bigvee': 8897, @@ -2556,7 +2553,6 @@ 'rightzigzagarrow': 'uni21DD', 'rightarrow': 'uni2192', 'leftarrow': 'uni2190', -'sqrt': 'uni221A', 'twoheaddownarrow': 'uni21A1', 'oint': 'uni222E', 'bigvee': 'uni22C1', Modified: trunk/matplotlib/lib/matplotlib/mathtext.py =================================================================== --- trunk/matplotlib/lib/matplotlib/mathtext.py 2007-08-21 17:25:57 UTC (rev 3724) +++ trunk/matplotlib/lib/matplotlib/mathtext.py 2007-08-21 19:08:55 UTC (rev 3725) @@ -143,7 +143,7 @@ Combine, Group, Optional, Forward, NotAny, alphas, nums, alphanums, \ StringStart, StringEnd, ParseFatalException, FollowedBy, Regex, \ operatorPrecedence, opAssoc, ParseResults, Or, Suppress, oneOf, \ - ParseException, MatchFirst + ParseException, MatchFirst, NoMatch from matplotlib.afm import AFM from matplotlib.cbook import enumerate, iterable, Bunch, get_realpath_and_stat, \ @@ -1806,12 +1806,12 @@ + rbrace ).setParseAction(self.customspace).setName('customspace') - symbol =(Regex(r"[a-zA-Z0-9 +\-*/<>=:,.;!'@()[\]]") - ^ Combine( - bslash - + oneOf(tex2uni.keys()) - ) - ).setParseAction(self.symbol).leaveWhitespace() + symbol =(Regex(r"([a-zA-Z0-9 +\-*/<>=:,.;!'@()])|(\\[%${}\[\]])") + | Combine( + bslash + + oneOf(tex2uni.keys()) + ) + ).setParseAction(self.symbol).leaveWhitespace() accent = Group( Combine(bslash + accent) @@ -1823,7 +1823,7 @@ group = Group( start_group - + OneOrMore( + + ZeroOrMore( autoDelim | simple) + end_group @@ -1907,7 +1907,7 @@ math = OneOrMore( autoDelim - | simple + ^ simple ).setParseAction(self.math).setName("math") math_delim =(~bslash @@ -1916,16 +1916,18 @@ non_math = Regex(r"(?:[^$]|(?:\\\$))*" ).setParseAction(self.non_math).setName("non_math").leaveWhitespace() - self._expression <<( - non_math - + ZeroOrMore( - Suppress(math_delim) - + math - + Suppress(math_delim) - + non_math - ) - ) + self._expression << ( + non_math + + ZeroOrMore( + Suppress(math_delim) + + math + + Suppress(math_delim) + + non_math + ) + ) + StringEnd() + self._expression.enablePackrat() + self.clear() def clear(self): @@ -1966,6 +1968,7 @@ self._state_stack.append(self.get_state().copy()) def finish(self, s, loc, toks): + #~ print "finish", toks self._expr = Hlist(toks) return [self._expr] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-08-21 17:26:00
|
Revision: 3724 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3724&view=rev Author: mdboom Date: 2007-08-21 10:25:57 -0700 (Tue, 21 Aug 2007) Log Message: ----------- Making parser more robust -- will only accept valid symbol names. (Re-)adding \hspace{ } command. Modified Paths: -------------- trunk/matplotlib/examples/mathtext_examples.py trunk/matplotlib/lib/matplotlib/_mathtext_data.py trunk/matplotlib/lib/matplotlib/mathtext.py Modified: trunk/matplotlib/examples/mathtext_examples.py =================================================================== --- trunk/matplotlib/examples/mathtext_examples.py 2007-08-21 15:24:26 UTC (rev 3723) +++ trunk/matplotlib/examples/mathtext_examples.py 2007-08-21 17:25:57 UTC (rev 3724) @@ -9,7 +9,7 @@ r'$100\%y\ x*y\ x/y x\$y$', r'$x\leftarrow y\ x\forall y\ x-y$', r'$x \sf x \bf x {\cal X} \rm x$', - r'$x\ x\,x\;x\quad x\qquad x\!x$', + r'$x\ x\,x\;x\quad x\qquad x\!x\hspace{0.5}y$', r'$\{ \rm braces \}$', r'$\left[\left\lfloor\frac{5}{\frac{\left(3\right)}{4}} y\right)\right]$', r'$\left(x\right)$', Modified: trunk/matplotlib/lib/matplotlib/_mathtext_data.py =================================================================== --- trunk/matplotlib/lib/matplotlib/_mathtext_data.py 2007-08-21 15:24:26 UTC (rev 3723) +++ trunk/matplotlib/lib/matplotlib/_mathtext_data.py 2007-08-21 17:25:57 UTC (rev 3724) @@ -1763,7 +1763,6 @@ 'Theta': 920, 'origof': 8886, 'blacksquare': 9632, -'hspace': 8202, 'solbar': 9023, 'neg': 172, 'sum': 8721, Modified: trunk/matplotlib/lib/matplotlib/mathtext.py =================================================================== --- trunk/matplotlib/lib/matplotlib/mathtext.py 2007-08-21 15:24:26 UTC (rev 3723) +++ trunk/matplotlib/lib/matplotlib/mathtext.py 2007-08-21 17:25:57 UTC (rev 3724) @@ -1750,12 +1750,10 @@ _overunder_symbols = Set(r''' \sum \prod \coprod \bigcap \bigcup \bigsqcup \bigvee \bigwedge \bigodot \bigotimes \bigoplus \biguplus - '''.split() - ) + '''.split()) _overunder_functions = Set( - r"lim liminf limsup sup max min".split() - ) + r"lim liminf limsup sup max min".split()) _dropsub_symbols = Set(r'''\int \oint'''.split()) @@ -1769,11 +1767,13 @@ autoDelim = Forward().setParseAction(self.auto_sized_delimiter) self._expression = Forward().setParseAction(self.finish).setName("finish") + float = Regex(r"-?[0-9]+\.?[0-9]*") + lbrace = Literal('{').suppress() rbrace = Literal('}').suppress() start_group = (Optional(latexfont) + lbrace) start_group.setParseAction(self.start_group) - end_group = rbrace + end_group = rbrace.copy() end_group.setParseAction(self.end_group) bslash = Literal('\\') @@ -1786,15 +1786,9 @@ "cosh gcd ln sup cot hom log tan coth inf max " "tanh") - number = Combine(Word(nums) + Optional(Literal('.')) + Optional( Word(nums) )) - fontname = oneOf("rm cal it tt sf bf") latex2efont = oneOf("mathrm mathcal mathit mathtt mathsf mathbf") - texsym = Combine(bslash + Word(alphanums) + NotAny("{")) - - char = Word(alphanums + ' ', exact=1).leaveWhitespace() - space =(FollowedBy(bslash) + (Literal(r'\ ') | Literal(r'\/') @@ -1806,19 +1800,18 @@ ) ).setParseAction(self.space).setName('space') - symbol = Regex("(" + ")|(".join( - [ - r"\\(?!quad)(?!qquad)(?!left[^a-z])(?!right[^a-z])[a-zA-Z0-9]+(?!{)", - r"[a-zA-Z0-9 ]", - r"[+\-*/]", - r"[<>=]", - r"[:,.;!'@[()]", - r"\\[$%{}]", - ]) - + ")" - ).setParseAction(self.symbol).leaveWhitespace() + customspace =(Literal(r'\hspace') + + lbrace + + float + + rbrace + ).setParseAction(self.customspace).setName('customspace') - rightBracket = Literal("[").setParseAction(self.symbol).leaveWhitespace() + symbol =(Regex(r"[a-zA-Z0-9 +\-*/<>=:,.;!'@()[\]]") + ^ Combine( + bslash + + oneOf(tex2uni.keys()) + ) + ).setParseAction(self.symbol).leaveWhitespace() accent = Group( Combine(bslash + accent) @@ -1873,13 +1866,13 @@ placeable <<(accent ^ function ^ symbol - ^ rightBracket ^ group ^ frac ^ sqrt ) simple <<(space + | customspace | font | subsuper ) @@ -2016,6 +2009,9 @@ box = self._make_space(num) return [box] + def customspace(self, s, loc, toks): + return [self._make_space(float(toks[1]))] + def symbol(self, s, loc, toks): # print "symbol", toks c = toks[0] @@ -2226,7 +2222,8 @@ y = Hlist([sub]) # y.width += SCRIPT_SPACE * xHeight shift_down = max(shift_down, SUB1 * xHeight) - clr = 2.0 * rule_thickness - ((shift_up - x.depth) - (y.height - shift_down)) + clr = (2.0 * rule_thickness - + ((shift_up - x.depth) - (y.height - shift_down))) if clr > 0.: shift_up += clr shift_down += clr This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-08-21 15:25:30
|
Revision: 3723 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3723&view=rev Author: mdboom Date: 2007-08-21 08:24:26 -0700 (Tue, 21 Aug 2007) Log Message: ----------- Fix docstring Modified Paths: -------------- trunk/matplotlib/src/_ttconv.cpp Modified: trunk/matplotlib/src/_ttconv.cpp =================================================================== --- trunk/matplotlib/src/_ttconv.cpp 2007-08-21 15:19:04 UTC (rev 3722) +++ trunk/matplotlib/src/_ttconv.cpp 2007-08-21 15:24:26 UTC (rev 3723) @@ -195,12 +195,12 @@ "get_pdf_charprocs(filename, glyph_ids)\n" "\n" "Given a Truetype font file, returns a dictionary containing the PDF Type 3\n" - "representation of its path. Useful for subsetting a Truetype font inside\n" + "representation of its paths. Useful for subsetting a Truetype font inside\n" "of a PDF file.\n" "\n" "filename is the path to a TTF font file.\n" "glyph_ids is a list of the numeric glyph ids to include.\n" - "The return value is a dictionary where the keys are glyph names and \n" + "The return value is a dictionary where the keys are glyph names and\n" "the values are the stream content needed to render that glyph. This\n" "is useful to generate the CharProcs dictionary in a PDF Type 3 font.\n" }, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-08-21 15:19:33
|
Revision: 3722 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3722&view=rev Author: mdboom Date: 2007-08-21 08:19:04 -0700 (Tue, 21 Aug 2007) Log Message: ----------- Prevent the mathtext cache from getting out of hand, by clearing it after every plot. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_agg.py trunk/matplotlib/lib/matplotlib/backends/backend_agg2.py trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py trunk/matplotlib/lib/matplotlib/backends/backend_gdk.py trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py trunk/matplotlib/lib/matplotlib/backends/backend_ps.py trunk/matplotlib/lib/matplotlib/backends/backend_qt.py trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py trunk/matplotlib/lib/matplotlib/backends/backend_svg.py trunk/matplotlib/lib/matplotlib/mathtext.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_agg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_agg.py 2007-08-21 15:13:49 UTC (rev 3721) +++ trunk/matplotlib/lib/matplotlib/backends/backend_agg.py 2007-08-21 15:19:04 UTC (rev 3722) @@ -83,7 +83,7 @@ from matplotlib.figure import Figure from matplotlib.font_manager import findfont from matplotlib.ft2font import FT2Font, LOAD_DEFAULT -from matplotlib.mathtext import math_parse_s_ft2font +from matplotlib.mathtext import MathTextParser from matplotlib.transforms import lbwh_to_bbox from _backend_agg import RendererAgg as _RendererAgg @@ -125,8 +125,8 @@ self.copy_from_bbox = self._renderer.copy_from_bbox self.restore_region = self._renderer.restore_region + self.mathtext_parser = MathTextParser('Agg') - self.bbox = lbwh_to_bbox(0,0, self.width, self.height) if __debug__: verbose.report('RendererAgg.__init__ done', 'debug-annoying') @@ -173,7 +173,7 @@ """ if __debug__: verbose.report('RendererAgg.draw_mathtext', 'debug-annoying') - width, height, fonts, used_characters = math_parse_s_ft2font( + width, height, fonts, used_characters = self.mathtext_parser.parse( s, self.dpi.get(), prop) if angle == 90: @@ -230,7 +230,7 @@ return n,m if ismath: - width, height, fonts, used_characters = math_parse_s_ft2font( + width, height, fonts, used_characters = self.mathtext_parser.parse( s, self.dpi.get(), prop) return width, height font = self._get_agg_font(prop) Modified: trunk/matplotlib/lib/matplotlib/backends/backend_agg2.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_agg2.py 2007-08-21 15:13:49 UTC (rev 3721) +++ trunk/matplotlib/lib/matplotlib/backends/backend_agg2.py 2007-08-21 15:19:04 UTC (rev 3722) @@ -16,7 +16,7 @@ from matplotlib.cbook import enumerate, is_string_like, exception_to_str from matplotlib.figure import Figure from matplotlib.ft2font import FT2Font -from matplotlib.mathtext import math_parse_s_ft2font +from matplotlib.mathtext import MathTextParser from _backend_agg import RendererAgg as _RendererAgg Modified: trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py 2007-08-21 15:13:49 UTC (rev 3721) +++ trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py 2007-08-21 15:19:04 UTC (rev 3722) @@ -38,7 +38,7 @@ FigureManagerBase, FigureCanvasBase from matplotlib.cbook import enumerate, izip from matplotlib.figure import Figure -from matplotlib.mathtext import math_parse_s_cairo +from matplotlib.mathtext import MathTextParser from matplotlib.transforms import Bbox from matplotlib.font_manager import ttfFontProperty from matplotlib import rcParams @@ -92,8 +92,8 @@ self.dpi = dpi self.text_ctx = cairo.Context ( cairo.ImageSurface (cairo.FORMAT_ARGB32,1,1)) + self.mathtext_parser = MathTextParser('Cairo') - def set_ctx_from_surface (self, surface): self.ctx = cairo.Context (surface) self.ctx.save() # restore, save - when call new_gc() @@ -304,7 +304,7 @@ if _debug: print '%s.%s()' % (self.__class__.__name__, _fn_name()) ctx = gc.ctx - width, height, glyphs, rects = math_parse_s_cairo( + width, height, glyphs, rects = self.mathtext_parser.parse( s, self.dpi.get(), prop) ctx.save() @@ -352,7 +352,7 @@ def get_text_width_height(self, s, prop, ismath): if _debug: print '%s.%s()' % (self.__class__.__name__, _fn_name()) if ismath: - width, height, fonts, used_characters = math_parse_s_cairo( + width, height, fonts, used_characters = self.mathtext_parser.parse( s, self.dpi.get(), prop) return width, height Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gdk.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_gdk.py 2007-08-21 15:13:49 UTC (rev 3721) +++ trunk/matplotlib/lib/matplotlib/backends/backend_gdk.py 2007-08-21 15:19:04 UTC (rev 3722) @@ -24,7 +24,7 @@ FigureManagerBase, FigureCanvasBase from matplotlib.cbook import is_string_like, enumerate from matplotlib.figure import Figure -from matplotlib.mathtext import math_parse_s_ft2font +from matplotlib.mathtext import MathTextParser from matplotlib.backends._backend_gdk import pixbuf_get_pixels_array @@ -71,6 +71,7 @@ self.gtkDA = gtkDA self.dpi = dpi self._cmap = gtkDA.get_colormap() + self.mathtext_parser = MathTextParser("Agg") def set_pixmap (self, pixmap): self.gdkDrawable = pixmap @@ -198,7 +199,7 @@ def _draw_mathtext(self, gc, x, y, s, prop, angle): - width, height, fonts, used_characters = math_parse_s_ft2font( + width, height, fonts, used_characters = self.mathtext_parser.parse( s, self.dpi.get(), prop) if angle==90: @@ -341,7 +342,7 @@ def get_text_width_height(self, s, prop, ismath): if ismath: - width, height, fonts, used_characters = math_parse_s_ft2font( + width, height, fonts, used_characters = self.mathtext_parser.parse( s, self.dpi.get(), prop) return width, height Modified: trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2007-08-21 15:13:49 UTC (rev 3721) +++ trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2007-08-21 15:19:04 UTC (rev 3722) @@ -29,7 +29,7 @@ from matplotlib.dviread import Dvi from matplotlib.ft2font import FT2Font, FIXED_WIDTH, ITALIC, LOAD_NO_SCALE, \ LOAD_NO_HINTING, KERNING_UNFITTED -from matplotlib.mathtext import math_parse_s_pdf +from matplotlib.mathtext import MathTextParser from matplotlib.transforms import Bbox from matplotlib import ttconv @@ -1032,6 +1032,7 @@ self.encode_string = self.encode_string_type3 else: self.encode_string = self.encode_string_type42 + self.mathtext_parser = MathTextParser("Pdf") def finalize(self): self.gc.finalize() @@ -1219,7 +1220,7 @@ def draw_mathtext(self, gc, x, y, s, prop, angle): # TODO: fix positioning and encoding width, height, glyphs, rects, used_characters = \ - math_parse_s_pdf(s, 72, prop) + self.mathtext_parser.parse(s, 72, prop) self.merge_used_characters(used_characters) # When using Type 3 fonts, we can't use character codes higher @@ -1466,7 +1467,7 @@ if ismath: w, h, glyphs, rects, used_characters = \ - math_parse_s_pdf(s, 72, prop) + self.mathtext_parser.parse(s, 72, prop) elif rcParams['pdf.use14corefonts']: font = self._get_font_afm(prop) Modified: trunk/matplotlib/lib/matplotlib/backends/backend_ps.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2007-08-21 15:13:49 UTC (rev 3721) +++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2007-08-21 15:19:04 UTC (rev 3722) @@ -21,7 +21,7 @@ from matplotlib.font_manager import findfont from matplotlib.ft2font import FT2Font, KERNING_DEFAULT, LOAD_NO_HINTING from matplotlib.ttconv import convert_ttf_to_ps -from matplotlib.mathtext import math_parse_s_ps +from matplotlib.mathtext import MathTextParser from matplotlib.text import Text from matplotlib.transforms import get_vec6_scales @@ -144,6 +144,7 @@ self.fontd = {} self.afmfontd = {} self.used_characters = {} + self.mathtext_parser = MathTextParser("PS") def track_characters(self, font, s): """Keeps track of which characters are required from @@ -277,8 +278,8 @@ return w, h if ismath: - width, height, pswriter, used_characters = math_parse_s_ps( - s, 72, prop) + width, height, pswriter, used_characters = \ + self.mathtext_parser.parse(s, 72, prop) return width, height if rcParams['ps.useafm']: @@ -814,7 +815,7 @@ self._pswriter.write("% mathtext\n") width, height, pswriter, used_characters = \ - math_parse_s_ps(s, 72, prop) + self.mathtext_parser.parse(s, 72, prop) self.merge_used_characters(used_characters) self.set_color(*gc.get_rgb()) thetext = pswriter.getvalue() Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_qt.py 2007-08-21 15:13:49 UTC (rev 3721) +++ trunk/matplotlib/lib/matplotlib/backends/backend_qt.py 2007-08-21 15:19:04 UTC (rev 3722) @@ -10,7 +10,7 @@ FigureManagerBase, FigureCanvasBase, NavigationToolbar2, cursors from matplotlib._pylab_helpers import Gcf from matplotlib.figure import Figure -from matplotlib.mathtext import math_parse_s_ft2font +from matplotlib.mathtext import MathTextParser from matplotlib.widgets import SubplotTool import qt Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2007-08-21 15:13:49 UTC (rev 3721) +++ trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2007-08-21 15:19:04 UTC (rev 3722) @@ -10,7 +10,7 @@ FigureManagerBase, FigureCanvasBase, NavigationToolbar2, cursors from matplotlib._pylab_helpers import Gcf from matplotlib.figure import Figure -from matplotlib.mathtext import math_parse_s_ft2font +from matplotlib.mathtext import MathTextParser from matplotlib.widgets import SubplotTool from PyQt4 import QtCore, QtGui Modified: trunk/matplotlib/lib/matplotlib/backends/backend_svg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2007-08-21 15:13:49 UTC (rev 3721) +++ trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2007-08-21 15:19:04 UTC (rev 3722) @@ -9,7 +9,7 @@ from matplotlib.figure import Figure from matplotlib.font_manager import findfont, FontProperties from matplotlib.ft2font import FT2Font, KERNING_DEFAULT, LOAD_NO_HINTING -from matplotlib.mathtext import math_parse_s_ft2font_svg +from matplotlib.mathtext import MathTextParser from xml.sax.saxutils import escape as escape_xml_text @@ -40,6 +40,7 @@ self._imaged = {} self._clipd = {} self._char_defs = {} + self.mathtext_parser = MathTextParser('SVG') svgwriter.write(svgProlog%(width,height,width,height)) def _draw_svg_element(self, element, details, gc, rgbFace): @@ -338,7 +339,7 @@ Draw math text using matplotlib.mathtext """ width, height, svg_elements, used_characters = \ - math_parse_s_ft2font_svg(s, 72, prop) + self.mathtext_parser.parse(s, 72, prop) svg_glyphs = svg_elements.svg_glyphs svg_rects = svg_elements.svg_rects color = rgb2hex(gc.get_rgb()) @@ -428,7 +429,7 @@ def get_text_width_height(self, s, prop, ismath): if ismath: width, height, trash, used_characters = \ - math_parse_s_ft2font_svg(s, 72, prop) + self.mathtext_parser.parse(s, 72, prop) return width, height font = self._get_font(prop) font.set_text(s, 0.0, flags=LOAD_NO_HINTING) Modified: trunk/matplotlib/lib/matplotlib/mathtext.py =================================================================== --- trunk/matplotlib/lib/matplotlib/mathtext.py 2007-08-21 15:13:49 UTC (rev 3721) +++ trunk/matplotlib/lib/matplotlib/mathtext.py 2007-08-21 15:19:04 UTC (rev 3722) @@ -532,7 +532,7 @@ slanted = slanted ) - self.glyphd[key] = Bunch( + result = self.glyphd[key] = Bunch( font = font, fontsize = fontsize, postscript_name = font.postscript_name, @@ -542,7 +542,7 @@ glyph = glyph, offset = offset ) - return self.glyphd[key] + return result def get_xheight(self, font, fontsize, dpi): cached_font = self._get_font(font) @@ -2343,7 +2343,7 @@ ############################################################################## # MAIN -class math_parse_s_ft2font_common: +class MathTextParser: """ Parse the math expression s, return the (bbox, fonts) tuple needed to render it. @@ -2352,40 +2352,38 @@ return is width, height, fonts """ - major, minor1, minor2, tmp, tmp = sys.version_info - if major==2 and minor1==2: - raise SystemExit('mathtext broken on python2.2. We hope to get this fixed soon') - _parser = None - + _backend_mapping = { 'Agg' : MathtextBackendAgg, 'PS' : MathtextBackendPs, - 'PDF' : MathtextBackendPdf, + 'Pdf' : MathtextBackendPdf, 'SVG' : MathtextBackendSvg, 'Cairo' : MathtextBackendCairo } def __init__(self, output): - self.output = output - self.cache = {} + self._output = output + self._cache = {} - def __call__(self, s, dpi, prop): + def parse(self, s, dpi, prop): cacheKey = (s, dpi, hash(prop)) - if self.cache.has_key(cacheKey): - result = self.cache[cacheKey] + result = self._cache.get(cacheKey) + if result is not None: return result - if self.output == 'PS' and rcParams['ps.useafm']: + if self._output == 'PS' and rcParams['ps.useafm']: font_output = StandardPsFonts(prop) else: - backend = self._backend_mapping[self.output]() + backend = self._backend_mapping[self._output]() if rcParams['mathtext.use_cm']: font_output = BakomaFonts(prop, backend) else: font_output = UnicodeFonts(prop, backend) fontsize = prop.get_size_in_points() + # This is a class variable so we don't rebuild the parser + # with each request. if self._parser is None: self.__class__._parser = Parser() box = self._parser.parse(s, font_output, fontsize, dpi) @@ -2395,7 +2393,7 @@ font_output.set_canvas_size(w, h) ship(2, 2, box) result = font_output.get_results() - self.cache[cacheKey] = result + self._cache[cacheKey] = result # Free up the transient data structures self._parser.clear() # Remove a cyclical reference @@ -2403,8 +2401,8 @@ return result -math_parse_s_ft2font = math_parse_s_ft2font_common('Agg') -math_parse_s_ft2font_svg = math_parse_s_ft2font_common('SVG') -math_parse_s_ps = math_parse_s_ft2font_common('PS') -math_parse_s_pdf = math_parse_s_ft2font_common('PDF') -math_parse_s_cairo = math_parse_s_ft2font_common('Cairo') +# math_parse_s_ft2font = math_parse_s_ft2font_common('Agg') +# math_parse_s_ft2font_svg = math_parse_s_ft2font_common('SVG') +# math_parse_s_ps = math_parse_s_ft2font_common('PS') +# math_parse_s_pdf = math_parse_s_ft2font_common('PDF') +# math_parse_s_cairo = math_parse_s_ft2font_common('Cairo') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-08-21 15:13:53
|
Revision: 3721 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3721&view=rev Author: mdboom Date: 2007-08-21 08:13:49 -0700 (Tue, 21 Aug 2007) Log Message: ----------- Fix capitalization of "Pdf", which must match that in matplotlib/__init__.py Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/config/mpltraits.py Modified: trunk/matplotlib/lib/matplotlib/config/mpltraits.py =================================================================== --- trunk/matplotlib/lib/matplotlib/config/mpltraits.py 2007-08-20 18:52:38 UTC (rev 3720) +++ trunk/matplotlib/lib/matplotlib/config/mpltraits.py 2007-08-21 15:13:49 UTC (rev 3721) @@ -30,7 +30,7 @@ 'agg': 'Agg', 'cairo': 'Cairo', 'ps': 'PS', - 'pdf': 'PDF', + 'pdf': 'Pdf', 'svg': 'SVG', 'template': 'Template' } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ds...@us...> - 2007-08-20 18:52:40
|
Revision: 3720 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3720&view=rev Author: dsdale Date: 2007-08-20 11:52:38 -0700 (Mon, 20 Aug 2007) Log Message: ----------- fix verbose reporting with traited config Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/__init__.py trunk/matplotlib/setup.py Modified: trunk/matplotlib/lib/matplotlib/__init__.py =================================================================== --- trunk/matplotlib/lib/matplotlib/__init__.py 2007-08-20 16:11:29 UTC (rev 3719) +++ trunk/matplotlib/lib/matplotlib/__init__.py 2007-08-20 18:52:38 UTC (rev 3720) @@ -711,6 +711,8 @@ #print "importing from reorganized config system!" try: from config import rcParams, rcdefaults, mplConfig, save_config + verbose.set_level(rcParams['verbose.level']) + verbose.set_fileo(rcParams['verbose.fileo']) except: from config import rcParams, rcdefaults Modified: trunk/matplotlib/setup.py =================================================================== --- trunk/matplotlib/setup.py 2007-08-20 16:11:29 UTC (rev 3719) +++ trunk/matplotlib/setup.py 2007-08-20 18:52:38 UTC (rev 3720) @@ -64,7 +64,7 @@ try: import setuptools except ImportError: raise SystemExit("""\ -matplotlib requires setuptools for installation. Visit: +matplotlib requires setuptools for installation with python-2.3. Visit: http://cheeseshop.python.org/pypi/setuptools for installation instructions for the proper version of setuptools for your system. If this is your first time upgrading matplotlib with the new This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-08-20 16:11:35
|
Revision: 3719 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3719&view=rev Author: mdboom Date: 2007-08-20 09:11:29 -0700 (Mon, 20 Aug 2007) Log Message: ----------- Change mathtext.* rcParams so they accept a string which is a set of arguments to the FontProperties constructor. This has been added to both the classic and traits based configuration frameworks. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/config/mplconfig.py trunk/matplotlib/lib/matplotlib/config/mpltraits.py trunk/matplotlib/lib/matplotlib/config/rcsetup.py trunk/matplotlib/lib/matplotlib/mathtext.py trunk/matplotlib/lib/matplotlib/mpl-data/matplotlibrc trunk/matplotlib/lib/matplotlib/rcsetup.py trunk/matplotlib/matplotlibrc.template Modified: trunk/matplotlib/lib/matplotlib/config/mplconfig.py =================================================================== --- trunk/matplotlib/lib/matplotlib/config/mplconfig.py 2007-08-20 12:47:45 UTC (rev 3718) +++ trunk/matplotlib/lib/matplotlib/config/mplconfig.py 2007-08-20 16:11:29 UTC (rev 3719) @@ -161,12 +161,12 @@ dvipnghack = T.false class mathtext(TConfig): - cal = T.Trait('cursive', 'cursive', 'normal', 'normal') - rm = T.Trait('serif', 'serif', 'normal', 'normal') - tt = T.Trait('monospace', 'monospace', 'normal', 'normal') - it = T.Trait('serif', 'serif', 'normal', 'italic') - bf = T.Trait('serif', 'serif', 'bold', 'normal') - sf = T.Trait('sans-serif', 'sans-serif', 'normal', 'normal') + cal = T.Trait("['cursive']", mplT.FontPropertiesHandler()) + rm = T.Trait("['serif']", mplT.FontPropertiesHandler()) + tt = T.Trait("['monospace']", mplT.FontPropertiesHandler()) + it = T.Trait("['serif'], style='oblique'", mplT.FontPropertiesHandler()) + bf = T.Trait("['serif'], weight='bold'", mplT.FontPropertiesHandler()) + sf = T.Trait("['sans-serif']", mplT.FontPropertiesHandler()) use_cm = T.true fallback_to_cm = T.true Modified: trunk/matplotlib/lib/matplotlib/config/mpltraits.py =================================================================== --- trunk/matplotlib/lib/matplotlib/config/mpltraits.py 2007-08-20 12:47:45 UTC (rev 3718) +++ trunk/matplotlib/lib/matplotlib/config/mpltraits.py 2007-08-20 16:11:29 UTC (rev 3719) @@ -144,3 +144,65 @@ 'hsv', 'hsv_r', 'jet', 'jet_r', 'pink', 'pink_r', 'prism', 'prism_r', 'spectral', 'spectral_r', 'spring', 'spring_r', 'summer', 'summer_r', 'winter', 'winter_r'] + +class FontPropertiesHandler(T.TraitHandler): + class FontPropertiesProxy: + # In order to build a FontProperties object, various rcParams must + # already be known in order to set default values. That means a + # FontProperties object can not be created from a config file, + # since it depends on other values in the same config file. This + # proxy class is used as a temporary storage area for the settings + # in the config file, and the full FontProperties class is created + # only when the class is first used. It is defined here rather than + # in font_manager.py to avoid a cyclical import. + def __init__(self, + family = None, + style = None, + variant= None, + weight = None, + stretch= None, + size = None, + fname = None, # if this is set, it's a hardcoded filename to use + ): + self.__family = family + self.__style = style + self.__variant = variant + self.__weight = weight + self.__stretch = stretch + self.__size = size + self.__fname = fname + + self.__child = None + + def __get_child(self): + if self.__child is None: + from matplotlib.font_manager import FontProperties + self.__child = FontProperties( + family = self.__family, + style = self.__style, + variant = self.__variant, + weight = self.__weight, + stretch = self.__stretch, + size = self.__size, + fname = self.__fname) + return self.__child + + def __getattr__(self, attr): + return getattr(self.__get_child(), attr) + + def validate(self, object, name, value): + from matplotlib.font_manager import FontProperties + if isinstance(value, FontProperties): + return value + if is_string_like(value): + try: + proxy = eval("FontProperties(%s)" % value, + {}, {'FontProperties': self.FontPropertiesProxy}) + except: + pass + else: + return proxy + self.error(object, name, value) + + def info(self): + return 'Represents a set of font properties. Must be a FontProperties object or a string containing the parameters to the FontProperties constructor.' Modified: trunk/matplotlib/lib/matplotlib/config/rcsetup.py =================================================================== --- trunk/matplotlib/lib/matplotlib/config/rcsetup.py 2007-08-20 12:47:45 UTC (rev 3718) +++ trunk/matplotlib/lib/matplotlib/config/rcsetup.py 2007-08-20 16:11:29 UTC (rev 3719) @@ -198,12 +198,64 @@ except ValueError: raise ValueError('not a valid font size') -def validate_mathtext_font(s): - s = eval(s) - if type(s) in (list, tuple) and len(s) == 3: - return s - raise ValueError('Mathtext font specifier must be a 3-tuple of (family, weight, style)') +class FontPropertiesProxy: + # In order to build a FontProperties object, various rcParams must + # already be known in order to set default values. That means a + # FontProperties object can not be created from a config file, + # since it depends on other values in the same config file. This + # proxy class is used as a temporary storage area for the settings + # in the config file, and the full FontProperties class is created + # only when the class is first used. It is defined here rather than + # in font_manager.py to avoid a cyclical import. + def __init__(self, + family = None, + style = None, + variant= None, + weight = None, + stretch= None, + size = None, + fname = None, # if this is set, it's a hardcoded filename to use + ): + self.__family = family + self.__style = style + self.__variant = variant + self.__weight = weight + self.__stretch = stretch + self.__size = size + self.__fname = fname + + self.__child = None + + def __get_child(self): + if self.__child is None: + from font_manager import FontProperties + self.__child = FontProperties( + family = self.__family, + style = self.__style, + variant = self.__variant, + weight = self.__weight, + stretch = self.__stretch, + size = self.__size, + fname = self.__fname) + return self.__child + + def __getattr__(self, attr): + return getattr(self.__get_child(), attr) +def validate_font_properties(s): + parsed = False + try: + prop = eval(u'FontProperties(%s)' % s, + {}, {'FontProperties': FontPropertiesProxy}) + except: + pass + else: + parsed = isinstance(prop, FontPropertiesProxy) + if not parsed: + raise ValueError( + 'Mathtext font specifier must be a set of arguments to the FontProperty constructor.') + return prop + validate_markup = ValidateInStrings( 'markup', ['plain', 'tex'], @@ -366,12 +418,12 @@ 'text.fontsize' : ['medium', validate_fontsize], 'text.markup' : ['plain', validate_markup], - 'mathtext.cal' : [('cursive', 'normal', 'normal'), validate_mathtext_font], - 'mathtext.rm' : [('serif', 'normal', 'normal'), validate_mathtext_font], - 'mathtext.tt' : [('monospace', 'normal', 'normal'), validate_mathtext_font], - 'mathtext.it' : [('serif', 'normal', 'italic'), validate_mathtext_font], - 'mathtext.bf' : [('serif', 'bold', 'normal'), validate_mathtext_font], - 'mathtext.sf' : [('sans-serif', 'normal', 'normal'), validate_mathtext_font], + 'mathtext.cal' : [FontPropertiesProxy(['cursive']), validate_font_properties], + 'mathtext.rm' : [FontPropertiesProxy(['serif']), validate_font_properties], + 'mathtext.tt' : [FontPropertiesProxy(['monospace']), validate_font_properties], + 'mathtext.it' : [FontPropertiesProxy(['serif'], style='oblique'), validate_font_properties], + 'mathtext.bf' : [FontPropertiesProxy(['serif'], weight='bold'), validate_font_properties], + 'mathtext.sf' : [FontPropertiesProxy(['sans-serif']), validate_font_properties], 'mathtext.use_cm' : [True, validate_bool], 'mathtext.fallback_to_cm' : [True, validate_bool], Modified: trunk/matplotlib/lib/matplotlib/mathtext.py =================================================================== --- trunk/matplotlib/lib/matplotlib/mathtext.py 2007-08-20 12:47:45 UTC (rev 3718) +++ trunk/matplotlib/lib/matplotlib/mathtext.py 2007-08-20 16:11:29 UTC (rev 3719) @@ -686,9 +686,7 @@ TruetypeFonts.__init__(self, *args, **kwargs) if not len(self.fontmap): for texfont in "cal rm tt it bf sf".split(): - setting = rcParams['mathtext.' + texfont] - family, weight, style = setting - prop = FontProperties(family=family, weight=weight, style=style) + prop = rcParams['mathtext.' + texfont] font = findfont(prop) self.fontmap[texfont] = font Modified: trunk/matplotlib/lib/matplotlib/mpl-data/matplotlibrc =================================================================== --- trunk/matplotlib/lib/matplotlib/mpl-data/matplotlibrc 2007-08-20 12:47:45 UTC (rev 3718) +++ trunk/matplotlib/lib/matplotlib/mpl-data/matplotlibrc 2007-08-20 16:11:29 UTC (rev 3719) @@ -150,7 +150,7 @@ #text.dvipnghack : False # some versions of dvipng don't handle # alpha channel properly. Use True to correct and flush # ~/.matplotlib/tex.cache before testing -#text.markup : 'plain' # Affects how text, such as titles and lables, are +#text.markup : 'plain' # Affects how text, such as titles and labels, are # interpreted by default. # 'plain': As plain, unformatted text # 'tex': As TeX-like text. Text between $'s will be @@ -160,16 +160,16 @@ # processing. # The following settings allow you to select the fonts in math mode. -# They map from a TeX font name to a 3-tuple of the form: -# (family, weight, style) +# They map from a TeX font name to a set of arguments for the FontProperties constructor. +# (See FontProperties for more details). # These settings are only used if mathtext.use_cm is False, otherwise, the # Bakoma TeX Computer Modern fonts are used. -#mathtext.cal : (['cursive'], 'normal', 'normal') -#mathtext.rm : (['serif'], 'normal', 'normal') -#mathtext.tt : (['monospace'], 'normal', 'normal') -#mathtext.it : (['serif'], 'normal', 'oblique') -#mathtext.bf : (['serif'], 'bold', 'normal') -#mathtext.sf : (['sans-serif'], 'normal', 'normal') +#mathtext.cal : ['cursive'] +#mathtext.rm : ['serif'] +#mathtext.tt : ['monospace'] +#mathtext.it : ['serif'], style='oblique' +#mathtext.bf : ['serif'], weight='bold' +#mathtext.sf : ['sans-serif'] #mathtext.use_cm : True #mathtext.fallback_to_cm : True # When True, use symbols from the Computer Modern # fonts when a symbol can not be found in one of Modified: trunk/matplotlib/lib/matplotlib/rcsetup.py =================================================================== --- trunk/matplotlib/lib/matplotlib/rcsetup.py 2007-08-20 12:47:45 UTC (rev 3718) +++ trunk/matplotlib/lib/matplotlib/rcsetup.py 2007-08-20 16:11:29 UTC (rev 3719) @@ -198,12 +198,64 @@ except ValueError: raise ValueError('not a valid font size') -def validate_mathtext_font(s): - s = eval(s) - if type(s) in (list, tuple) and len(s) == 3: - return s - raise ValueError('Mathtext font specifier must be a 3-tuple of (family, weight, style)') +class FontPropertiesProxy: + # In order to build a FontProperties object, various rcParams must + # already be known in order to set default values. That means a + # FontProperties object can not be created from a config file, + # since it depends on other values in the same config file. This + # proxy class is used as a temporary storage area for the settings + # in the config file, and the full FontProperties class is created + # only when the class is first used. It is defined here rather than + # in font_manager.py to avoid a cyclical import. + def __init__(self, + family = None, + style = None, + variant= None, + weight = None, + stretch= None, + size = None, + fname = None, # if this is set, it's a hardcoded filename to use + ): + self.__family = family + self.__style = style + self.__variant = variant + self.__weight = weight + self.__stretch = stretch + self.__size = size + self.__fname = fname + + self.__child = None + + def __get_child(self): + if self.__child is None: + from font_manager import FontProperties + self.__child = FontProperties( + family = self.__family, + style = self.__style, + variant = self.__variant, + weight = self.__weight, + stretch = self.__stretch, + size = self.__size, + fname = self.__fname) + return self.__child + + def __getattr__(self, attr): + return getattr(self.__get_child(), attr) +def validate_font_properties(s): + parsed = False + try: + prop = eval(u'FontProperties(%s)' % s, + {}, {'FontProperties': FontPropertiesProxy}) + except: + pass + else: + parsed = isinstance(prop, FontPropertiesProxy) + if not parsed: + raise ValueError( + 'Mathtext font specifier must be a set of arguments to the FontProperty constructor.') + return prop + validate_markup = ValidateInStrings( 'markup', ['plain', 'tex'], @@ -366,12 +418,12 @@ 'text.fontsize' : ['medium', validate_fontsize], 'text.markup' : ['plain', validate_markup], - 'mathtext.cal' : [('cursive', 'normal', 'normal'), validate_mathtext_font], - 'mathtext.rm' : [('serif', 'normal', 'normal'), validate_mathtext_font], - 'mathtext.tt' : [('monospace', 'normal', 'normal'), validate_mathtext_font], - 'mathtext.it' : [('serif', 'normal', 'italic'), validate_mathtext_font], - 'mathtext.bf' : [('serif', 'bold', 'normal'), validate_mathtext_font], - 'mathtext.sf' : [('sans-serif', 'normal', 'normal'), validate_mathtext_font], + 'mathtext.cal' : [FontPropertiesProxy(['cursive']), validate_font_properties], + 'mathtext.rm' : [FontPropertiesProxy(['serif']), validate_font_properties], + 'mathtext.tt' : [FontPropertiesProxy(['monospace']), validate_font_properties], + 'mathtext.it' : [FontPropertiesProxy(['serif'], style='oblique'), validate_font_properties], + 'mathtext.bf' : [FontPropertiesProxy(['serif'], weight='bold'), validate_font_properties], + 'mathtext.sf' : [FontPropertiesProxy(['sans-serif']), validate_font_properties], 'mathtext.use_cm' : [True, validate_bool], 'mathtext.fallback_to_cm' : [True, validate_bool], Modified: trunk/matplotlib/matplotlibrc.template =================================================================== --- trunk/matplotlib/matplotlibrc.template 2007-08-20 12:47:45 UTC (rev 3718) +++ trunk/matplotlib/matplotlibrc.template 2007-08-20 16:11:29 UTC (rev 3719) @@ -150,7 +150,7 @@ #text.dvipnghack : False # some versions of dvipng don't handle # alpha channel properly. Use True to correct and flush # ~/.matplotlib/tex.cache before testing -#text.markup : 'plain' # Affects how text, such as titles and lables, are +#text.markup : 'plain' # Affects how text, such as titles and labels, are # interpreted by default. # 'plain': As plain, unformatted text # 'tex': As TeX-like text. Text between $'s will be @@ -160,16 +160,16 @@ # processing. # The following settings allow you to select the fonts in math mode. -# They map from a TeX font name to a 3-tuple of the form: -# (family, weight, style) +# They map from a TeX font name to a set of arguments for the FontProperties constructor. +# (See FontProperties for more details). # These settings are only used if mathtext.use_cm is False, otherwise, the # Bakoma TeX Computer Modern fonts are used. -#mathtext.cal : (['cursive'], 'normal', 'normal') -#mathtext.rm : (['serif'], 'normal', 'normal') -#mathtext.tt : (['monospace'], 'normal', 'normal') -#mathtext.it : (['serif'], 'normal', 'oblique') -#mathtext.bf : (['serif'], 'bold', 'normal') -#mathtext.sf : (['sans-serif'], 'normal', 'normal') +#mathtext.cal : ['cursive'] +#mathtext.rm : ['serif'] +#mathtext.tt : ['monospace'] +#mathtext.it : ['serif'], style='oblique' +#mathtext.bf : ['serif'], weight='bold' +#mathtext.sf : ['sans-serif'] #mathtext.use_cm : True #mathtext.fallback_to_cm : True # When True, use symbols from the Computer Modern # fonts when a symbol can not be found in one of This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ds...@us...> - 2007-08-20 12:48:47
|
Revision: 3718 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3718&view=rev Author: dsdale Date: 2007-08-20 05:47:45 -0700 (Mon, 20 Aug 2007) Log Message: ----------- sync tconfig.py with sources in ipython1 Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/config/tconfig.py Modified: trunk/matplotlib/lib/matplotlib/config/tconfig.py =================================================================== --- trunk/matplotlib/lib/matplotlib/config/tconfig.py 2007-08-20 12:47:42 UTC (rev 3717) +++ trunk/matplotlib/lib/matplotlib/config/tconfig.py 2007-08-20 12:47:45 UTC (rev 3718) @@ -370,8 +370,6 @@ if config is None: config = mkConfigObj(None) - - # Validate the set of scalars ... my_scalars = set(get_scalars(self)) cf_scalars = set(config.scalars) @@ -603,7 +601,7 @@ This method, in contrast with write(), updates the .fconfCombined object with the *entire* .tconf instance, and then writes it out to - disk. This method is thus useful for generating files that contain an + disk. This method is thus useful for generating files that have a self-contained, non-hierarchical file. :Keywords: @@ -615,12 +613,12 @@ if filename is not None: fileObj = open(filename,'w') self.fconfUpdate(self.fconfCombined,self.tconf) - out = self.fconf.write(fileObj) + out = self.fconfCombined.write(fileObj) fileObj.close() return out else: self.fconfUpdate(self.fconfCombined,self.tconf) - return self.fconf.write() + return self.fconfCombined.write() def tconfStr(self): return str(self.tconf) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-08-20 12:48:21
|
Revision: 3717 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3717&view=rev Author: mdboom Date: 2007-08-20 05:47:42 -0700 (Mon, 20 Aug 2007) Log Message: ----------- Take a version check out of the method call. Thanks to Fernando Perez. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_gtkcairo.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gtkcairo.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_gtkcairo.py 2007-08-20 12:46:53 UTC (rev 3716) +++ trunk/matplotlib/lib/matplotlib/backends/backend_gtkcairo.py 2007-08-20 12:47:42 UTC (rev 3717) @@ -29,12 +29,14 @@ class RendererGTKCairo (backend_cairo.RendererCairo): - def set_pixmap (self, pixmap): - if gtk.pygtk_version >= (2,7,0): + if gtk.pygtk_version >= (2,7,0): + def set_pixmap (self, pixmap): self.ctx = pixmap.cairo_create() - else: + self.ctx.save() # restore, save - when call new_gc() + else: + def set_pixmap (self, pixmap): self.ctx = cairo.gtk.gdk_cairo_create (pixmap) - self.ctx.save() # restore, save - when call new_gc() + self.ctx.save() # restore, save - when call new_gc() class FigureCanvasGTKCairo(FigureCanvasGTK): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-08-20 12:47:10
|
Revision: 3716 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3716&view=rev Author: mdboom Date: 2007-08-20 05:46:53 -0700 (Mon, 20 Aug 2007) Log Message: ----------- Remove a Unicode character Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/mathtext.py Modified: trunk/matplotlib/lib/matplotlib/mathtext.py =================================================================== --- trunk/matplotlib/lib/matplotlib/mathtext.py 2007-08-17 22:36:01 UTC (rev 3715) +++ trunk/matplotlib/lib/matplotlib/mathtext.py 2007-08-20 12:46:53 UTC (rev 3716) @@ -176,9 +176,9 @@ or a Type1 symbol name (i.e. 'phi'). """ - # From UTF #25: U+2212 − minus sign is the preferred + # From UTF #25: U+2212 minus sign is the preferred # representation of the unary and binary minus sign rather than - # the ASCII-derived U+002D - hyphen-minus, because minus sign is + # the ASCII-derived U+002D hyphen-minus, because minus sign is # unambiguous and because it is rendered with a more desirable # length, usually longer than a hyphen. if symbol == '-': This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2007-08-17 22:36:08
|
Revision: 3715 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3715&view=rev Author: efiring Date: 2007-08-17 15:36:01 -0700 (Fri, 17 Aug 2007) Log Message: ----------- Added coll.update(kwargs) to hline method; thanks to Daniel Fish Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/axes.py Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2007-08-16 21:57:58 UTC (rev 3714) +++ trunk/matplotlib/lib/matplotlib/axes.py 2007-08-17 22:36:01 UTC (rev 3715) @@ -2345,7 +2345,6 @@ respective values are constant, else the widths of the lines are determined by xmin and xmax - colors is a line collections color args, either a single color or a len(x) list of colors @@ -2370,23 +2369,18 @@ xmin = npy.asarray(xmin) xmax = npy.asarray(xmax) - if len(xmin)!=len(y): raise ValueError, 'xmin and y are unequal sized sequences' if len(xmax)!=len(y): raise ValueError, 'xmax and y are unequal sized sequences' - - - verts = [ ((thisxmin, thisy), (thisxmax, thisy)) for thisxmin, thisxmax, thisy in zip(xmin, xmax, y)] coll = mcoll.LineCollection(verts, colors=colors, linestyle=linestyle, label=label) self.add_collection(coll) + coll.update(kwargs) - - minx = min(xmin.min(), xmax.min()) maxx = max(xmin.max(), xmax.max()) miny = y.min() @@ -2444,8 +2438,6 @@ if len(ymax)==1: ymax = ymax*npy.ones(x.shape, x.dtype) - - if len(ymin)!=len(x): raise ValueError, 'ymin and x are unequal sized sequences' if len(ymax)!=len(x): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ds...@us...> - 2007-08-16 21:58:02
|
Revision: 3714 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3714&view=rev Author: dsdale Date: 2007-08-16 14:57:58 -0700 (Thu, 16 Aug 2007) Log Message: ----------- revert changes that cause embedding_in_qt4 to fail Modified Paths: -------------- trunk/matplotlib/examples/embedding_in_qt4.py Modified: trunk/matplotlib/examples/embedding_in_qt4.py =================================================================== --- trunk/matplotlib/examples/embedding_in_qt4.py 2007-08-16 21:48:52 UTC (rev 3713) +++ trunk/matplotlib/examples/embedding_in_qt4.py 2007-08-16 21:57:58 UTC (rev 3714) @@ -64,13 +64,11 @@ def compute_initial_figure(self): self.axes.plot([0, 1, 2, 3], [1, 2, 0, 4], 'r') - self.axes.set_yscale('log') def update_figure(self): # Build a list of 4 random integers between 0 and 10 (both inclusive) l = [ random.randint(0, 10) for i in xrange(4) ] - l[l<=0]=1 self.axes.plot([0, 1, 2, 3], l, 'r') self.draw() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ds...@us...> - 2007-08-16 21:48:53
|
Revision: 3713 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3713&view=rev Author: dsdale Date: 2007-08-16 14:48:52 -0700 (Thu, 16 Aug 2007) Log Message: ----------- fic bug in traited config: mathtext settings Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/config/mplconfig.py Modified: trunk/matplotlib/lib/matplotlib/config/mplconfig.py =================================================================== --- trunk/matplotlib/lib/matplotlib/config/mplconfig.py 2007-08-16 21:28:24 UTC (rev 3712) +++ trunk/matplotlib/lib/matplotlib/config/mplconfig.py 2007-08-16 21:48:52 UTC (rev 3713) @@ -159,6 +159,16 @@ unicode = T.false preamble = T.ListStr([]) dvipnghack = T.false + + class mathtext(TConfig): + cal = T.Trait('cursive', 'cursive', 'normal', 'normal') + rm = T.Trait('serif', 'serif', 'normal', 'normal') + tt = T.Trait('monospace', 'monospace', 'normal', 'normal') + it = T.Trait('serif', 'serif', 'normal', 'italic') + bf = T.Trait('serif', 'serif', 'bold', 'normal') + sf = T.Trait('sans-serif', 'sans-serif', 'normal', 'normal') + use_cm = T.true + fallback_to_cm = T.true class axes(TConfig): hold = T.Trait(True, mplT.BoolHandler()) @@ -329,6 +339,15 @@ 'text.latex.preamble' : (self.tconfig.text.latex, 'preamble'), 'text.dvipnghack' : (self.tconfig.text.latex, 'dvipnghack'), 'text.markup' : (self.tconfig.text, 'markup'), + + 'mathtext.cal' : (self.tconfig.mathtext, 'cal'), + 'mathtext.rm' : (self.tconfig.mathtext, 'rm'), + 'mathtext.tt' : (self.tconfig.mathtext, 'tt'), + 'mathtext.it' : (self.tconfig.mathtext, 'it'), + 'mathtext.bf' : (self.tconfig.mathtext, 'bf'), + 'mathtext.sf' : (self.tconfig.mathtext, 'sf'), + 'mathtext.use_cm' : (self.tconfig.mathtext, 'use_cm'), + 'mathtext.fallback_to_cm' : (self.tconfig.mathtext, 'fallback_to_cm'), 'image.aspect' : (self.tconfig.image, 'aspect'), 'image.interpolation' : (self.tconfig.image, 'interpolation'), This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ds...@us...> - 2007-08-16 21:40:14
|
Revision: 3712 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3712&view=rev Author: dsdale Date: 2007-08-16 14:28:24 -0700 (Thu, 16 Aug 2007) Log Message: ----------- fixed bug in traited config: text.markup Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/config/mplconfig.py Modified: trunk/matplotlib/lib/matplotlib/config/mplconfig.py =================================================================== --- trunk/matplotlib/lib/matplotlib/config/mplconfig.py 2007-08-16 19:43:35 UTC (rev 3711) +++ trunk/matplotlib/lib/matplotlib/config/mplconfig.py 2007-08-16 21:28:24 UTC (rev 3712) @@ -328,7 +328,7 @@ 'text.latex.unicode' : (self.tconfig.text.latex, 'unicode'), 'text.latex.preamble' : (self.tconfig.text.latex, 'preamble'), 'text.dvipnghack' : (self.tconfig.text.latex, 'dvipnghack'), - 'text.markup' : (self.tconfig.text.markup, 'markup'), + 'text.markup' : (self.tconfig.text, 'markup'), 'image.aspect' : (self.tconfig.image, 'aspect'), 'image.interpolation' : (self.tconfig.image, 'interpolation'), This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |