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: <md...@us...> - 2008-05-05 15:12:32
|
Revision: 5111
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5111&view=rev
Author: mdboom
Date: 2008-05-05 08:12:29 -0700 (Mon, 05 May 2008)
Log Message:
-----------
Fix a number of minor issues discovered with "-pedantic"
Modified Paths:
--------------
trunk/matplotlib/src/MPL_isnan.h
trunk/matplotlib/src/_backend_agg.cpp
trunk/matplotlib/src/_image.cpp
trunk/matplotlib/src/_image.h
trunk/matplotlib/src/_path.cpp
trunk/matplotlib/src/_tkagg.cpp
trunk/matplotlib/src/_ttconv.cpp
trunk/matplotlib/src/cntr.c
trunk/matplotlib/src/ft2font.cpp
Modified: trunk/matplotlib/src/MPL_isnan.h
===================================================================
--- trunk/matplotlib/src/MPL_isnan.h 2008-05-02 21:52:05 UTC (rev 5110)
+++ trunk/matplotlib/src/MPL_isnan.h 2008-05-05 15:12:29 UTC (rev 5111)
@@ -8,6 +8,10 @@
*/
+#ifdef _ISOC99_SOURCE
+#include <stdint.h>
+#endif
+
#if defined(SIZEOF_VOID_P)
#if SIZEOF_VOID_P == 8
#define MPL_LP64 1
@@ -24,9 +28,13 @@
#if defined(_MSC_VER)
typedef __int64 MPL_Int64;
#else
+#if defined(_ISOC99_SOURCE)
+typedef int64_t MPL_Int64;
+#else
typedef long long MPL_Int64;
#endif
#endif
+#endif
#if !defined(MPL_U64)
#define MPL_U64(u) (* (MPL_Int64 *) &(u) )
Modified: trunk/matplotlib/src/_backend_agg.cpp
===================================================================
--- trunk/matplotlib/src/_backend_agg.cpp 2008-05-02 21:52:05 UTC (rev 5110)
+++ trunk/matplotlib/src/_backend_agg.cpp 2008-05-05 15:12:29 UTC (rev 5111)
@@ -249,7 +249,7 @@
//theRasterizer->filling_rule(agg::fill_even_odd);
//theRasterizer->filling_rule(agg::fill_non_zero);
-};
+}
void RendererAgg::create_alpha_buffers() {
if (!alphaBuffer) {
@@ -1762,4 +1762,4 @@
static _backend_agg_module* _backend_agg = NULL;
_backend_agg = new _backend_agg_module;
-};
+}
Modified: trunk/matplotlib/src/_image.cpp
===================================================================
--- trunk/matplotlib/src/_image.cpp 2008-05-02 21:52:05 UTC (rev 5110)
+++ trunk/matplotlib/src/_image.cpp 2008-05-05 15:12:29 UTC (rev 5111)
@@ -826,7 +826,7 @@
for (size_t i=0; i<thisim->colsOut; i++) {
thisx = i+ox;
thisy = j+oy;
- if (thisx<0 || thisx>=numcols || thisy<0 || thisy>=numrows) {
+ if (thisx>=numcols || thisy>=numrows) {
ind +=4;
continue;
}
Modified: trunk/matplotlib/src/_image.h
===================================================================
--- trunk/matplotlib/src/_image.h 2008-05-02 21:52:05 UTC (rev 5110)
+++ trunk/matplotlib/src/_image.h 2008-05-05 15:12:29 UTC (rev 5111)
@@ -61,7 +61,7 @@
MITCHELL,
SINC,
LANCZOS,
- BLACKMAN,};
+ BLACKMAN};
//enum { BICUBIC=0, BILINEAR, BLACKMAN100, BLACKMAN256, BLACKMAN64,
// NEAREST, SINC144, SINC256, SINC64, SPLINE16, SPLINE36};
Modified: trunk/matplotlib/src/_path.cpp
===================================================================
--- trunk/matplotlib/src/_path.cpp 2008-05-02 21:52:05 UTC (rev 5110)
+++ trunk/matplotlib/src/_path.cpp 2008-05-05 15:12:29 UTC (rev 5111)
@@ -1161,4 +1161,4 @@
static _path_module* _path = NULL;
_path = new _path_module;
-};
+}
Modified: trunk/matplotlib/src/_tkagg.cpp
===================================================================
--- trunk/matplotlib/src/_tkagg.cpp 2008-05-02 21:52:05 UTC (rev 5110)
+++ trunk/matplotlib/src/_tkagg.cpp 2008-05-05 15:12:29 UTC (rev 5111)
@@ -27,7 +27,7 @@
#else
# include <tk.h>
#endif
-};
+}
Modified: trunk/matplotlib/src/_ttconv.cpp
===================================================================
--- trunk/matplotlib/src/_ttconv.cpp 2008-05-02 21:52:05 UTC (rev 5110)
+++ trunk/matplotlib/src/_ttconv.cpp 2008-05-05 15:12:29 UTC (rev 5111)
@@ -204,7 +204,7 @@
"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"
},
- {NULL} /* Sentinel */
+ {0, 0, 0, 0} /* Sentinel */
};
#ifndef PyMODINIT_FUNC /* declarations for DLL import/export */
Modified: trunk/matplotlib/src/cntr.c
===================================================================
--- trunk/matplotlib/src/cntr.c 2008-05-02 21:52:05 UTC (rev 5110)
+++ trunk/matplotlib/src/cntr.c 2008-05-05 15:12:29 UTC (rev 5111)
@@ -1688,7 +1688,7 @@
" Optional argument: nchunk; approximate number of grid points\n"
" per chunk. 0 (default) for no chunking.\n"
},
- {NULL} /* Sentinel */
+ {0, 0, 0, 0} /* Sentinel */
};
static PyTypeObject CntrType = {
Modified: trunk/matplotlib/src/ft2font.cpp
===================================================================
--- trunk/matplotlib/src/ft2font.cpp 2008-05-02 21:52:05 UTC (rev 5110)
+++ trunk/matplotlib/src/ft2font.cpp 2008-05-05 15:12:29 UTC (rev 5111)
@@ -153,8 +153,7 @@
void
FT2Image::draw_rect(unsigned long x0, unsigned long y0,
unsigned long x1, unsigned long y1) {
- if ( x0<0 || y0<0 || x1<0 || y1<0 ||
- x0>_width || x1>_width ||
+ if ( x0>_width || x1>_width ||
y0>_height || y1>_height )
throw Py::ValueError("Rect coords outside image bounds");
@@ -197,10 +196,10 @@
void FT2Image::draw_rect_filled(unsigned long x0, unsigned long y0,
unsigned long x1, unsigned long y1) {
- x0 = CLAMP(x0, 0, _width);
- y0 = CLAMP(y0, 0, _height);
- x1 = CLAMP(x1, 0, _width);
- y1 = CLAMP(y1, 0, _height);
+ x0 = std::min(x0, _width);
+ y0 = std::min(y0, _height);
+ x1 = std::min(x1, _width);
+ y1 = std::min(y1, _height);
for (size_t j=y0; j<y1+1; j++) {
for (size_t i=x0; i<x1+1; i++) {
@@ -1207,7 +1206,7 @@
"draw_glyphs_to_bitmap. This function is intended for people who\n"
"want to render individual glyphs at precise locations, eg, a\n"
"a glyph returned by load_char\n";
-;
+
Py::Object
FT2Font::draw_glyph_to_bitmap(const Py::Tuple & args) {
_VERBOSE("FT2Font::draw_glyph_to_bitmap");
@@ -1768,7 +1767,7 @@
behaviors().supportGetattr();
behaviors().supportSetattr();
-};
+}
//todo add module docs strings
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mme...@us...> - 2008-05-02 21:52:17
|
Revision: 5110
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5110&view=rev
Author: mmetz_bn
Date: 2008-05-02 14:52:05 -0700 (Fri, 02 May 2008)
Log Message:
-----------
Add step histograms
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/axes.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-05-02 17:21:27 UTC (rev 5109)
+++ trunk/matplotlib/CHANGELOG 2008-05-02 21:52:05 UTC (rev 5110)
@@ -1,3 +1,5 @@
+2008-05-02 Added step histograms, based on patch by Erik Tollerud. - MM
+
2008-05-02 On PyQt <= 3.14 there is no way to determine the underlying
Qt version. [1851364] - MGD
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py 2008-05-02 17:21:27 UTC (rev 5109)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2008-05-02 21:52:05 UTC (rev 5110)
@@ -5406,11 +5406,11 @@
#### Data analysis
- def hist(self, x, bins=10, normed=0, bottom=None,
+ def hist(self, x, bins=10, normed=0, bottom=None, histtype='bar',
align='edge', orientation='vertical', width=None,
log=False, **kwargs):
"""
- HIST(x, bins=10, normed=0, bottom=None,
+ HIST(x, bins=10, normed=0, bottom=None, histtype='bar',
align='edge', orientation='vertical', width=None,
log=False, **kwargs)
@@ -5429,6 +5429,10 @@
pdf, bins, patches = ax.hist(...)
print np.trapz(pdf, bins)
+ histtype = 'bar' | 'step'. The type of histogram to draw.
+ 'bar' is a traditional bar-type histogram, 'step' generates
+ a lineplot.
+
align = 'edge' | 'center'. Interprets bins either as edge
or center values
@@ -5436,7 +5440,7 @@
will be used and the "bottom" kwarg will be the left edges.
width: the width of the bars. If None, automatically compute
- the width.
+ the width. Ignored for 'step' histtype.
log: if True, the histogram axis will be set to a log scale
@@ -5446,15 +5450,44 @@
"""
if not self._hold: self.cla()
n, bins = np.histogram(x, bins, range=None, normed=normed)
- if width is None: width = 0.9*(bins[1]-bins[0])
- if orientation == 'horizontal':
- patches = self.barh(bins, n, height=width, left=bottom,
- align=align, log=log)
- elif orientation == 'vertical':
- patches = self.bar(bins, n, width=width, bottom=bottom,
- align=align, log=log)
+ if width is None:
+ if histtype == 'bar':
+ width = 0.9*(bins[1]-bins[0])
+ elif histtype == 'step':
+ width = bins[1]-bins[0]
+ else:
+ raise ValueError, 'invalid histtype: %s' % histtype
+
+ if histtype == 'bar':
+ if orientation == 'horizontal':
+ patches = self.barh(bins, n, height=width, left=bottom,
+ align=align, log=log)
+ elif orientation == 'vertical':
+ patches = self.bar(bins, n, width=width, bottom=bottom,
+ align=align, log=log)
+ else:
+ raise ValueError, 'invalid orientation: %s' % orientation
+
+ elif histtype == 'step':
+ binedges = np.concatenate((bins,bins[-1:]+width))
+ if align == 'center':
+ binedges -= 0.5*width
+ x = np.zeros( 2*len(binedges), np.float_ )
+ y = np.zeros( 2*len(binedges), np.float_ )
+
+ x[0:-1:2],x[1::2] = binedges, binedges
+ y[1:-1:2],y[2::2] = n, n
+
+ if orientation == 'horizontal':
+ x,y = y,x
+ elif orientation == 'vertical':
+ pass
+ else:
+ raise ValueError, 'invalid orientation: %s' % orientation
+ patches = self.fill(x,y)
else:
- raise ValueError, 'invalid orientation: %s' % orientation
+ raise ValueError, 'invalid histtype: %s' % histtype
+
for p in patches:
p.update(kwargs)
return n, bins, cbook.silent_list('Patch', patches)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-05-02 17:21:34
|
Revision: 5109
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5109&view=rev
Author: mdboom
Date: 2008-05-02 10:21:27 -0700 (Fri, 02 May 2008)
Log Message:
-----------
Merged revisions 5106-5108 via svnmerge from
https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v0_91_maint
........
r5107 | mdboom | 2008-05-02 13:05:19 -0400 (Fri, 02 May 2008) | 2 lines
Don't call sys.exit() when pyemf is not found.
........
r5108 | mdboom | 2008-05-02 13:20:38 -0400 (Fri, 02 May 2008) | 2 lines
Fix build error with PyQt <= 3.14 [1851364] - MGD
........
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/backends/backend_emf.py
trunk/matplotlib/setupext.py
Property Changed:
----------------
trunk/matplotlib/
Property changes on: trunk/matplotlib
___________________________________________________________________
Name: svnmerge-integrated
- /branches/v0_91_maint:1-5105
+ /branches/v0_91_maint:1-5108
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-05-02 17:20:38 UTC (rev 5108)
+++ trunk/matplotlib/CHANGELOG 2008-05-02 17:21:27 UTC (rev 5109)
@@ -1,3 +1,9 @@
+2008-05-02 On PyQt <= 3.14 there is no way to determine the underlying
+ Qt version. [1851364] - MGD
+
+2008-05-02 Don't call sys.exit() when pyemf is not found [1924199] -
+ MGD
+
2008-05-02 Update _subprocess.c from upstream Python 2.5.2 to get a
few memory and reference-counting-related bugfixes. See
bug 1949978. - MGD
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_emf.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_emf.py 2008-05-02 17:20:38 UTC (rev 5108)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_emf.py 2008-05-02 17:21:27 UTC (rev 5109)
@@ -8,9 +8,7 @@
try:
import pyemf
except ImportError:
- import sys
- print >>sys.stderr, 'You must first install pyemf from http://pyemf.sf.net'
- sys.exit()
+ raise ImportError('You must first install pyemf from http://pyemf.sf.net')
import os,sys,math,re
@@ -600,7 +598,7 @@
pass
filetypes = {'emf': 'Enhanced Metafile'}
-
+
def print_emf(self, filename, dpi=300, **kwargs):
width, height = self.figure.get_size_inches()
renderer = RendererEMF(filename,width,height,dpi)
@@ -609,7 +607,7 @@
def get_default_filetype(self):
return 'emf'
-
+
class FigureManagerEMF(FigureManagerBase):
"""
Wrap everything up into a window for the pylab interface
Modified: trunk/matplotlib/setupext.py
===================================================================
--- trunk/matplotlib/setupext.py 2008-05-02 17:20:38 UTC (rev 5108)
+++ trunk/matplotlib/setupext.py 2008-05-02 17:21:27 UTC (rev 5109)
@@ -351,8 +351,13 @@
print_status("Qt", "no")
return False
else:
+ try:
+ qt_version = pyqtconfig.Configuration().qt_version
+ qt_version = convert_qt_version(qt_version)
+ except AttributeError:
+ qt_version = "<unknown>"
print_status("Qt", "Qt: %s, PyQt: %s" %
- (convert_qt_version(pyqtconfig.Configuration().qt_version),
+ (qt_version,
pyqtconfig.Configuration().pyqt_version_str))
return True
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-05-02 17:20:40
|
Revision: 5108
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5108&view=rev
Author: mdboom
Date: 2008-05-02 10:20:38 -0700 (Fri, 02 May 2008)
Log Message:
-----------
Fix build error with PyQt <= 3.14 [1851364] - MGD
Modified Paths:
--------------
branches/v0_91_maint/CHANGELOG
branches/v0_91_maint/setupext.py
Modified: branches/v0_91_maint/CHANGELOG
===================================================================
--- branches/v0_91_maint/CHANGELOG 2008-05-02 17:05:19 UTC (rev 5107)
+++ branches/v0_91_maint/CHANGELOG 2008-05-02 17:20:38 UTC (rev 5108)
@@ -1,3 +1,6 @@
+2008-05-02 On PyQt <= 3.14 there is no way to determine the underlying
+ Qt version. [1851364] - MGD
+
2008-05-02 Don't call sys.exit() when pyemf is not found [1924199] -
MGD
Modified: branches/v0_91_maint/setupext.py
===================================================================
--- branches/v0_91_maint/setupext.py 2008-05-02 17:05:19 UTC (rev 5107)
+++ branches/v0_91_maint/setupext.py 2008-05-02 17:20:38 UTC (rev 5108)
@@ -100,20 +100,20 @@
numpy_inc_dirs = []
# matplotlib build options, which can be altered using setup.cfg
-options = {'display_status': True,
- 'verbose': False,
- 'provide_pytz': 'auto',
- 'provide_dateutil': 'auto',
- 'provide_configobj': 'auto',
- 'provide_traits': 'auto',
- 'build_agg': True,
- 'build_gtk': 'auto',
- 'build_gtkagg': 'auto',
- 'build_tkagg': 'auto',
- 'build_wxagg': 'auto',
- 'build_image': True,
- 'build_windowing': True,
- 'backend': None,
+options = {'display_status': True,
+ 'verbose': False,
+ 'provide_pytz': 'auto',
+ 'provide_dateutil': 'auto',
+ 'provide_configobj': 'auto',
+ 'provide_traits': 'auto',
+ 'build_agg': True,
+ 'build_gtk': 'auto',
+ 'build_gtkagg': 'auto',
+ 'build_tkagg': 'auto',
+ 'build_wxagg': 'auto',
+ 'build_image': True,
+ 'build_windowing': True,
+ 'backend': None,
'numerix': None}
# Based on the contents of setup.cfg, determine the build options
@@ -351,8 +351,13 @@
print_status("Qt", "no")
return False
else:
+ try:
+ qt_version = pyqtconfig.Configuration().qt_version
+ qt_version = convert_qt_version(qt_version)
+ except AttributeError:
+ qt_version = "<unknown>"
print_status("Qt", "Qt: %s, PyQt: %s" %
- (convert_qt_version(pyqtconfig.Configuration().qt_version),
+ (qt_version,
pyqtconfig.Configuration().pyqt_version_str))
return True
@@ -813,7 +818,7 @@
explanation = "Tcl/Tk v8.3 or later required"
else:
gotit = True
-
+
if gotit:
module = Extension('test', [])
try:
@@ -830,7 +835,7 @@
else:
explanation = message
gotit = False
-
+
if gotit:
print_status("Tkinter", "Tkinter: %s, Tk: %s, Tcl: %s" %
(Tkinter.__version__.split()[-2], Tkinter.TkVersion, Tkinter.TclVersion))
@@ -849,7 +854,7 @@
# Use cached values if they exist, which ensures this function only executes once
if TCL_TK_CACHE is not None:
return TCL_TK_CACHE
-
+
# By this point, we already know that Tkinter imports correctly
import Tkinter
tcl_lib_dir = ''
@@ -875,14 +880,14 @@
tk.withdraw()
tcl_lib_dir = str(tk.getvar('tcl_library'))
tk_lib_dir = str(tk.getvar('tk_library'))
-
+
# Save directories and version string to cache
TCL_TK_CACHE = tcl_lib_dir, tk_lib_dir, str(Tkinter.TkVersion)[:3]
return TCL_TK_CACHE
def add_tk_flags(module):
'Add the module flags to build extensions which use tk'
- message = None
+ message = None
if sys.platform == 'win32':
major, minor1, minor2, s, tmp = sys.version_info
if major == 2 and minor1 in [3, 4, 5]:
@@ -894,11 +899,11 @@
else:
raise RuntimeError('No tk/win32 support for this python version yet')
module.library_dirs.extend([os.path.join(sys.prefix, 'dlls')])
-
+
elif sys.platform == 'darwin':
# this config section lifted directly from Imaging - thanks to
# the effbot!
-
+
# First test for a MacOSX/darwin framework install
from os.path import join, exists
framework_dirs = [
@@ -906,7 +911,7 @@
'/Library/Frameworks',
'/System/Library/Frameworks/',
]
-
+
# Find the directory that contains the Tcl.framework and Tk.framework
# bundles.
# XXX distutils should support -F!
@@ -931,7 +936,7 @@
for fw in 'Tcl', 'Tk'
for H in 'Headers', 'Versions/Current/PrivateHeaders'
]
-
+
# For 8.4a2, the X11 headers are not included. Rather than include a
# complicated search, this is a hard-coded path. It could bail out
# if X11 libs are not found...
@@ -940,31 +945,31 @@
module.include_dirs.extend(tk_include_dirs)
module.extra_link_args.extend(frameworks)
module.extra_compile_args.extend(frameworks)
-
+
# you're still here? ok we'll try it this way...
else:
# Query Tcl/Tk system for library paths and version string
tcl_lib_dir, tk_lib_dir, tk_ver = query_tcltk() # todo: try/except
-
+
# Process base directories to obtain include + lib dirs
- if tcl_lib_dir != '' and tk_lib_dir != '':
+ if tcl_lib_dir != '' and tk_lib_dir != '':
tcl_lib = os.path.normpath(os.path.join(tcl_lib_dir, '../'))
tk_lib = os.path.normpath(os.path.join(tk_lib_dir, '../'))
- tcl_inc = os.path.normpath(os.path.join(tcl_lib_dir,
+ tcl_inc = os.path.normpath(os.path.join(tcl_lib_dir,
'../../include/tcl' + tk_ver))
if not os.path.exists(tcl_inc):
- tcl_inc = os.path.normpath(os.path.join(tcl_lib_dir,
+ tcl_inc = os.path.normpath(os.path.join(tcl_lib_dir,
'../../include'))
- tk_inc = os.path.normpath(os.path.join(tk_lib_dir,
+ tk_inc = os.path.normpath(os.path.join(tk_lib_dir,
'../../include/tk' + tk_ver))
if not os.path.exists(tk_inc):
- tk_inc = os.path.normpath(os.path.join(tk_lib_dir,
+ tk_inc = os.path.normpath(os.path.join(tk_lib_dir,
'../../include'))
-
+
if ((not os.path.exists(os.path.join(tk_inc,'tk.h'))) and
os.path.exists(os.path.join(tcl_inc,'tk.h'))):
tk_inc = tcl_inc
-
+
if not os.path.exists(tcl_inc):
# this is a hack for suse linux, which is broken
if (sys.platform.startswith('linux') and
@@ -986,7 +991,7 @@
module.include_dirs.extend([tcl_inc, tk_inc])
module.library_dirs.extend([tcl_lib, tk_lib])
module.libraries.extend(['tk' + tk_ver, 'tcl' + tk_ver])
-
+
return message
def add_windowing_flags(module):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-05-02 17:05:24
|
Revision: 5107
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5107&view=rev
Author: mdboom
Date: 2008-05-02 10:05:19 -0700 (Fri, 02 May 2008)
Log Message:
-----------
Don't call sys.exit() when pyemf is not found.
Modified Paths:
--------------
branches/v0_91_maint/CHANGELOG
branches/v0_91_maint/lib/matplotlib/backends/backend_emf.py
Modified: branches/v0_91_maint/CHANGELOG
===================================================================
--- branches/v0_91_maint/CHANGELOG 2008-05-02 17:00:01 UTC (rev 5106)
+++ branches/v0_91_maint/CHANGELOG 2008-05-02 17:05:19 UTC (rev 5107)
@@ -1,3 +1,6 @@
+2008-05-02 Don't call sys.exit() when pyemf is not found [1924199] -
+ MGD
+
2008-05-02 Update _subprocess.c from upstream Python 2.5.2 to get a
few memory and reference-counting-related bugfixes. See
bug 1949978. - MGD
Modified: branches/v0_91_maint/lib/matplotlib/backends/backend_emf.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/backends/backend_emf.py 2008-05-02 17:00:01 UTC (rev 5106)
+++ branches/v0_91_maint/lib/matplotlib/backends/backend_emf.py 2008-05-02 17:05:19 UTC (rev 5107)
@@ -8,9 +8,7 @@
try:
import pyemf
except ImportError:
- import sys
- print >>sys.stderr, 'You must first install pyemf from http://pyemf.sf.net'
- sys.exit()
+ raise ImportError('You must first install pyemf from http://pyemf.sf.net')
import os,sys,math,re
@@ -600,7 +598,7 @@
pass
filetypes = {'emf': 'Enhanced Metafile'}
-
+
def print_emf(self, filename, dpi=300, **kwargs):
width, height = self.figure.get_size_inches()
renderer = RendererEMF(filename,width,height,dpi)
@@ -609,7 +607,7 @@
def get_default_filetype(self):
return 'emf'
-
+
class FigureManagerEMF(FigureManagerBase):
"""
Wrap everything up into a window for the pylab interface
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-05-02 17:00:22
|
Revision: 5106
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5106&view=rev
Author: mdboom
Date: 2008-05-02 10:00:01 -0700 (Fri, 02 May 2008)
Log Message:
-----------
Merged revisions 5102-5105 via svnmerge from
https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v0_91_maint
........
r5104 | mdboom | 2008-05-02 12:55:59 -0400 (Fri, 02 May 2008) | 3 lines
Update _subprocess.c from upstream Python 2.5.2 to get a few memory
and reference-counting-related bugfixes. See bug 1949978. - MGD
........
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/src/_subprocess.c
Property Changed:
----------------
trunk/matplotlib/
Property changes on: trunk/matplotlib
___________________________________________________________________
Name: svnmerge-integrated
- /branches/v0_91_maint:1-5101
+ /branches/v0_91_maint:1-5105
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-05-02 16:57:45 UTC (rev 5105)
+++ trunk/matplotlib/CHANGELOG 2008-05-02 17:00:01 UTC (rev 5106)
@@ -1,3 +1,7 @@
+2008-05-02 Update _subprocess.c from upstream Python 2.5.2 to get a
+ few memory and reference-counting-related bugfixes. See
+ bug 1949978. - MGD
+
2008-04-30 Added some record array editing widgets for gtk -- see
examples/rec_edit*.py - JDH
Modified: trunk/matplotlib/src/_subprocess.c
===================================================================
--- trunk/matplotlib/src/_subprocess.c 2008-05-02 16:57:45 UTC (rev 5105)
+++ trunk/matplotlib/src/_subprocess.c 2008-05-02 17:00:01 UTC (rev 5106)
@@ -104,12 +104,12 @@
{
if (self->handle != INVALID_HANDLE_VALUE)
CloseHandle(self->handle);
- PyMem_DEL(self);
+ PyObject_FREE(self);
}
static PyMethodDef sp_handle_methods[] = {
- {"Detach", (PyCFunction) sp_handle_detach, 1},
- {"Close", (PyCFunction) sp_handle_close, 1},
+ {"Detach", (PyCFunction) sp_handle_detach, METH_VARARGS},
+ {"Close", (PyCFunction) sp_handle_close, METH_VARARGS},
{NULL, NULL}
};
@@ -250,19 +250,23 @@
getint(PyObject* obj, char* name)
{
PyObject* value;
+ int ret;
value = PyObject_GetAttrString(obj, name);
if (! value) {
PyErr_Clear(); /* FIXME: propagate error? */
return 0;
}
- return (int) PyInt_AsLong(value);
+ ret = (int) PyInt_AsLong(value);
+ Py_DECREF(value);
+ return ret;
}
static HANDLE
gethandle(PyObject* obj, char* name)
{
sp_handle_object* value;
+ HANDLE ret;
value = (sp_handle_object*) PyObject_GetAttrString(obj, name);
if (! value) {
@@ -270,8 +274,11 @@
return NULL;
}
if (value->ob_type != &sp_handle_type)
- return NULL;
- return value->handle;
+ ret = NULL;
+ else
+ ret = value->handle;
+ Py_DECREF(value);
+ return ret;
}
static PyObject*
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-05-02 16:57:48
|
Revision: 5105
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5105&view=rev
Author: mdboom
Date: 2008-05-02 09:57:45 -0700 (Fri, 02 May 2008)
Log Message:
-----------
Minor fixes.
Modified Paths:
--------------
trunk/matplotlib/src/_path.cpp
Modified: trunk/matplotlib/src/_path.cpp
===================================================================
--- trunk/matplotlib/src/_path.cpp 2008-05-02 16:55:59 UTC (rev 5104)
+++ trunk/matplotlib/src/_path.cpp 2008-05-02 16:57:45 UTC (rev 5105)
@@ -657,7 +657,8 @@
bisectx(double x) : m_x(x) {}
- void bisect(double sx, double sy, double px, double py, double* bx, double* by) const
+ inline void bisect(double sx, double sy, double px, double py,
+ double* bx, double* by) const
{
*bx = m_x;
double dx = px - sx;
@@ -670,7 +671,7 @@
{
xlt(double x) : bisectx(x) {}
- bool is_inside(double x, double y) const
+ inline bool is_inside(double x, double y) const
{
return x <= m_x;
}
@@ -680,7 +681,7 @@
{
xgt(double x) : bisectx(x) {}
- bool is_inside(double x, double y) const
+ inline bool is_inside(double x, double y) const
{
return x >= m_x;
}
@@ -692,7 +693,7 @@
bisecty(double y) : m_y(y) {}
- void bisect(double sx, double sy, double px, double py, double* bx, double* by) const
+ inline void bisect(double sx, double sy, double px, double py, double* bx, double* by) const
{
*by = m_y;
double dx = px - sx;
@@ -705,7 +706,7 @@
{
ylt(double y) : bisecty(y) {}
- bool is_inside(double x, double y) const
+ inline bool is_inside(double x, double y) const
{
return y <= m_y;
}
@@ -715,7 +716,7 @@
{
ygt(double y) : bisecty(y) {}
- bool is_inside(double x, double y) const
+ inline bool is_inside(double x, double y) const
{
return y >= m_y;
}
@@ -723,7 +724,7 @@
}
template<class Filter>
-void clip_to_rect_one_step(const Polygon& polygon, Polygon& result, const Filter& filter)
+inline void clip_to_rect_one_step(const Polygon& polygon, Polygon& result, const Filter& filter)
{
double sx, sy, px, py, bx, by;
bool sinside, pinside;
@@ -899,8 +900,9 @@
transform = (PyArrayObject*) PyArray_FromObject
(transform_obj.ptr(), PyArray_DOUBLE, 2, 2);
- if (!transform || PyArray_NDIM(transform) != 2 ||
- PyArray_DIM(transform, 0) != 3 || PyArray_DIM(transform, 1) != 3)
+ if (!transform ||
+ PyArray_DIM(transform, 0) != 3 ||
+ PyArray_DIM(transform, 1) != 3)
throw Py::ValueError("Invalid transform.");
double a, b, c, d, e, f;
@@ -964,6 +966,7 @@
Py_XDECREF(vertices);
Py_XDECREF(transform);
Py_XDECREF(result);
+ throw;
}
Py_XDECREF(vertices);
@@ -1020,10 +1023,10 @@
return Py::Int(count);
}
-bool segments_intersect(const double& x1, const double& y1,
- const double& x2, const double& y2,
- const double& x3, const double& y3,
- const double& x4, const double& y4)
+inline bool segments_intersect(const double& x1, const double& y1,
+ const double& x2, const double& y2,
+ const double& x3, const double& y3,
+ const double& x4, const double& y4)
{
double den = ((y4-y3)*(x2-x1)) - ((x4-x3)*(y2-y1));
if (den == 0.0)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-05-02 16:56:11
|
Revision: 5104
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5104&view=rev
Author: mdboom
Date: 2008-05-02 09:55:59 -0700 (Fri, 02 May 2008)
Log Message:
-----------
Update _subprocess.c from upstream Python 2.5.2 to get a few memory
and reference-counting-related bugfixes. See bug 1949978. - MGD
Modified Paths:
--------------
branches/v0_91_maint/CHANGELOG
branches/v0_91_maint/src/_subprocess.c
Modified: branches/v0_91_maint/CHANGELOG
===================================================================
--- branches/v0_91_maint/CHANGELOG 2008-05-01 18:38:28 UTC (rev 5103)
+++ branches/v0_91_maint/CHANGELOG 2008-05-02 16:55:59 UTC (rev 5104)
@@ -1,3 +1,7 @@
+2008-05-02 Update _subprocess.c from upstream Python 2.5.2 to get a
+ few memory and reference-counting-related bugfixes. See
+ bug 1949978. - MGD
+
2008-04-29 Fix bug in mlab.sqrtm - MM
2008-04-28 Fix bug in SVG text with Mozilla-based viewers (the symbol
Modified: branches/v0_91_maint/src/_subprocess.c
===================================================================
--- branches/v0_91_maint/src/_subprocess.c 2008-05-01 18:38:28 UTC (rev 5103)
+++ branches/v0_91_maint/src/_subprocess.c 2008-05-02 16:55:59 UTC (rev 5104)
@@ -104,12 +104,12 @@
{
if (self->handle != INVALID_HANDLE_VALUE)
CloseHandle(self->handle);
- PyMem_DEL(self);
+ PyObject_FREE(self);
}
static PyMethodDef sp_handle_methods[] = {
- {"Detach", (PyCFunction) sp_handle_detach, 1},
- {"Close", (PyCFunction) sp_handle_close, 1},
+ {"Detach", (PyCFunction) sp_handle_detach, METH_VARARGS},
+ {"Close", (PyCFunction) sp_handle_close, METH_VARARGS},
{NULL, NULL}
};
@@ -250,19 +250,23 @@
getint(PyObject* obj, char* name)
{
PyObject* value;
+ int ret;
value = PyObject_GetAttrString(obj, name);
if (! value) {
PyErr_Clear(); /* FIXME: propagate error? */
return 0;
}
- return (int) PyInt_AsLong(value);
+ ret = (int) PyInt_AsLong(value);
+ Py_DECREF(value);
+ return ret;
}
static HANDLE
gethandle(PyObject* obj, char* name)
{
sp_handle_object* value;
+ HANDLE ret;
value = (sp_handle_object*) PyObject_GetAttrString(obj, name);
if (! value) {
@@ -270,8 +274,11 @@
return NULL;
}
if (value->ob_type != &sp_handle_type)
- return NULL;
- return value->handle;
+ ret = NULL;
+ else
+ ret = value->handle;
+ Py_DECREF(value);
+ return ret;
}
static PyObject*
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-05-01 18:38:53
|
Revision: 5103
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5103&view=rev
Author: mdboom
Date: 2008-05-01 11:38:28 -0700 (Thu, 01 May 2008)
Log Message:
-----------
Minor cleanups.
Modified Paths:
--------------
trunk/matplotlib/src/_backend_agg.cpp
Modified: trunk/matplotlib/src/_backend_agg.cpp
===================================================================
--- trunk/matplotlib/src/_backend_agg.cpp 2008-05-01 18:24:54 UTC (rev 5102)
+++ trunk/matplotlib/src/_backend_agg.cpp 2008-05-01 18:38:28 UTC (rev 5103)
@@ -260,7 +260,7 @@
alphaMask = new alpha_mask_type(*alphaMaskRenderingBuffer);
pixfmtAlphaMask = new agg::pixfmt_gray8(*alphaMaskRenderingBuffer);
- rendererBaseAlphaMask = new renderer_base_alpha_mask_type(*pixfmtAlphaMask);
+ rendererBaseAlphaMask = new renderer_base_alpha_mask_type(*pixfmtAlphaMask);
rendererAlphaMask = new renderer_alpha_mask_type(*rendererBaseAlphaMask);
scanlineAlphaMask = new agg::scanline_p8();
}
@@ -424,7 +424,6 @@
return Py::Object();
//throw Py::ValueError("Cannot restore_region from NULL data");
-
agg::rendering_buffer rbuf;
rbuf.attach(region->data,
region->width,
@@ -1434,14 +1433,14 @@
png_write_image(png_ptr, row_pointers);
png_write_end(png_ptr, info_ptr);
- /* Changed calls to png_destroy_write_struct to follow
- http://www.libpng.org/pub/png/libpng-manual.txt.
- This ensures the info_ptr memory is released.
- */
} catch (...) {
if (fp && close_file) fclose(fp);
delete [] row_pointers;
+ /* Changed calls to png_destroy_write_struct to follow
+ http://www.libpng.org/pub/png/libpng-manual.txt.
+ This ensures the info_ptr memory is released.
+ */
if (png_ptr && info_ptr) png_destroy_write_struct(&png_ptr, &info_ptr);
throw;
}
@@ -1477,9 +1476,7 @@
//todo: how to do this with native CXX
- PyObject* o = Py_BuildValue("s#",
- buf_tmp,
- row_len * height);
+ PyObject* o = Py_BuildValue("s#", buf_tmp, row_len * height);
delete [] buf_tmp;
return Py::asObject(o);
}
@@ -1499,18 +1496,13 @@
throw Py::MemoryError("RendererAgg::tostring_argb could not allocate memory");
}
agg::rendering_buffer renderingBufferTmp;
- renderingBufferTmp.attach(buf_tmp,
- width,
- height,
- row_len);
+ renderingBufferTmp.attach(buf_tmp, width, height, row_len);
agg::color_conv(&renderingBufferTmp, renderingBuffer, agg::color_conv_rgba32_to_argb32());
//todo: how to do this with native CXX
- PyObject* o = Py_BuildValue("s#",
- buf_tmp,
- row_len * height);
+ PyObject* o = Py_BuildValue("s#", buf_tmp, row_len * height);
delete [] buf_tmp;
return Py::asObject(o);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-05-01 18:26:57
|
Revision: 5102
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5102&view=rev
Author: mdboom
Date: 2008-05-01 11:24:54 -0700 (Thu, 01 May 2008)
Log Message:
-----------
Merged revisions 5091-5101 via svnmerge from
https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v0_91_maint
........
r5095 | mmetz_bn | 2008-04-29 09:21:48 -0400 (Tue, 29 Apr 2008) | 1 line
fixed bug in mlab.sqrtm; numpy.linalg.eig behaves different than Numeric did
........
r5101 | mdboom | 2008-05-01 14:20:13 -0400 (Thu, 01 May 2008) | 2 lines
Include stdio.h for gcc 4.3
........
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/mlab.py
trunk/matplotlib/ttconv/truetype.h
Property Changed:
----------------
trunk/matplotlib/
Property changes on: trunk/matplotlib
___________________________________________________________________
Name: svnmerge-integrated
- /branches/v0_91_maint:1-5090
+ /branches/v0_91_maint:1-5101
Modified: trunk/matplotlib/lib/matplotlib/mlab.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mlab.py 2008-05-01 18:20:13 UTC (rev 5101)
+++ trunk/matplotlib/lib/matplotlib/mlab.py 2008-05-01 18:24:54 UTC (rev 5102)
@@ -2261,7 +2261,7 @@
if x=='True': return True
elif x=='False': return False
else: raise ValueError('invalid bool')
-
+
dateparser = dateutil.parser.parse
mydateparser = with_default_value(dateparser, datetime.date(1,1,1))
myfloat = with_default_value(float, np.nan)
Modified: trunk/matplotlib/ttconv/truetype.h
===================================================================
--- trunk/matplotlib/ttconv/truetype.h 2008-05-01 18:20:13 UTC (rev 5101)
+++ trunk/matplotlib/ttconv/truetype.h 2008-05-01 18:24:54 UTC (rev 5102)
@@ -4,6 +4,8 @@
* Michael Droettboom
*/
+#include <stdio.h>
+
/*
** ~ppr/src/include/typetype.h
**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-05-01 18:21:20
|
Revision: 5101
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5101&view=rev
Author: mdboom
Date: 2008-05-01 11:20:13 -0700 (Thu, 01 May 2008)
Log Message:
-----------
Include stdio.h for gcc 4.3
Modified Paths:
--------------
branches/v0_91_maint/ttconv/truetype.h
Modified: branches/v0_91_maint/ttconv/truetype.h
===================================================================
--- branches/v0_91_maint/ttconv/truetype.h 2008-04-30 19:53:10 UTC (rev 5100)
+++ branches/v0_91_maint/ttconv/truetype.h 2008-05-01 18:20:13 UTC (rev 5101)
@@ -4,6 +4,8 @@
* Michael Droettboom
*/
+#include <stdio.h>
+
/*
** ~ppr/src/include/typetype.h
**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-04-30 19:53:25
|
Revision: 5100
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5100&view=rev
Author: jdh2358
Date: 2008-04-30 12:53:10 -0700 (Wed, 30 Apr 2008)
Log Message:
-----------
refinements to the rec editors plus examples
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/mlab.py
trunk/matplotlib/lib/mpl_toolkits/gtktools.py
Added Paths:
-----------
trunk/matplotlib/examples/data/demodata.csv
trunk/matplotlib/examples/date_demo.py
trunk/matplotlib/examples/rec_edit_gtk_custom.py
trunk/matplotlib/examples/rec_edit_gtk_simple.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-04-29 21:10:44 UTC (rev 5099)
+++ trunk/matplotlib/CHANGELOG 2008-04-30 19:53:10 UTC (rev 5100)
@@ -1,3 +1,6 @@
+2008-04-30 Added some record array editing widgets for gtk -- see
+ examples/rec_edit*.py - JDH
+
2008-04-29 Fix bug in mlab.sqrtm - MM
2008-04-28 Fix bug in SVG text with Mozilla-based viewers (the symbol
Added: trunk/matplotlib/examples/data/demodata.csv
===================================================================
--- trunk/matplotlib/examples/data/demodata.csv (rev 0)
+++ trunk/matplotlib/examples/data/demodata.csv 2008-04-30 19:53:10 UTC (rev 5100)
@@ -0,0 +1,11 @@
+clientid,date,weekdays,gains,prices,up
+0,2008-04-30,Wed,-0.52458192906686452,7791404.0091921333,False
+1,2008-05-01,Thu,0.076191536201738269,3167180.7366340165,True
+2,2008-05-02,Fri,-0.86850970062880861,9589766.9613829032,False
+3,2008-05-03,Sat,-0.42701083852713395,8949415.1867596991,False
+4,2008-05-04,Sun,0.2532553652693274,937163.44375252665,True
+5,2008-05-05,Mon,-0.68151636911081892,949579.88022264629,False
+6,2008-05-06,Tue,0.0071911579626532168,7268426.906552773,True
+7,2008-05-07,Wed,0.67449747200412147,7517014.782897247,True
+8,2008-05-08,Thu,-1.1841008656818983,1920959.5423492221,False
+9,2008-05-09,Fri,-1.5803692595811152,8456240.6198725495,False
Added: trunk/matplotlib/examples/date_demo.py
===================================================================
--- trunk/matplotlib/examples/date_demo.py (rev 0)
+++ trunk/matplotlib/examples/date_demo.py 2008-04-30 19:53:10 UTC (rev 5100)
@@ -0,0 +1,14 @@
+"""
+Simple example showing how to plot a time series with datetime objects
+"""
+import datetime
+import matplotlib.pyplot as plt
+
+today = datetime.date.today()
+dates = [today+datetime.timedelta(days=i) for i in range(10)]
+
+fig = plt.figure()
+ax = fig.add_subplot(111)
+ax.plot(dates, range(10))
+fig.autofmt_xdate()
+plt.show()
Added: trunk/matplotlib/examples/rec_edit_gtk_custom.py
===================================================================
--- trunk/matplotlib/examples/rec_edit_gtk_custom.py (rev 0)
+++ trunk/matplotlib/examples/rec_edit_gtk_custom.py 2008-04-30 19:53:10 UTC (rev 5100)
@@ -0,0 +1,37 @@
+"""
+generate an editable gtk treeview widget for record arrays with custom
+formatting of the cells and show how to limit string entries to a list
+of strings
+"""
+import gtk
+import numpy as np
+import matplotlib.mlab as mlab
+import mpl_toolkits.gtktools as gtktools
+
+r = mlab.csv2rec('data/demodata.csv', converterd={'weekdays':str})
+
+
+formatd = mlab.get_formatd(r)
+formatd['date'] = mlab.FormatDate('%Y-%m-%d')
+formatd['prices'] = mlab.FormatMillions(precision=1)
+formatd['gain'] = mlab.FormatPercent(precision=2)
+
+# use a drop down combo for weekdays
+stringd = dict(weekdays=['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'])
+constant = ['clientid'] # block editing of this field
+
+
+liststore = gtktools.RecListStore(r, formatd=formatd, stringd=stringd)
+treeview = gtktools.RecTreeView(liststore, constant=constant)
+
+def mycallback(liststore, rownum, colname, oldval, newval):
+ print 'verify: old=%s, new=%s, rec=%s'%(oldval, newval, liststore.r[rownum][colname])
+
+liststore.callbacks.connect('cell_changed', mycallback)
+
+win = gtk.Window()
+win.set_title('click to edit')
+win.add(treeview)
+win.show_all()
+win.connect('delete-event', lambda *args: gtk.main_quit())
+gtk.main()
Added: trunk/matplotlib/examples/rec_edit_gtk_simple.py
===================================================================
--- trunk/matplotlib/examples/rec_edit_gtk_simple.py (rev 0)
+++ trunk/matplotlib/examples/rec_edit_gtk_simple.py 2008-04-30 19:53:10 UTC (rev 5100)
@@ -0,0 +1,15 @@
+"""
+Load a CSV file into a record array and edit it in a gtk treeview
+"""
+
+import gtk
+import numpy as np
+import matplotlib.mlab as mlab
+import mpl_toolkits.gtktools as gtktools
+
+r = mlab.csv2rec('data/demodata.csv', converterd={'weekdays':str})
+
+liststore, treeview, win = gtktools.edit_recarray(r)
+win.set_title('click to edit')
+win.connect('delete-event', lambda *args: gtk.main_quit())
+gtk.main()
Modified: trunk/matplotlib/lib/matplotlib/mlab.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mlab.py 2008-04-29 21:10:44 UTC (rev 5099)
+++ trunk/matplotlib/lib/matplotlib/mlab.py 2008-04-30 19:53:10 UTC (rev 5100)
@@ -2170,7 +2170,7 @@
data type. When set to zero all rows are validated.
converterd, if not None, is a dictionary mapping column number or
- munged column name to a converter function
+ munged column name to a converter function.
names, if not None, is a list of header names. In this case, no
header will be read from the file
@@ -2256,11 +2256,18 @@
return func(val)
return newfunc
+
+ def mybool(x):
+ if x=='True': return True
+ elif x=='False': return False
+ else: raise ValueError('invalid bool')
+
dateparser = dateutil.parser.parse
mydateparser = with_default_value(dateparser, datetime.date(1,1,1))
myfloat = with_default_value(float, np.nan)
myint = with_default_value(int, -1)
mystr = with_default_value(str, '')
+ mybool = with_default_value(mybool, None)
def mydate(x):
# try and return a date object
@@ -2273,7 +2280,7 @@
def get_func(name, item, func):
# promote functions in this order
- funcmap = {myint:myfloat, myfloat:mydate, mydate:mydateparser, mydateparser:mystr}
+ funcmap = {mybool:myint,myint:myfloat, myfloat:mydate, mydate:mydateparser, mydateparser:mystr}
try: func(name, item)
except:
if func==mystr:
@@ -2294,7 +2301,7 @@
converters = None
for i, row in enumerate(reader):
if i==0:
- converters = [myint]*len(row)
+ converters = [mybool]*len(row)
if checkrows and i>checkrows:
break
#print i, len(names), len(row)
@@ -2308,6 +2315,9 @@
func = converters[j]
if len(item.strip()):
func = get_func(name, item, func)
+ else:
+ # how should we handle custom converters and defaults?
+ func = with_default_value(func, None)
converters[j] = func
return converters
@@ -2427,6 +2437,13 @@
def fromstr(self, s):
return int(s)
+class FormatBool(FormatObj):
+ def toval(self, x):
+ return x
+
+ def fromstr(self, s):
+ return bool(s)
+
class FormatPercent(FormatFloat):
def __init__(self, precision=4):
FormatFloat.__init__(self, precision, scale=100.)
@@ -2465,6 +2482,7 @@
defaultformatd = {
+ np.bool_ : FormatBool(),
np.int16 : FormatInt(),
np.int32 : FormatInt(),
np.int64 : FormatInt(),
Modified: trunk/matplotlib/lib/mpl_toolkits/gtktools.py
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/gtktools.py 2008-04-29 21:10:44 UTC (rev 5099)
+++ trunk/matplotlib/lib/mpl_toolkits/gtktools.py 2008-04-30 19:53:10 UTC (rev 5100)
@@ -37,6 +37,49 @@
import matplotlib.cbook as cbook
import matplotlib.mlab as mlab
+
+def error_message(msg, parent=None, title=None):
+ """
+ create an error message dialog with string msg. Optionally set
+ the parent widget and dialog title
+ """
+
+ dialog = gtk.MessageDialog(
+ parent = None,
+ type = gtk.MESSAGE_ERROR,
+ buttons = gtk.BUTTONS_OK,
+ message_format = msg)
+ if parent is not None:
+ dialog.set_transient_for(parent)
+ if title is not None:
+ dialog.set_title(title)
+ else:
+ dialog.set_title('Error!')
+ dialog.show()
+ dialog.run()
+ dialog.destroy()
+ return None
+
+def simple_message(msg, parent=None, title=None):
+ """
+ create a simple message dialog with string msg. Optionally set
+ the parent widget and dialog title
+ """
+ dialog = gtk.MessageDialog(
+ parent = None,
+ type = gtk.MESSAGE_INFO,
+ buttons = gtk.BUTTONS_OK,
+ message_format = msg)
+ if parent is not None:
+ dialog.set_transient_for(parent)
+ if title is not None:
+ dialog.set_title(title)
+ dialog.show()
+ dialog.run()
+ dialog.destroy()
+ return None
+
+
def gtkformat_factory(format, colnum):
"""
copy the format, perform any overrides, and attach an gtk style attrs
@@ -313,6 +356,10 @@
* r - the record array with the edited values
+ * formatd - the list of mlab.FormatObj instances, with gtk attachments
+
+ * stringd - a dict mapping dtype names to a list of valid strings for the combo drop downs
+
* callbacks - a matplotlib.cbook.CallbackRegistry. Connect to the cell_changed with
def mycallback(liststore, rownum, colname, oldval, newval):
@@ -320,85 +367,265 @@
cid = liststore.callbacks.connect('cell_changed', mycallback)
- """
- def __init__(self, r, formatd=None):
+ """
+ def __init__(self, r, formatd=None, stringd=None):
+ """
+ r is a numpy record array
+
+ formatd is a dict mapping dtype name to mlab.FormatObj instances
+
+ stringd, if not None, is a dict mapping dtype names to a list of
+ valid strings for a combo drop down editor
+ """
+
+ if stringd is None:
+ stringd = dict()
+
if formatd is None:
formatd = mlab.get_formatd(r)
+ self.stringd = stringd
self.callbacks = cbook.CallbackRegistry(['cell_changed'])
self.r = r
- gtk.ListStore.__init__(self, *([gobject.TYPE_STRING]*len(r.dtype)))
+
self.headers = r.dtype.names
self.formats = [gtkformat_factory(formatd.get(name, mlab.FormatObj()),i)
for i,name in enumerate(self.headers)]
+
+ # use the gtk attached versions
+ self.formatd = formatd = dict(zip(self.headers, self.formats))
+ types = []
+ for format in self.formats:
+ if isinstance(format, mlab.FormatBool):
+ types.append(gobject.TYPE_BOOLEAN)
+ else:
+ types.append(gobject.TYPE_STRING)
+
+ self.combod = dict()
+ if len(stringd):
+ types.extend([gobject.TYPE_INT]*len(stringd))
+
+ keys = stringd.keys()
+ keys.sort()
+
+ valid = set(r.dtype.names)
+ for ikey, key in enumerate(keys):
+ assert(key in valid)
+ combostore = gtk.ListStore(gobject.TYPE_STRING)
+ for s in stringd[key]:
+ combostore.append([s])
+ self.combod[key] = combostore, len(self.headers)+ikey
+
+
+ gtk.ListStore.__init__(self, *types)
+
for row in r:
- self.append([func.tostr(val) for func, val in zip(self.formats, row)])
+ vals = []
+ for formatter, val in zip(self.formats, row):
+ if isinstance(formatter, mlab.FormatBool):
+ vals.append(val)
+ else:
+ vals.append(formatter.tostr(val))
+ if len(stringd):
+ # todo, get correct index here?
+ vals.extend([0]*len(stringd))
+ self.append(vals)
def position_edited(self, renderer, path, newtext, position):
- self[path][position] = newtext
- format = self.formats[int(position)]
+ position = int(position)
+ format = self.formats[position]
+
rownum = int(path)
- colname = self.headers[int(position)]
+ colname = self.headers[position]
oldval = self.r[rownum][colname]
- newval = format.fromstr(newtext)
+ try: newval = format.fromstr(newtext)
+ except ValueError:
+ msg = cbook.exception_to_str('Error converting "%s"'%newtext)
+ error_message(msg, title='Error')
+ return
self.r[rownum][colname] = newval
+
+ self[path][position] = format.tostr(newval)
+
+
self.callbacks.process('cell_changed', self, rownum, colname, oldval, newval)
-def editable_recarray(r, formatd=None):
+ def position_toggled(self, cellrenderer, path, position):
+ position = int(position)
+ format = self.formats[position]
+
+ newval = not cellrenderer.get_active()
+
+ rownum = int(path)
+ colname = self.headers[position]
+ oldval = self.r[rownum][colname]
+ self.r[rownum][colname] = newval
+
+ self[path][position] = newval
+
+ self.callbacks.process('cell_changed', self, rownum, colname, oldval, newval)
+
+
+
+
+
+class RecTreeView(gtk.TreeView):
"""
- return a (gtk.TreeView, RecListStore) from record array t and
- format dictionary formatd where the keys are record array dtype
- names and the values are matplotlib.mlab.FormatObj instances
+ An editable tree view widget for record arrays
+ """
+ def __init__(self, recliststore, constant=None):
+ """
+ build a gtk.TreeView to edit a RecListStore
- Example:
+ constant, if not None, is a list of dtype names which are not editable
+ """
+ self.recliststore = recliststore
+
+ gtk.TreeView.__init__(self, recliststore)
- formatd = mlab.get_formatd(r)
- formatd['date'] = mlab.FormatDate('%Y-%m-%d')
- formatd['volume'] = mlab.FormatMillions(precision=1)
+ combostrings = set(recliststore.stringd.keys())
- treeview, liststore = gtktools.editable_recarray(r, formatd=formatd)
+
+ if constant is None:
+ constant = []
- def mycallback(liststore, rownum, colname, oldval, newval):
- print 'verify: old=%s, new=%s, rec=%s'%(oldval, newval, liststore.r[rownum][colname])
+ constant = set(constant)
- liststore.callbacks.connect('cell_changed', mycallback)
+ for i, header in enumerate(recliststore.headers):
+ formatter = recliststore.formatd[header]
+ coltype = recliststore.get_column_type(i)
+ if coltype==gobject.TYPE_BOOLEAN:
+ renderer = gtk.CellRendererToggle()
+ if header not in constant:
+ renderer.connect("toggled", recliststore.position_toggled, i)
+ renderer.set_property('activatable', True)
+ elif header in combostrings:
+ renderer = gtk.CellRendererCombo()
+ renderer.connect("edited", recliststore.position_edited, i)
+ combostore, listind = recliststore.combod[header]
+ renderer.set_property("model", combostore)
+ renderer.set_property('editable', True)
+ else:
+ renderer = gtk.CellRendererText()
+ if header not in constant:
+ renderer.connect("edited", recliststore.position_edited, i)
+ renderer.set_property('editable', True)
+
+
+ if formatter is not None:
+ renderer.set_property('xalign', formatter.xalign)
+
+
+
+ tvcol = gtk.TreeViewColumn(header)
+ self.append_column(tvcol)
+ tvcol.pack_start(renderer, True)
+
+ if coltype == gobject.TYPE_STRING:
+ tvcol.add_attribute(renderer, 'text', i)
+ if header in combostrings:
+ combostore, listind = recliststore.combod[header]
+ tvcol.add_attribute(renderer, 'text-column', listind)
+ elif coltype == gobject.TYPE_BOOLEAN:
+ tvcol.add_attribute(renderer, 'active', i)
+
+
+ if formatter is not None and formatter.cell is not None:
+ tvcol.set_cell_data_func(renderer, formatter.cell)
+
+
+
+
+ self.connect("button-release-event", self.on_selection_changed)
+ self.set_grid_lines(gtk.TREE_VIEW_GRID_LINES_BOTH)
+ self.get_selection().set_mode(gtk.SELECTION_BROWSE)
+ self.get_selection().set_select_function(self.on_select)
+
+
+ def on_select(self, *args):
+ return False
+
+ def on_selection_changed(self, *args):
+ (path, col) = self.get_cursor()
+ ren = col.get_cell_renderers()[0]
+ if isinstance(ren, gtk.CellRendererText):
+ self.set_cursor_on_cell(path, col, ren, start_editing=True)
+
+def edit_recarray(r, formatd=None, stringd=None, constant=None, autowin=True):
+ """
+ create a RecListStore and RecTreeView and return them.
+
+ If autowin is True, create a gtk.Window, insert the treeview into
+ it, and return it (return value will be (liststore, treeview, win)
+
+ See RecListStore and RecTreeView for a description of the keyword args
+ """
+
+ liststore = RecListStore(r, formatd=formatd, stringd=stringd)
+ treeview = RecTreeView(liststore, constant=constant)
+
+ if autowin:
win = gtk.Window()
- win.show()
- win.connect('destroy', lambda x: gtk.main_quit())
win.add(treeview)
- gtk.main()
+ win.show_all()
+ return liststore, treeview, win
+ else:
+ return liststore, treeview
+
+
- """
- liststore = RecListStore(r, formatd=formatd)
- treeview = gtk.TreeView()
- if formatd is None:
- formatd = mlab.get_formatd(r)
- for i, header in enumerate(liststore.headers):
- renderer = gtk.CellRendererText()
- renderer.connect("edited", liststore.position_edited, i)
- renderer.set_property('editable', True)
- formatter = gtkformat_factory(formatd.get(header), i)
+if __name__=='__main__':
- if formatter is not None:
- renderer.set_property('xalign', formatter.xalign)
+ import datetime
+ import gtk
+ import numpy as np
+ import matplotlib.mlab as mlab
+ N = 10
+ today = datetime.date.today()
+ dates = [today+datetime.timedelta(days=i) for i in range(N)] # datetimes
+ weekdays = [d.strftime('%a') for d in dates] # strings
+ gains = np.random.randn(N) # floats
+ prices = np.random.rand(N)*1e7 # big numbers
+ up = gains>0 # bools
+ clientid = range(N) # ints
- tvcol = gtk.TreeViewColumn(header)
- treeview.append_column(tvcol)
- tvcol.pack_start(renderer, True)
- tvcol.add_attribute(renderer, 'text', i)
- if formatter is not None and formatter.cell is not None:
- tvcol.set_cell_data_func(renderer, formatter.cell)
+ r = np.rec.fromarrays([clientid, dates, weekdays, gains, prices, up],
+ names='clientid,date,weekdays,gains,prices,up')
+ # some custom formatters
+ formatd = mlab.get_formatd(r)
+ formatd['date'] = mlab.FormatDate('%Y-%m-%d')
+ formatd['prices'] = mlab.FormatMillions(precision=1)
+ formatd['gain'] = mlab.FormatPercent(precision=2)
- treeview.set_model(liststore)
- treeview.show()
- treeview.set_grid_lines(gtk.TREE_VIEW_GRID_LINES_BOTH)
+ # use a drop down combo for weekdays
+ stringd = dict(weekdays=['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'])
+ constant = ['clientid'] # block editing of this field
- return treeview, liststore
+ liststore = RecListStore(r, formatd=formatd, stringd=stringd)
+ treeview = RecTreeView(liststore, constant=constant)
+
+ def mycallback(liststore, rownum, colname, oldval, newval):
+ print 'verify: old=%s, new=%s, rec=%s'%(oldval, newval, liststore.r[rownum][colname])
+
+ liststore.callbacks.connect('cell_changed', mycallback)
+
+ win = gtk.Window()
+ win.set_title('with full customization')
+ win.add(treeview)
+ win.show_all()
+
+ # or you just use the defaults
+ r2 = r.copy()
+ ls, tv, win2 = edit_recarray(r2)
+ win2.set_title('with all defaults')
+
+ gtk.main()
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-04-29 21:10:45
|
Revision: 5099
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5099&view=rev
Author: jdh2358
Date: 2008-04-29 14:10:44 -0700 (Tue, 29 Apr 2008)
Log Message:
-----------
added support for a editable recarray widget in gtk
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/mlab.py
trunk/matplotlib/lib/mpl_toolkits/gtktools.py
Modified: trunk/matplotlib/lib/matplotlib/mlab.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mlab.py 2008-04-29 15:14:36 UTC (rev 5098)
+++ trunk/matplotlib/lib/matplotlib/mlab.py 2008-04-29 21:10:44 UTC (rev 5099)
@@ -2384,6 +2384,8 @@
def toval(self, x):
return str(x)
+ def fromstr(self, s):
+ return s
class FormatString(FormatObj):
def tostr(self, x):
@@ -2402,6 +2404,7 @@
if x is None: return 'None'
return self.fmt%self.toval(x)
+
class FormatFloat(FormatFormatStr):
def __init__(self, precision=4, scale=1.):
FormatFormatStr.__init__(self, '%%1.%df'%precision)
@@ -2413,10 +2416,17 @@
x = x * self.scale
return x
+ def fromstr(self, s):
+ return float(s)/self.scale
+
+
class FormatInt(FormatObj):
def toval(self, x):
return x
+ def fromstr(self, s):
+ return int(s)
+
class FormatPercent(FormatFloat):
def __init__(self, precision=4):
FormatFloat.__init__(self, precision, scale=100.)
@@ -2425,6 +2435,7 @@
def __init__(self, precision=4):
FormatFloat.__init__(self, precision, scale=1e-3)
+
class FormatMillions(FormatFloat):
def __init__(self, precision=4):
FormatFloat.__init__(self, precision, scale=1e-6)
@@ -2438,11 +2449,21 @@
if x is None: return 'None'
return x.strftime(self.fmt)
+ def fromstr(self, x):
+ import dateutil.parser
+ return dateutil.parser.parse(x).date()
+
class FormatDatetime(FormatDate):
def __init__(self, fmt='%Y-%m-%d %H:%M:%S'):
FormatDate.__init__(self, fmt)
+ def fromstr(self, x):
+ import dateutil.parser
+ return dateutil.parser.parse(x)
+
+
+
defaultformatd = {
np.int16 : FormatInt(),
np.int32 : FormatInt(),
Modified: trunk/matplotlib/lib/mpl_toolkits/gtktools.py
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/gtktools.py 2008-04-29 15:14:36 UTC (rev 5098)
+++ trunk/matplotlib/lib/mpl_toolkits/gtktools.py 2008-04-29 21:10:44 UTC (rev 5099)
@@ -8,7 +8,7 @@
import matplotlib.mlab as mlab
import mpl_toolkits.gtktools as gtktools
-
+
r = mlab.csv2rec('somefile.csv', checkrows=0)
formatd = dict(
@@ -46,7 +46,7 @@
cell = None
"""
-
+ if format is None: return None
format = copy.copy(format)
format.xalign = 0.
format.cell = None
@@ -148,6 +148,8 @@
column = gtk.TreeViewColumn(header, renderer, text=i)
renderer.set_property('xalign', formatter.xalign)
+ renderer.set_property('editable', True)
+ renderer.connect("edited", self.position_edited, i)
column.connect('clicked', Clicked(self, i))
column.set_property('clickable', True)
@@ -164,6 +166,10 @@
self.treeview = treeview
self.clear()
+ def position_edited(self, renderer, path, newtext, position):
+ #print path, position
+ self.model[path][position] = newtext
+
def clear(self):
self.iterd = dict()
self.iters = [] # an ordered list of iters
@@ -291,9 +297,108 @@
if autowin:
win = gtk.Window()
win.set_default_size(800,600)
+ #win.set_geometry_hints(scroll)
win.add(scroll)
win.show_all()
scroll.win = win
return scroll
+
+class RecListStore(gtk.ListStore):
+ """
+ A liststore as a model of an editable record array.
+
+ attributes:
+
+ * r - the record array with the edited values
+
+ * callbacks - a matplotlib.cbook.CallbackRegistry. Connect to the cell_changed with
+
+ def mycallback(liststore, rownum, colname, oldval, newval):
+ print 'verify: old=%s, new=%s, rec=%s'%(oldval, newval, liststore.r[rownum][colname])
+
+ cid = liststore.callbacks.connect('cell_changed', mycallback)
+
+ """
+ def __init__(self, r, formatd=None):
+ if formatd is None:
+ formatd = mlab.get_formatd(r)
+
+ self.callbacks = cbook.CallbackRegistry(['cell_changed'])
+
+ self.r = r
+ gtk.ListStore.__init__(self, *([gobject.TYPE_STRING]*len(r.dtype)))
+ self.headers = r.dtype.names
+ self.formats = [gtkformat_factory(formatd.get(name, mlab.FormatObj()),i)
+ for i,name in enumerate(self.headers)]
+ for row in r:
+ self.append([func.tostr(val) for func, val in zip(self.formats, row)])
+
+
+ def position_edited(self, renderer, path, newtext, position):
+ self[path][position] = newtext
+ format = self.formats[int(position)]
+
+ rownum = int(path)
+ colname = self.headers[int(position)]
+ oldval = self.r[rownum][colname]
+ newval = format.fromstr(newtext)
+ self.r[rownum][colname] = newval
+ self.callbacks.process('cell_changed', self, rownum, colname, oldval, newval)
+
+def editable_recarray(r, formatd=None):
+ """
+ return a (gtk.TreeView, RecListStore) from record array t and
+ format dictionary formatd where the keys are record array dtype
+ names and the values are matplotlib.mlab.FormatObj instances
+
+ Example:
+
+ formatd = mlab.get_formatd(r)
+ formatd['date'] = mlab.FormatDate('%Y-%m-%d')
+ formatd['volume'] = mlab.FormatMillions(precision=1)
+
+ treeview, liststore = gtktools.editable_recarray(r, formatd=formatd)
+
+ def mycallback(liststore, rownum, colname, oldval, newval):
+ print 'verify: old=%s, new=%s, rec=%s'%(oldval, newval, liststore.r[rownum][colname])
+
+ liststore.callbacks.connect('cell_changed', mycallback)
+
+
+ win = gtk.Window()
+ win.show()
+ win.connect('destroy', lambda x: gtk.main_quit())
+ win.add(treeview)
+ gtk.main()
+
+ """
+ liststore = RecListStore(r, formatd=formatd)
+ treeview = gtk.TreeView()
+ if formatd is None:
+ formatd = mlab.get_formatd(r)
+ for i, header in enumerate(liststore.headers):
+ renderer = gtk.CellRendererText()
+ renderer.connect("edited", liststore.position_edited, i)
+ renderer.set_property('editable', True)
+
+ formatter = gtkformat_factory(formatd.get(header), i)
+
+ if formatter is not None:
+ renderer.set_property('xalign', formatter.xalign)
+
+ tvcol = gtk.TreeViewColumn(header)
+ treeview.append_column(tvcol)
+ tvcol.pack_start(renderer, True)
+ tvcol.add_attribute(renderer, 'text', i)
+ if formatter is not None and formatter.cell is not None:
+ tvcol.set_cell_data_func(renderer, formatter.cell)
+
+
+ treeview.set_model(liststore)
+ treeview.show()
+ treeview.set_grid_lines(gtk.TREE_VIEW_GRID_LINES_BOTH)
+
+
+ return treeview, liststore
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-04-29 15:15:02
|
Revision: 5098
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5098&view=rev
Author: jdh2358
Date: 2008-04-29 08:14:36 -0700 (Tue, 29 Apr 2008)
Log Message:
-----------
changed numpy abbrev from npy to np
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/art3d.py
trunk/matplotlib/lib/matplotlib/axes.py
trunk/matplotlib/lib/matplotlib/axes3d.py
trunk/matplotlib/lib/matplotlib/axis3d.py
trunk/matplotlib/lib/matplotlib/backend_bases.py
trunk/matplotlib/lib/matplotlib/cbook.py
trunk/matplotlib/lib/matplotlib/cm.py
trunk/matplotlib/lib/matplotlib/collections.py
trunk/matplotlib/lib/matplotlib/colorbar.py
trunk/matplotlib/lib/matplotlib/colors.py
trunk/matplotlib/lib/matplotlib/contour.py
trunk/matplotlib/lib/matplotlib/dates.py
trunk/matplotlib/lib/matplotlib/dviread.py
trunk/matplotlib/lib/matplotlib/finance.py
trunk/matplotlib/lib/matplotlib/image.py
trunk/matplotlib/lib/matplotlib/legend.py
trunk/matplotlib/lib/matplotlib/lines.py
trunk/matplotlib/lib/matplotlib/mlab.py
trunk/matplotlib/lib/matplotlib/patches.py
trunk/matplotlib/lib/matplotlib/path.py
trunk/matplotlib/lib/matplotlib/proj3d.py
trunk/matplotlib/lib/matplotlib/pylab.py
trunk/matplotlib/lib/matplotlib/quiver.py
trunk/matplotlib/lib/matplotlib/scale.py
trunk/matplotlib/lib/matplotlib/texmanager.py
trunk/matplotlib/lib/matplotlib/ticker.py
trunk/matplotlib/lib/matplotlib/transforms.py
trunk/matplotlib/lib/matplotlib/widgets.py
trunk/matplotlib/setupext.py
trunk/matplotlib/src/_backend_agg.cpp
Modified: trunk/matplotlib/lib/matplotlib/art3d.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/art3d.py 2008-04-29 14:22:48 UTC (rev 5097)
+++ trunk/matplotlib/lib/matplotlib/art3d.py 2008-04-29 15:14:36 UTC (rev 5098)
@@ -11,7 +11,7 @@
from colors import Normalize
-import numpy as npy
+import numpy as np
import proj3d
class Wrap2D:
@@ -253,8 +253,8 @@
segis.append((si,ei))
si = ei
xs,ys,zs = zip(*points)
- ones = npy.ones(len(xs))
- self.vec = npy.array([xs,ys,zs,ones])
+ ones = np.ones(len(xs))
+ self.vec = np.array([xs,ys,zs,ones])
self.segis = segis
def draw3d(self, renderer):
@@ -326,7 +326,7 @@
source = image._A
w,h,p = source.shape
X,Y = meshgrid(arange(w),arange(h))
- Z = npy.zeros((w,h))
+ Z = np.zeros((w,h))
tX,tY,tZ = proj3d.transform(X.flat,Y.flat,Z.flat,M)
tX = reshape(tX,(w,h))
tY = reshape(tY,(w,h))
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py 2008-04-29 14:22:48 UTC (rev 5097)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2008-04-29 15:14:36 UTC (rev 5098)
@@ -1,7 +1,7 @@
from __future__ import division, generators
import math, warnings, new
-import numpy as npy
+import numpy as np
from numpy import ma
import matplotlib
@@ -212,16 +212,16 @@
def _xy_from_y(self, y):
if self.axes.yaxis is not None:
b = self.axes.yaxis.update_units(y)
- if b: return npy.arange(len(y)), y, False
+ if b: return np.arange(len(y)), y, False
if not ma.isMaskedArray(y):
- y = npy.asarray(y)
+ y = np.asarray(y)
if len(y.shape) == 1:
- y = y[:,npy.newaxis]
+ y = y[:,np.newaxis]
nr, nc = y.shape
- x = npy.arange(nr)
+ x = np.arange(nr)
if len(x.shape) == 1:
- x = x[:,npy.newaxis]
+ x = x[:,np.newaxis]
return x,y, True
def _xy_from_xy(self, x, y):
@@ -235,18 +235,18 @@
x = ma.asarray(x)
y = ma.asarray(y)
if len(x.shape) == 1:
- x = x[:,npy.newaxis]
+ x = x[:,np.newaxis]
if len(y.shape) == 1:
- y = y[:,npy.newaxis]
+ y = y[:,np.newaxis]
nrx, ncx = x.shape
nry, ncy = y.shape
assert nrx == nry, 'Dimensions of x and y are incompatible'
if ncx == ncy:
return x, y, True
if ncx == 1:
- x = npy.repeat(x, ncy, axis=1)
+ x = np.repeat(x, ncy, axis=1)
if ncy == 1:
- y = npy.repeat(y, ncx, axis=1)
+ y = np.repeat(y, ncx, axis=1)
assert x.shape == y.shape, 'Dimensions of x and y are incompatible'
return x, y, True
@@ -1231,7 +1231,7 @@
# Otherwise, it will compute the bounds of it's current data
# and the data in xydata
if not ma.isMaskedArray(xys):
- xys = npy.asarray(xys)
+ xys = np.asarray(xys)
self.dataLim.update_from_data_xy(xys, self.ignore_existing_data_limits)
self.ignore_existing_data_limits = False
@@ -2071,7 +2071,7 @@
dx = 0.5 * (dx + dy)
dy = dx
- alpha = npy.power(10.0, (dx, dy))
+ alpha = np.power(10.0, (dx, dy))
start = p.trans_inverse.transform_point((p.x, p.y))
lim_points = p.lim.get_points()
result = start + alpha * (lim_points - start)
@@ -2200,7 +2200,7 @@
def dist_x_y(p1, x, y):
'x and y are arrays; return the distance to the closest point'
x1, y1 = p1
- return min(npy.sqrt((x-x1)**2+(y-y1)**2))
+ return min(np.sqrt((x-x1)**2+(y-y1)**2))
def dist(a):
if isinstance(a, Text):
@@ -2217,7 +2217,7 @@
ydata = a.get_ydata(orig=False)
xt, yt = a.get_transform().numerix_x_y(xdata, ydata)
- return dist_x_y(xywin, npy.asarray(xt), npy.asarray(yt))
+ return dist_x_y(xywin, np.asarray(xt), np.asarray(yt))
artists = self.lines + self.patches + self.texts
if callable(among):
@@ -2601,14 +2601,14 @@
if not iterable(y): y = [y]
if not iterable(xmin): xmin = [xmin]
if not iterable(xmax): xmax = [xmax]
- y = npy.asarray(y)
- xmin = npy.asarray(xmin)
- xmax = npy.asarray(xmax)
+ y = np.asarray(y)
+ xmin = np.asarray(xmin)
+ xmax = np.asarray(xmax)
if len(xmin)==1:
- xmin = npy.resize( xmin, y.shape )
+ xmin = np.resize( xmin, y.shape )
if len(xmax)==1:
- xmax = npy.resize( xmax, y.shape )
+ xmax = np.resize( xmax, y.shape )
if len(xmin)!=len(y):
raise ValueError, 'xmin and y are unequal sized sequences'
@@ -2669,26 +2669,26 @@
if not iterable(x): x = [x]
if not iterable(ymin): ymin = [ymin]
if not iterable(ymax): ymax = [ymax]
- x = npy.asarray(x)
- ymin = npy.asarray(ymin)
- ymax = npy.asarray(ymax)
+ x = np.asarray(x)
+ ymin = np.asarray(ymin)
+ ymax = np.asarray(ymax)
if len(ymin)==1:
- ymin = npy.resize( ymin, x.shape )
+ ymin = np.resize( ymin, x.shape )
if len(ymax)==1:
- ymax = npy.resize( ymax, x.shape )
+ ymax = np.resize( ymax, x.shape )
if len(ymin)!=len(x):
raise ValueError, 'ymin and x are unequal sized sequences'
if len(ymax)!=len(x):
raise ValueError, 'ymax and x are unequal sized sequences'
- Y = npy.array([ymin, ymax]).T
+ Y = np.array([ymin, ymax]).T
verts = [ ((thisx, thisymin), (thisx, thisymax))
for thisx, (thisymin, thisymax) in zip(x,Y)]
#print 'creating line collection'
coll = mcoll.LineCollection(verts, colors=colors,
- linestyles=linestyles, label=label)
+ linestyles=linestyles, label=label)
self.add_collection(coll)
coll.update(kwargs)
@@ -3063,19 +3063,19 @@
if Nx!=len(y):
raise ValueError('x and y must be equal length')
- x = detrend(npy.asarray(x))
- y = detrend(npy.asarray(y))
+ x = detrend(np.asarray(x))
+ y = detrend(np.asarray(y))
- c = npy.correlate(x, y, mode=2)
+ c = np.correlate(x, y, mode=2)
- if normed: c/= npy.sqrt(npy.dot(x,x) * npy.dot(y,y))
+ if normed: c/= np.sqrt(np.dot(x,x) * np.dot(y,y))
if maxlags is None: maxlags = Nx - 1
if maxlags >= Nx or maxlags < 1:
raise ValueError('maglags must be None or strictly positive < %d'%Nx)
- lags = npy.arange(-maxlags,maxlags+1)
+ lags = np.arange(-maxlags,maxlags+1)
c = c[Nx-1-maxlags:Nx+maxlags]
@@ -3358,10 +3358,10 @@
# do not convert to array here as unit info is lost
- #left = npy.asarray(left)
- #height = npy.asarray(height)
- #width = npy.asarray(width)
- #bottom = npy.asarray(bottom)
+ #left = np.asarray(left)
+ #height = np.asarray(height)
+ #width = np.asarray(width)
+ #bottom = np.asarray(bottom)
if len(linewidth) == 1: linewidth = linewidth * nbars
@@ -3469,16 +3469,16 @@
if adjust_xlim:
xmin, xmax = self.dataLim.intervalx
- xmin = npy.amin(width)
+ xmin = np.amin(width)
if xerr is not None:
- xmin = xmin - npy.amax(xerr)
+ xmin = xmin - np.amax(xerr)
xmin = max(xmin*0.9, 1e-100)
self.dataLim.intervalx = (xmin, xmax)
if adjust_ylim:
ymin, ymax = self.dataLim.intervaly
- ymin = npy.amin(height)
+ ymin = np.amin(height)
if yerr is not None:
- ymin = ymin - npy.amax(yerr)
+ ymin = ymin - np.amax(yerr)
ymin = max(ymin*0.9, 1e-100)
self.dataLim.intervaly = (ymin, ymax)
self.autoscale_view()
@@ -3596,7 +3596,7 @@
l, = self.plot([thisx,thisx], [0, thisy], linefmt)
stemlines.append(l)
- baseline, = self.plot([npy.amin(x), npy.amax(x)], [0,0], basefmt)
+ baseline, = self.plot([np.amin(x), np.amax(x)], [0,0], basefmt)
self.hold(remember_hold)
@@ -3658,10 +3658,10 @@
"""
self.set_frame_on(False)
- x = npy.asarray(x).astype(npy.float32)
+ x = np.asarray(x).astype(np.float32)
sx = float(x.sum())
- if sx>1: x = npy.divide(x,sx)
+ if sx>1: x = np.divide(x,sx)
if labels is None: labels = ['']*len(x)
if explode is None: explode = [0]*len(x)
@@ -3841,17 +3841,17 @@
# arrays fine here, they are booleans and hence not units
if not iterable(lolims):
- lolims = npy.asarray([lolims]*len(x), bool)
- else: lolims = npy.asarray(lolims, bool)
+ lolims = np.asarray([lolims]*len(x), bool)
+ else: lolims = np.asarray(lolims, bool)
- if not iterable(uplims): uplims = npy.array([uplims]*len(x), bool)
- else: uplims = npy.asarray(uplims, bool)
+ if not iterable(uplims): uplims = np.array([uplims]*len(x), bool)
+ else: uplims = np.asarray(uplims, bool)
- if not iterable(xlolims): xlolims = npy.array([xlolims]*len(x), bool)
- else: xlolims = npy.asarray(xlolims, bool)
+ if not iterable(xlolims): xlolims = np.array([xlolims]*len(x), bool)
+ else: xlolims = np.asarray(xlolims, bool)
- if not iterable(xuplims): xuplims = npy.array([xuplims]*len(x), bool)
- else: xuplims = npy.asarray(xuplims, bool)
+ if not iterable(xuplims): xuplims = np.array([xuplims]*len(x), bool)
+ else: xuplims = np.asarray(xuplims, bool)
def xywhere(xs, ys, mask):
"""
@@ -4032,26 +4032,26 @@
distance = max(positions) - min(positions)
widths = min(0.15*max(distance,1.0), 0.5)
if isinstance(widths, float) or isinstance(widths, int):
- widths = npy.ones((col,), float) * widths
+ widths = np.ones((col,), float) * widths
# loop through columns, adding each to plot
self.hold(True)
for i,pos in enumerate(positions):
- d = npy.ravel(x[i])
+ d = np.ravel(x[i])
row = len(d)
# get median and quartiles
q1, med, q3 = mlab.prctile(d,[25,50,75])
# get high extreme
iq = q3 - q1
hi_val = q3 + whis*iq
- wisk_hi = npy.compress( d <= hi_val , d )
+ wisk_hi = np.compress( d <= hi_val , d )
if len(wisk_hi) == 0:
wisk_hi = q3
else:
wisk_hi = max(wisk_hi)
# get low extreme
lo_val = q1 - whis*iq
- wisk_lo = npy.compress( d >= lo_val, d )
+ wisk_lo = np.compress( d >= lo_val, d )
if len(wisk_lo) == 0:
wisk_lo = q1
else:
@@ -4062,16 +4062,16 @@
flier_hi_x = []
flier_lo_x = []
if len(sym) != 0:
- flier_hi = npy.compress( d > wisk_hi, d )
- flier_lo = npy.compress( d < wisk_lo, d )
- flier_hi_x = npy.ones(flier_hi.shape[0]) * pos
- flier_lo_x = npy.ones(flier_lo.shape[0]) * pos
+ flier_hi = np.compress( d > wisk_hi, d )
+ flier_lo = np.compress( d < wisk_lo, d )
+ flier_hi_x = np.ones(flier_hi.shape[0]) * pos
+ flier_lo_x = np.ones(flier_lo.shape[0]) * pos
# get x locations for fliers, whisker, whisker cap and box sides
box_x_min = pos - widths[i] * 0.5
box_x_max = pos + widths[i] * 0.5
- wisk_x = npy.ones(2) * pos
+ wisk_x = np.ones(2) * pos
cap_x_min = pos - widths[i] * 0.25
cap_x_max = pos + widths[i] * 0.25
@@ -4089,8 +4089,8 @@
med_x = [box_x_min, box_x_max]
# calculate 'notch' plot
else:
- notch_max = med + 1.57*iq/npy.sqrt(row)
- notch_min = med - 1.57*iq/npy.sqrt(row)
+ notch_max = med + 1.57*iq/np.sqrt(row)
+ notch_min = med - 1.57*iq/np.sqrt(row)
if notch_max > q3:
notch_max = q3
if notch_min < q1:
@@ -4267,7 +4267,7 @@
# mapping, not interpretation as rgb or rgba.
if not is_string_like(c):
- sh = npy.shape(c)
+ sh = np.shape(c)
if len(sh) == 1 and sh[0] == len(x):
colors = None # use cmap, norm after collection is created
else:
@@ -4324,7 +4324,7 @@
symstyle = marker[1]
else:
- verts = npy.asarray(marker[0])
+ verts = np.asarray(marker[0])
if sym is not None:
if symstyle==0:
@@ -4357,11 +4357,11 @@
else:
# MGDTODO: This has dpi problems
# rescale verts
- rescale = npy.sqrt(max(verts[:,0]**2+verts[:,1]**2))
+ rescale = np.sqrt(max(verts[:,0]**2+verts[:,1]**2))
verts /= rescale
- scales = npy.asarray(scales)
- scales = npy.sqrt(scales * self.figure.dpi / 72.)
+ scales = np.asarray(scales)
+ scales = np.sqrt(scales * self.figure.dpi / 72.)
if len(scales)==1:
verts = [scales[0]*verts]
else:
@@ -4382,7 +4382,7 @@
if colors is None:
if norm is not None: assert(isinstance(norm, mcolors.Normalize))
if cmap is not None: assert(isinstance(cmap, mcolors.Colormap))
- collection.set_array(npy.asarray(c))
+ collection.set_array(np.asarray(c))
collection.set_cmap(cmap)
collection.set_norm(norm)
@@ -4394,10 +4394,10 @@
temp_x = x
temp_y = y
- minx = npy.amin(temp_x)
- maxx = npy.amax(temp_x)
- miny = npy.amin(temp_y)
- maxy = npy.amax(temp_y)
+ minx = np.amin(temp_x)
+ maxx = np.amax(temp_x)
+ miny = np.amin(temp_y)
+ maxy = np.amax(temp_y)
w = maxx-minx
h = maxy-miny
@@ -4513,16 +4513,16 @@
nx = gridsize
ny = int(nx/math.sqrt(3))
# Count the number of data in each hexagon
- x = npy.array(x, float)
- y = npy.array(y, float)
+ x = np.array(x, float)
+ y = np.array(y, float)
if xscale=='log':
- x = npy.log10(x)
+ x = np.log10(x)
if yscale=='log':
- y = npy.log10(y)
- xmin = npy.amin(x)
- xmax = npy.amax(x)
- ymin = npy.amin(y)
- ymax = npy.amax(y)
+ y = np.log10(y)
+ xmin = np.amin(x)
+ xmax = np.amax(x)
+ ymin = np.amin(y)
+ ymax = np.amax(y)
# In the x-direction, the hexagons exactly cover the region from
# xmin to xmax. Need some padding to avoid roundoff errors.
padding = 1.e-9 * (xmax - xmin)
@@ -4532,17 +4532,17 @@
sy = (ymax-ymin) / ny
x = (x-xmin)/sx
y = (y-ymin)/sy
- ix1 = npy.round(x).astype(int)
- iy1 = npy.round(y).astype(int)
- ix2 = npy.floor(x).astype(int)
- iy2 = npy.floor(y).astype(int)
+ ix1 = np.round(x).astype(int)
+ iy1 = np.round(y).astype(int)
+ ix2 = np.floor(x).astype(int)
+ iy2 = np.floor(y).astype(int)
nx1 = nx + 1
ny1 = ny + 1
nx2 = nx
ny2 = ny
n = nx1*ny1+nx2*ny2
- counts = npy.zeros(n)
+ counts = np.zeros(n)
lattice1 = counts[:nx1*ny1]
lattice2 = counts[nx1*ny1:]
lattice1.shape = (nx1,ny1)
@@ -4558,16 +4558,16 @@
else:
lattice2[ix2[i], iy2[i]]+=1
- px = xmin + sx * npy.array([ 0.5, 0.5, 0.0, -0.5, -0.5, 0.0])
- py = ymin + sy * npy.array([-0.5, 0.5, 1.0, 0.5, -0.5, -1.0]) / 3.0
+ px = xmin + sx * np.array([ 0.5, 0.5, 0.0, -0.5, -0.5, 0.0])
+ py = ymin + sy * np.array([-0.5, 0.5, 1.0, 0.5, -0.5, -1.0]) / 3.0
- polygons = npy.zeros((6, n, 2), float)
- polygons[:,:nx1*ny1,0] = npy.repeat(npy.arange(nx1), ny1)
- polygons[:,:nx1*ny1,1] = npy.tile(npy.arange(ny1), nx1)
- polygons[:,nx1*ny1:,0] = npy.repeat(npy.arange(nx2) + 0.5, ny2)
- polygons[:,nx1*ny1:,1] = npy.tile(npy.arange(ny2), nx2) + 0.5
+ polygons = np.zeros((6, n, 2), float)
+ polygons[:,:nx1*ny1,0] = np.repeat(np.arange(nx1), ny1)
+ polygons[:,:nx1*ny1,1] = np.tile(np.arange(ny1), nx1)
+ polygons[:,nx1*ny1:,0] = np.repeat(np.arange(nx2) + 0.5, ny2)
+ polygons[:,nx1*ny1:,1] = np.tile(np.arange(ny2), nx2) + 0.5
- polygons = npy.transpose(polygons, axes=[1,0,2])
+ polygons = np.transpose(polygons, axes=[1,0,2])
polygons[:,:,0] *= sx
polygons[:,:,1] *= sy
polygons[:,:,0] += px
@@ -4607,13 +4607,13 @@
# Transform the counts if needed
if bins=='log':
- counts = npy.log10(counts+1)
+ counts = np.log10(counts+1)
elif bins!=None:
if not iterable(bins):
minimum, maximum = min(counts), max(counts)
bins-=1 # one less edge than bins
- bins = minimum + (maximum-minimum)*npy.arange(bins)/bins
- bins = npy.sort(bins)
+ bins = minimum + (maximum-minimum)*np.arange(bins)/bins
+ bins = np.sort(bins)
counts = bins.searchsorted(counts)
if norm is not None: assert(isinstance(norm, mcolors.Normalize))
@@ -4847,7 +4847,7 @@
if len(args)==1:
C = args[0]
numRows, numCols = C.shape
- X, Y = npy.meshgrid(npy.arange(numCols+1), npy.arange(numRows+1) )
+ X, Y = np.meshgrid(np.arange(numCols+1), np.arange(numRows+1) )
elif len(args)==3:
X, Y, C = args
else:
@@ -4936,8 +4936,8 @@
Similarly for meshgrid:
- x = npy.arange(5)
- y = npy.arange(3)
+ x = np.arange(5)
+ y = np.arange(3)
X, Y = meshgrid(x,y)
is equivalent to
@@ -4990,8 +4990,8 @@
# don't plot if C or any of the surrounding vertices are masked.
mask = ma.getmaskarray(C)[0:Ny-1,0:Nx-1]+xymask
- newaxis = npy.newaxis
- compress = npy.compress
+ newaxis = np.newaxis
+ compress = np.compress
ravelmask = (mask==0).ravel()
X1 = compress(ravelmask, ma.filled(X[0:-1,0:-1]).ravel())
@@ -5004,7 +5004,7 @@
Y4 = compress(ravelmask, ma.filled(Y[0:-1,1:]).ravel())
npoly = len(X1)
- xy = npy.concatenate((X1[:,newaxis], Y1[:,newaxis],
+ xy = np.concatenate((X1[:,newaxis], Y1[:,newaxis],
X2[:,newaxis], Y2[:,newaxis],
X3[:,newaxis], Y3[:,newaxis],
X4[:,newaxis], Y4[:,newaxis],
@@ -5043,10 +5043,10 @@
x = X.compressed()
y = Y.compressed()
- minx = npy.amin(x)
- maxx = npy.amax(x)
- miny = npy.amin(y)
- maxy = npy.amax(y)
+ minx = np.amin(x)
+ maxx = np.amax(x)
+ miny = np.amin(y)
+ maxy = np.amax(y)
corners = (minx, miny), (maxx, maxy)
self.update_datalim( corners)
@@ -5127,7 +5127,7 @@
X = X.ravel()
Y = Y.ravel()
- coords = npy.zeros(((Nx * Ny), 2), dtype=float)
+ coords = np.zeros(((Nx * Ny), 2), dtype=float)
coords[:, 0] = X
coords[:, 1] = Y
@@ -5151,10 +5151,10 @@
self.grid(False)
- minx = npy.amin(X)
- maxx = npy.amax(X)
- miny = npy.amin(Y)
- maxy = npy.amax(Y)
+ minx = np.amin(X)
+ maxx = np.amax(X)
+ miny = np.amin(Y)
+ maxy = np.amax(Y)
corners = (minx, miny), (maxx, maxy)
self.update_datalim( corners)
@@ -5250,16 +5250,16 @@
y = [0, nr]
elif len(args) == 3:
x, y = args[:2]
- x = npy.asarray(x)
- y = npy.asarray(y)
+ x = np.asarray(x)
+ y = np.asarray(y)
if x.ndim == 1 and y.ndim == 1:
if x.size == 2 and y.size == 2:
style = "image"
else:
- dx = npy.diff(x)
- dy = npy.diff(y)
- if (npy.ptp(dx) < 0.01*npy.abs(dx.mean()) and
- npy.ptp(dy) < 0.01*npy.abs(dy.mean())):
+ dx = np.diff(x)
+ dy = np.diff(y)
+ if (np.ptp(dx) < 0.01*np.abs(dx.mean()) and
+ np.ptp(dy) < 0.01*np.abs(dy.mean())):
style = "image"
else:
style = "pcolorimage"
@@ -5283,7 +5283,7 @@
# The following needs to be cleaned up; the renderer
# requires separate contiguous arrays for X and Y,
# but the QuadMesh class requires the 2D array.
- coords = npy.empty(((Nx * Ny), 2), npy.float64)
+ coords = np.empty(((Nx * Ny), 2), np.float64)
coords[:, 0] = X
coords[:, 1] = Y
@@ -5328,7 +5328,7 @@
ret.set_clim(vmin, vmax)
else:
ret.autoscale_None()
- self.update_datalim(npy.array([[xl, yb], [xr, yt]]))
+ self.update_datalim(np.array([[xl, yb], [xr, yt]]))
self.autoscale_view(tight=True)
return ret
@@ -5427,7 +5427,7 @@
# trapezoidal integration of the probability density function
pdf, bins, patches = ax.hist(...)
- print npy.trapz(pdf, bins)
+ print np.trapz(pdf, bins)
align = 'edge' | 'center'. Interprets bins either as edge
or center values
@@ -5445,7 +5445,7 @@
%(Rectangle)s
"""
if not self._hold: self.cla()
- n, bins = npy.histogram(x, bins, range=None, normed=normed)
+ n, bins = np.histogram(x, bins, range=None, normed=normed)
if width is None: width = 0.9*(bins[1]-bins[0])
if orientation == 'horizontal':
patches = self.barh(bins, n, height=width, left=bottom,
@@ -5498,7 +5498,7 @@
Returns the tuple Pxx, freqs
- For plotting, the power is plotted as 10*npy.log10(pxx) for decibels,
+ For plotting, the power is plotted as 10*np.log10(pxx) for decibels,
though pxx itself is returned
Refs:
@@ -5514,17 +5514,17 @@
pxx.shape = len(freqs),
freqs += Fc
- self.plot(freqs, 10*npy.log10(pxx), **kwargs)
+ self.plot(freqs, 10*np.log10(pxx), **kwargs)
self.set_xlabel('Frequency')
self.set_ylabel('Power Spectrum (dB)')
self.grid(True)
vmin, vmax = self.viewLim.intervaly
intv = vmax-vmin
- logi = int(npy.log10(intv))
+ logi = int(np.log10(intv))
if logi==0: logi=.1
step = 10*logi
#print vmin, vmax, step, intv, math.floor(vmin), math.ceil(vmax)+1
- ticks = npy.arange(math.floor(vmin), math.ceil(vmax)+1, step)
+ ticks = np.arange(math.floor(vmin), math.ceil(vmax)+1, step)
self.set_yticks(ticks)
return pxx, freqs
@@ -5546,7 +5546,7 @@
See the PSD help for a description of the optional parameters.
Returns the tuple Pxy, freqs. Pxy is the cross spectrum (complex
- valued), and 10*npy.log10(|Pxy|) is plotted
+ valued), and 10*np.log10(|Pxy|) is plotted
Refs:
Bendat & Piersol -- Random Data: Analysis and Measurement
@@ -5561,16 +5561,16 @@
# pxy is complex
freqs += Fc
- self.plot(freqs, 10*npy.log10(npy.absolute(pxy)), **kwargs)
+ self.plot(freqs, 10*np.log10(np.absolute(pxy)), **kwargs)
self.set_xlabel('Frequency')
self.set_ylabel('Cross Spectrum Magnitude (dB)')
self.grid(True)
vmin, vmax = self.viewLim.intervaly
intv = vmax-vmin
- step = 10*int(npy.log10(intv))
+ step = 10*int(np.log10(intv))
- ticks = npy.arange(math.floor(vmin), math.ceil(vmax)+1, step)
+ ticks = np.arange(math.floor(vmin), math.ceil(vmax)+1, step)
self.set_yticks(ticks)
return pxy, freqs
@@ -5655,10 +5655,10 @@
window, noverlap)
- Z = 10*npy.log10(Pxx)
- Z = npy.flipud(Z)
+ Z = 10*np.log10(Pxx)
+ Z = np.flipud(Z)
- if xextent is None: xextent = 0, npy.amax(bins)
+ if xextent is None: xextent = 0, np.amax(bins)
xmin, xmax = xextent
freqs += Fc
extent = xmin, xmax, freqs[0], freqs[-1]
@@ -5718,9 +5718,9 @@
if marker is None and markersize is None:
if hasattr(Z, 'tocoo'):
raise TypeError, "Image mode does not support scipy.sparse arrays"
- Z = npy.asarray(Z)
+ Z = np.asarray(Z)
if precision is None: mask = Z!=0.
- else: mask = npy.absolute(Z)>precision
+ else: mask = np.absolute(Z)>precision
if 'cmap' not in kwargs:
kwargs['cmap'] = mcolors.ListedColormap(['w', 'k'], name='binary')
@@ -5735,9 +5735,9 @@
x = c.col
z = c.data
else:
- Z = npy.asarray(Z)
+ Z = np.asarray(Z)
if precision is None: mask = Z!=0.
- else: mask = npy.absolute(Z)>precision
+ else: mask = np.absolute(Z)>precision
y,x,z = mlab.get_xyz_where(mask, mask)
if marker is None: marker = 's'
if markersize is None: markersize = 10
@@ -5780,7 +5780,7 @@
Returns: an image.AxesImage instance
'''
- Z = npy.asarray(Z)
+ Z = np.asarray(Z)
nr, nc = Z.shape
extent = [-0.5, nc-0.5, nr-0.5, -0.5]
kw = {'extent': extent,
Modified: trunk/matplotlib/lib/matplotlib/axes3d.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes3d.py 2008-04-29 14:22:48 UTC (rev 5097)
+++ trunk/matplotlib/lib/matplotlib/axes3d.py 2008-04-29 15:14:36 UTC (rev 5098)
@@ -15,7 +15,7 @@
import cbook
from transforms import unit_bbox
-import numpy as npy
+import numpy as np
from colors import Normalize
import art3d
@@ -184,7 +184,7 @@
pass
def auto_scale_xyz(self, X,Y,Z=None,had_data=None):
- x,y,z = map(npy.asarray, (X,Y,Z))
+ x,y,z = map(np.asarray, (X,Y,Z))
try:
x,y = X.flat,Y.flat
if Z is not None:
@@ -274,7 +274,7 @@
point.
"""
- relev,razim = npy.pi * self.elev/180, npy.pi * self.azim/180
+ relev,razim = np.pi * self.elev/180, np.pi * self.azim/180
xmin,xmax = self.get_w_xlim()
ymin,ymax = self.get_w_ylim()
@@ -286,29 +286,29 @@
zmin,zmax)
# look into the middle of the new coordinates
- R = npy.array([0.5,0.5,0.5])
+ R = np.array([0.5,0.5,0.5])
#
- xp = R[0] + npy.cos(razim)*npy.cos(relev)*self.dist
- yp = R[1] + npy.sin(razim)*npy.cos(relev)*self.dist
- zp = R[2] + npy.sin(relev)*self.dist
+ xp = R[0] + np.cos(razim)*np.cos(relev)*self.dist
+ yp = R[1] + np.sin(razim)*np.cos(relev)*self.dist
+ zp = R[2] + np.sin(relev)*self.dist
- E = npy.array((xp, yp, zp))
+ E = np.array((xp, yp, zp))
#
self.eye = E
self.vvec = R - E
self.vvec = self.vvec / proj3d.mod(self.vvec)
- if abs(relev) > npy.pi/2:
+ if abs(relev) > np.pi/2:
# upside down
- V = npy.array((0,0,-1))
+ V = np.array((0,0,-1))
else:
- V = npy.array((0,0,1))
+ V = np.array((0,0,1))
zfront,zback = -self.dist,self.dist
viewM = proj3d.view_transformation(E,R,V)
perspM = proj3d.persp_transformation(zfront,zback)
- M0 = npy.dot(viewM,worldM)
- M = npy.dot(perspM,M0)
+ M0 = np.dot(viewM,worldM)
+ M = np.dot(perspM,M0)
return M
def mouse_init(self):
@@ -382,8 +382,8 @@
# scale the z value to match
x0,y0,z0 = p0
x1,y1,z1 = p1
- d0 = npy.hypot(x0-xd,y0-yd)
- d1 = npy.hypot(x1-xd,y1-yd)
+ d0 = np.hypot(x0-xd,y0-yd)
+ d1 = np.hypot(x1-xd,y1-yd)
dt = d0+d1
z = d1/dt * z0 + d0/dt * z1
#print 'mid', edgei, d0, d1, z0, z1, z
@@ -503,14 +503,14 @@
had_data = self.has_data()
rows, cols = Z.shape
- tX,tY,tZ = npy.transpose(X), npy.transpose(Y), npy.transpose(Z)
+ tX,tY,tZ = np.transpose(X), np.transpose(Y), np.transpose(Z)
rstride = cbook.popd(kwargs, 'rstride', 10)
cstride = cbook.popd(kwargs, 'cstride', 10)
#
polys = []
boxes = []
- for rs in npy.arange(0,rows-1,rstride):
- for cs in npy.arange(0,cols-1,cstride):
+ for rs in np.arange(0,rows-1,rstride):
+ for cs in np.arange(0,cols-1,cstride):
ps = []
corners = []
for a,ta in [(X,tX),(Y,tY),(Z,tZ)]:
@@ -521,9 +521,9 @@
zright = ta[cs][rs:min(rows,rs+rstride+1):]
zright = zright[::-1]
corners.append([ztop[0],ztop[-1],zbase[0],zbase[-1]])
- z = npy.concatenate((ztop,zleft,zbase,zright))
+ z = np.concatenate((ztop,zleft,zbase,zright))
ps.append(z)
- boxes.append(map(npy.array,zip(*corners)))
+ boxes.append(map(np.array,zip(*corners)))
polys.append(zip(*ps))
#
lines = []
@@ -532,10 +532,10 @@
n = proj3d.cross(box[0]-box[1],
box[0]-box[2])
n = n/proj3d.mod(n)*5
- shade.append(npy.dot(n,[-1,-1,0.5]))
+ shade.append(np.dot(n,[-1,-1,0.5]))
lines.append((box[0],n+box[0]))
#
- color = npy.array([0,0,1,1])
+ color = np.array([0,0,1,1])
norm = Normalize(min(shade),max(shade))
colors = [color * (0.5+norm(v)*0.5) for v in shade]
for c in colors: c[3] = 1
@@ -553,7 +553,7 @@
had_data = self.has_data()
rows,cols = Z.shape
- tX,tY,tZ = npy.transpose(X), npy.transpose(Y), npy.transpose(Z)
+ tX,tY,tZ = np.transpose(X), np.transpose(Y), np.transpose(Z)
rii = [i for i in range(0,rows,rstride)]+[rows-1]
cii = [i for i in range(0,cols,cstride)]+[cols-1]
@@ -718,8 +718,8 @@
def get_test_data(delta=0.05):
from mlab import bivariate_normal
- x = y = npy.arange(-3.0, 3.0, delta)
- X, Y = npy.meshgrid(x,y)
+ x = y = np.arange(-3.0, 3.0, delta)
+ X, Y = np.meshgrid(x,y)
Z1 = bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
Z2 = bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
@@ -764,8 +764,8 @@
def test_plot():
ax = Axes3D()
- xs = npy.arange(0,4*npy.pi+0.1,0.1)
- ys = npy.sin(xs)
+ xs = np.arange(0,4*np.pi+0.1,0.1)
+ ys = np.sin(xs)
ax.plot(xs,ys, label='zl')
ax.plot(xs,ys+max(xs),label='zh')
ax.plot(xs,ys,dir='x', label='xl')
@@ -785,7 +785,7 @@
cc = lambda arg: colorConverter.to_rgba(arg, alpha=0.6)
ax = Axes3D()
- xs = npy.arange(0,10,0.4)
+ xs = np.arange(0,10,0.4)
verts = []
zs = [0.0,1.0,2.0,3.0]
for z in zs:
@@ -817,7 +817,7 @@
ax = Axes3D()
for c,z in zip(['r','g','b','y'],[30,20,10,0]):
- xs = npy.arange(20)
+ xs = np.arange(20)
ys = [random.random() for x in xs]
ax.bar(xs,ys,z=z,dir='y',color=c)
#ax.plot(xs,ys)
Modified: trunk/matplotlib/lib/matplotlib/axis3d.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axis3d.py 2008-04-29 14:22:48 UTC (rev 5097)
+++ trunk/matplotlib/lib/matplotlib/axis3d.py 2008-04-29 15:14:36 UTC (rev 5098)
@@ -13,7 +13,7 @@
import art3d
import proj3d
-import numpy as npy
+import numpy as np
def norm_angle(a):
"""Return angle between -180 and +180"""
@@ -51,8 +51,8 @@
# Compute the dash end points
# The 'c' prefix is for canvas coordinates
- cxy = npy.array(transform.xy_tup((x, y)))
- cd = npy.array([cos_theta, sin_theta])
+ cxy = np.array(transform.xy_tup((x, y)))
+ cd = np.array([cos_theta, sin_theta])
c1 = cxy+dashpush*cd
c2 = cxy+(dashpush+dashlength)*cd
(x1, y1) = transform.inverse_xy_tup(tuple(c1))
@@ -75,9 +75,9 @@
# well enough yet.
we = self._mytext.get_window_extent(renderer=renderer)
w, h = we.width(), we.height()
- off = npy.array([cos_theta*(w/2+2)-1,sin_theta*(h+1)-1])
- off = npy.array([cos_theta*(w/2),sin_theta*(h/2)])
- dir = npy.array([cos_theta,sin_theta])*dashpad
+ off = np.array([cos_theta*(w/2+2)-1,sin_theta*(h+1)-1])
+ off = np.array([cos_theta*(w/2),sin_theta*(h/2)])
+ dir = np.array([cos_theta,sin_theta])*dashpad
cw = c2 + off +dir
self._mytext.set_position(transform.inverse_xy_tup(tuple(cw)))
Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backend_bases.py 2008-04-29 14:22:48 UTC (rev 5097)
+++ trunk/matplotlib/lib/matplotlib/backend_bases.py 2008-04-29 15:14:36 UTC (rev 5098)
@@ -6,7 +6,7 @@
from __future__ import division
import os
-import numpy as npy
+import numpy as np
import matplotlib.cbook as cbook
import matplotlib.colors as colors
import matplotlib._image as _image
@@ -122,10 +122,10 @@
meshWidth, meshHeight, coordinates)
if showedges:
- edgecolors = npy.array([[0.0, 0.0, 0.0, 1.0]], npy.float_)
+ edgecolors = np.array([[0.0, 0.0, 0.0, 1.0]], np.float_)
else:
edgecolors = facecolors
- linewidths = npy.array([1.0], npy.float_)
+ linewidths = np.array([1.0], np.float_)
return self.draw_path_collection(
master_transform, cliprect, clippath, clippath_trans,
@@ -1569,7 +1569,7 @@
a.set_ylim((y0, y1))
elif self._button_pressed == 3:
if a.get_xscale()=='log':
- alpha=npy.log(Xmax/Xmin)/npy.log(x1/x0)
+ alpha=np.log(Xmax/Xmin)/np.log(x1/x0)
rx1=pow(Xmin/x0,alpha)*Xmin
rx2=pow(Xmax/x0,alpha)*Xmin
else:
@@ -1577,7 +1577,7 @@
rx1=alpha*(Xmin-x0)+Xmin
rx2=alpha*(Xmax-x0)+Xmin
if a.get_yscale()=='log':
- alpha=npy.log(Ymax/Ymin)/npy.log(y1/y0)
+ alpha=np.log(Ymax/Ymin)/np.log(y1/y0)
ry1=pow(Ymin/y0,alpha)*Ymin
ry2=pow(Ymax/y0,alpha)*Ymin
else:
Modified: trunk/matplotlib/lib/matplotlib/cbook.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/cbook.py 2008-04-29 14:22:48 UTC (rev 5097)
+++ trunk/matplotlib/lib/matplotlib/cbook.py 2008-04-29 15:14:36 UTC (rev 5098)
@@ -5,7 +5,7 @@
from __future__ import generators
import re, os, errno, sys, StringIO, traceback, locale
import time, datetime
-import numpy as npy
+import numpy as np
try:
set = set
@@ -856,7 +856,7 @@
class MemoryMonitor:
def __init__(self, nmax=20000):
self._nmax = nmax
- self._mem = npy.zeros((self._nmax,), npy.int32)
+ self._mem = np.zeros((self._nmax,), np.int32)
self.clear()
def clear(self):
@@ -892,7 +892,7 @@
print "Warning: array size was too small for the number of calls."
def xy(self, i0=0, isub=1):
- x = npy.arange(i0, self._n, isub)
+ x = np.arange(i0, self._n, isub)
return x, self._mem[i0:self._n:isub]
def plot(self, i0=0, isub=1, fig=None):
@@ -1051,11 +1051,11 @@
def simple_linear_interpolation(a, steps):
- steps = npy.floor(steps)
+ steps = np.floor(steps)
new_length = ((len(a) - 1) * steps) + 1
new_shape = list(a.shape)
new_shape[0] = new_length
- result = npy.zeros(new_shape, a.dtype)
+ result = np.zeros(new_shape, a.dtype)
result[0] = a[0]
a0 = a[0:-1]
Modified: trunk/matplotlib/lib/matplotlib/cm.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/cm.py 2008-04-29 14:22:48 UTC (rev 5097)
+++ trunk/matplotlib/lib/matplotlib/cm.py 2008-04-29 15:14:36 UTC (rev 5098)
@@ -2,7 +2,7 @@
This module contains the instantiations of color mapping classes
"""
-import numpy as npy
+import numpy as np
from numpy import ma
import matplotlib as mpl
import matplotlib.colors as colors
@@ -56,18 +56,18 @@
try:
if x.ndim == 3:
if x.shape[2] == 3:
- if x.dtype == npy.uint8:
- alpha = npy.array(alpha*255, npy.uint8)
+ if x.dtype == np.uint8:
+ alpha = np.array(alpha*255, np.uint8)
m, n = x.shape[:2]
- xx = npy.empty(shape=(m,n,4), dtype = x.dtype)
+ xx = np.empty(shape=(m,n,4), dtype = x.dtype)
xx[:,:,:3] = x
xx[:,:,3] = alpha
elif x.shape[2] == 4:
xx = x
else:
raise ValueError("third dimension must be 3 or 4")
- if bytes and xx.dtype != npy.uint8:
- xx = (xx * 255).astype(npy.uint8)
+ if bytes and xx.dtype != np.uint8:
+ xx = (xx * 255).astype(np.uint8)
return xx
except AttributeError:
pass
Modified: trunk/matplotlib/lib/matplotlib/collections.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/collections.py 2008-04-29 14:22:48 UTC (rev 5097)
+++ trunk/matplotlib/lib/matplotlib/collections.py 2008-04-29 15:14:36 UTC (rev 5098)
@@ -8,7 +8,7 @@
line segemnts)
"""
import math, warnings
-import numpy as npy
+import numpy as np
import matplotlib as mpl
import matplotlib.cbook as cbook
import matplotlib.colors as _colors # avoid conflict with kwarg
@@ -51,7 +51,7 @@
draw time a call to scalar mappable will be made to set the face
colors.
"""
- _offsets = npy.array([], npy.float_)
+ _offsets = np.array([], np.float_)
_transOffset = transforms.IdentityTransform()
_transforms = []
@@ -84,11 +84,11 @@
self.set_antialiased(antialiaseds)
self._uniform_offsets = None
- self._offsets = npy.array([], npy.float_)
+ self._offsets = np.array([], np.float_)
if offsets is not None:
- offsets = npy.asarray(offsets, npy.float_)
+ offsets = np.asarray(offsets, np.float_)
if len(offsets.shape) == 1:
- offsets = offsets[npy.newaxis,:] # Make it Nx2.
+ offsets = offsets[np.newaxis,:] # Make it Nx2.
if transOffset is not None:
Affine2D = transforms.Affine2D
self._offsets = offsets
@@ -137,7 +137,7 @@
if not transOffset.is_affine:
offsets = transOffset.transform_non_affine(offsets)
transOffset = transOffset.get_affine()
- offsets = npy.asarray(offsets, npy.float_)
+ offsets = np.asarray(offsets, np.float_)
result = mpath.get_path_collection_extents(
transform.frozen(), paths, self.get_transforms(),
@@ -166,7 +166,7 @@
ys = self.convert_yunits(self._offsets[:1])
offsets = zip(xs, ys)
- offsets = npy.asarray(offsets, npy.float_)
+ offsets = np.asarray(offsets, np.float_)
self.update_scalarmappable()
@@ -206,7 +206,7 @@
ind = mpath.point_in_path_collection(
mouseevent.x, mouseevent.y, self._pickradius,
transform.frozen(), paths, self.get_transforms(),
- npy.asarray(self._offsets, npy.float_),
+ np.asarray(self._offsets, np.float_),
self._transOffset.frozen(), len(self._facecolors))
return len(ind)>0,dict(ind=ind)
@@ -424,7 +424,7 @@
# By converting to floats now, we can avoid that on every draw.
self._coordinates = self._coordinates.reshape((meshHeight + 1, meshWidth + 1, 2))
- self._coordinates = npy.array(self._coordinates, npy.float_)
+ self._coordinates = np.array(self._coordinates, np.float_)
def get_paths(self, dataTrans=None):
if self._paths is None:
@@ -439,11 +439,11 @@
c = coordinates
# We could let the Path constructor generate the codes for us,
# but this is faster, since we know they'll always be the same
- codes = npy.array(
+ codes = np.array(
[Path.MOVETO, Path.LINETO, Path.LINETO, Path.LINETO, Path.CLOSEPOLY],
Path.code_type)
- points = npy.concatenate((
+ points = np.concatenate((
c[0:-1, 0:-1],
c[0:-1, 1: ],
c[1: , 1: ],
@@ -470,7 +470,7 @@
ys = self.convert_yunits(self._offsets[:1])
offsets = zip(xs, ys)
- offsets = npy.asarray(offsets, npy.float_)
+ offsets = np.asarray(offsets, np.float_)
if self.check_update('array'):
self.update_scalarmappable()
@@ -556,8 +556,8 @@
Example: see examples/dynamic_collection.py for complete example
- offsets = npy.random.rand(20,2)
- facecolors = [cm.jet(x) for x in npy.random.rand(20)]
+ offsets = np.random.rand(20,2)
+ facecolors = [cm.jet(x) for x in np.random.rand(20)]
black = (0,0,0,1)
collection = RegularPolyCollection(
@@ -584,7 +584,7 @@
# in points^2
self._transforms = [
transforms.Affine2D().rotate(-self._rotation).scale(
- (npy.sqrt(x) * renderer.dpi / 72.0) / npy.sqrt(npy.pi))
+ (np.sqrt(x) * renderer.dpi / 72.0) / np.sqrt(np.pi))
for x in self._sizes]
return Collection.draw(self, renderer)
@@ -679,7 +679,7 @@
pickradius=pickradius,
**kwargs)
- self._facecolors = npy.array([])
+ self._facecolors = np.array([])
self.set_segments(segments)
def get_paths(self):
@@ -687,7 +687,7 @@
def set_segments(self, segments):
if segments is None: return
- segments = [npy.asarray(seg, npy.float_) for seg in segments]
+ segments = [np.asarray(seg, np.float_) for seg in segments]
if self._uniform_offsets is not None:
segments = self._add_offsets(segments)
self._paths = [mpath.Path(seg) for seg in segments]
Modified: trunk/matplotlib/lib/matplotlib/colorbar.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/colorbar.py 2008-04-29 14:22:48 UTC (rev 5097)
+++ trunk/matplotlib/lib/matplotlib/colorbar.py 2008-04-29 15:14:36 UTC (rev 5098)
@@ -15,7 +15,7 @@
'''
-import numpy as npy
+import numpy as np
import matplotlib as mpl
import matplotlib.colors as colors
import matplotlib.cm as cm
@@ -185,7 +185,7 @@
self._process_values()
self._find_range()
X, Y = self._mesh()
- C = self._values[:,npy.newaxis]
+ C = self._values[:,np.newaxis]
self._config_axes(X, Y)
if self.filled:
self._add_solids(X, Y, C)
@@ -248,13 +248,13 @@
'''
N = X.shape[0]
ii = [0, 1, N-2, N-1, 2*N-1, 2*N-2, N+1, N, 0]
- x = npy.take(npy.ravel(npy.transpose(X)), ii)
- y = npy.take(npy.ravel(npy.transpose(Y)), ii)
+ x = np.take(np.ravel(np.transpose(X)), ii)
+ y = np.take(np.ravel(np.transpose(Y)), ii)
x = x.reshape((len(x), 1))
y = y.reshape((len(y), 1))
if self.orientation == 'horizontal':
- return npy.hstack((y, x))
- return npy.hstack((x, y))
+ return np.hstack((y, x))
+ return np.hstack((x, y))
def _edges(self, X, Y):
'''
@@ -276,7 +276,7 @@
if self.orientation == 'vertical':
args = (X, Y, C)
else:
- args = (npy.transpose(Y), npy.transpose(X), npy.transpose(C))
+ args = (np.transpose(Y), np.transpose(X), np.transpose(C))
kw = {'cmap':self.cmap, 'norm':self.norm,
'shading':'flat', 'alpha':self.alpha}
# Save, set, and restore hold state to keep pcolor from
@@ -303,8 +303,8 @@
dummy, y = self._locate(levels)
if len(y) <> N:
raise ValueError("levels are outside colorbar range")
- x = npy.array([0.0, 1.0])
- X, Y = npy.meshgrid(x,y)
+ x = np.array([0.0, 1.0])
+ X, Y = np.meshgrid(x,y)
if self.orientation == 'vertical':
xy = [zip(X[i], Y[i]) for i in range(N)]
else:
@@ -348,7 +348,7 @@
locator.set_data_interval(*intv)
formatter.set_view_interval(*intv)
formatter.set_data_interval(*intv)
- b = npy.array(locator())
+ b = np.array(locator())
b, ticks = self._locate(b)
formatter.set_locs(b)
ticklabels = [formatter(t, i) for i, t in enumerate(b)]
@@ -364,32 +364,32 @@
if b is None:
b = self.boundaries
if b is not None:
- self._boundaries = npy.asarray(b, dtype=float)
+ self._boundaries = np.asarray(b, dtype=float)
if self.values is None:
self._values = 0.5*(self._boundaries[:-1]
+ self._boundaries[1:])
if isinstance(self.norm, colors.NoNorm):
- self._values = (self._values + 0.00001).astype(npy.int16)
+ self._values = (self._values + 0.00001).astype(np.int16)
return
- self._values = npy.array(self.values)
+ self._values = np.array(self.values)
return
if self.values is not None:
- self._values = npy.array(self.values)
+ self._values = np.array(self.values)
if self.boundaries is None:
- b = npy.zeros(len(self.values)+1, 'd')
+ b = np.zeros(len(self.values)+1, 'd')
b[1:-1] = 0.5*(self._values[:-1] - self._values[1:])
b[0] = 2.0*b[1] - b[2]
b[-1] = 2.0*b[-2] - b[-3]
self._boundaries = b
return
- self._boundaries = npy.array(self.boundaries)
+ self._boundaries = np.array(self.boundaries)
return
# Neither boundaries nor values are specified;
# make reasonable ones based on cmap and norm.
if isinstance(self.norm, colors.NoNorm):
b = self._uniform_y(self.cmap.N+1) * self.cmap.N - 0.5
- v = npy.zeros((len(b)-1,), dtype=npy.int16)
- v[self._inside] = npy.arange(self.cmap.N, dtype=npy.int16)
+ v = np.zeros((len(b)-1,), dtype=np.int16)
+ v[self._inside] = np.arange(self.cmap.N, dtype=np.int16)
if self.extend in ('both', 'min'):
v[0] = -1
if self.extend in ('both', 'max'):
@@ -403,8 +403,8 @@
b = [b[0]-1] + b
if self.extend in ('both', 'max'):
b = b + [b[-1] + 1]
- b = npy.array(b)
- v = npy.zeros((len(b)-1,), dtype=float)
+ b = np.array(b)
+ v = np.zeros((len(b)-1,), dtype=float)
bi = self.norm.boundaries
v[self._inside] = 0.5*(bi[:-1] + bi[1:])
if self.extend in ('both', 'min'):
@@ -461,19 +461,19 @@
spaced boundaries, plus ends if required.
'''
if self.extend == 'neither':
- y = npy.linspace(0, 1, N)
+ y = np.linspace(0, 1, N)
else:
if self.extend == 'both':
- y = npy.zeros(N + 2, 'd')
+ y = np.zeros(N + 2, 'd')
y[0] = -0.05
y[-1] = 1.05
elif self.extend == 'min':
- y = npy.zeros(N + 1, 'd')
+ y = np.zeros(N + 1, 'd')
y[0] = -0.05
else:
- y = npy.zeros(N + 1, 'd')
+ y = np.zeros(N + 1, 'd')
y[-1] = 1.05
- y[self._inside] = npy.linspace(0, 1, N)
+ y[self._inside] = np.linspace(0, 1, N)
return y
def _proportional_y(self):
@@ -503,13 +503,13 @@
transposition for a horizontal colorbar are done outside
this function.
'''
- x = npy.array([0.0, 1.0])
+ x = np.array([0.0, 1.0])
if self.spacing == 'uniform':
y = self._uniform_y(self._central_N())
else:
y = self._proportional_y()
self._y = y
- X, Y = npy.meshgrid(x,y)
+ X, Y = np.meshgrid(x,y)
if self.extend in ('min', 'both'):
X[0,:] = 0.5
if self.extend in ('max', 'both'):
@@ -535,19 +535,19 @@
# floating point errors.
xn = self.norm(x, clip=False).filled()
in_cond = (xn > -0.001) & (xn < 1.001)
- xn = npy.compress(in_cond, xn)
- xout = npy.compress(in_cond, x)
+ xn = np.compress(in_cond, xn)
+ xout = np.compress(in_cond, x)
# The rest is linear interpolation with clipping.
y = self._y
N = len(b)
- ii = npy.minimum(npy.searchsorted(b, xn), N-1)
- i0 = npy.maximum(ii - 1, 0)
+ ii = np.minimum(np.searchsorted(b, xn), N-1)
+ i0 = np.maximum(ii - 1, 0)
#db = b[ii] - b[i0]
- db = npy.take(b, ii) - npy.take(b, i0)
- db = npy.where(i0==ii, 1.0, db)
+ db = np.take(b, ii) - np.take(b, i0)
+ db = np.where(i0==ii, 1.0, db)
#dy = y[ii] - y[i0]
- dy = npy.take(y, ii) - npy.take(y, i0)
- z = npy.take(y, i0) + (xn-npy.take(b,i0))*dy/db
+ dy = np.take(y, ii) - np.take(y, i0)
+ z = np.take(y, i0) + (xn-np.take(b,i0))*dy/db
return xout, z
def set_alpha(self, alpha):
Modified: trunk/matplotlib/lib/matplotlib/colors.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/colors.py 2008-04-29 14:22:48 UTC (rev 5097)
+++ trunk/matplotlib/lib/matplotlib/colors.py 2008-04-29 15:14:36 UTC (rev 5098)
@@ -34,7 +34,7 @@
'chartreuse' are supported.
"""
import re
-import numpy as npy
+import numpy as np
from numpy import ma
import matplotlib.cbook as cbook
@@ -320,23 +320,23 @@
"""
try:
if c.lower() == 'none':
- return npy.zeros((0,4), dtype=npy.float_)
+ return np.zeros((0,4), dtype=np.float_)
except AttributeError:
pass
if len(c) == 0:
- return npy.zeros((0,4), dtype=npy.float_)
+ return np.zeros((0,4), dtype=np.float_)
try:
result = [self.to_rgba(c, alpha)]
except ValueError:
# If c is a list it must be maintained as the same list
# with modified items so that items can be appended to
# it. This is needed for examples/dynamic_collections.py.
- if not isinstance(c, (list, npy.ndarray)): # specific; don't need duck-typing
+ if not isinstance(c, (list, np.ndarray)): # specific; don't need duck-typing
c = list(c)
for i, cc in enumerate(c):
c[i] = self.to_rgba(cc, alpha) # change in place
result = c
- return npy.asarray(result, npy.float_)
+ return np.asarray(result, np.float_)
colorConverter = ColorConverter()
@@ -358,7 +358,7 @@
gives the closest value for values of x between 0 and 1.
"""
try:
- adata = npy.array(data)
+ adata = np.array(data)
except:
raise TypeError("data must be convertable to an array")
shape = adata.shape
@@ -372,21 +372,21 @@
if x[0] != 0. or x[-1] != 1.0:
raise ValueError(
"data mapping points must start with x=0. and end with x=1")
- if npy.sometrue(npy.sort(x)-x):
+ if np.sometrue(np.sort(x)-x):
raise ValueError(
"data mapping points must have x in increasing order")
# begin generation of lookup table
x = x * (N-1)
- lut = npy.zeros((N,), npy.float)
- xind = npy.arange(float(N))
- ind = npy.searchsorted(x, xind)[1:-1]
+ lut = np.zeros((N,), np.float)
+ xind = np.arange(float(N))
+ ind = np.searchsorted(x, xind)[1:-1]
lut[1:-1] = ( ((xind[1:-1] - x[ind-1]) / (x[ind] - x[ind-1]))
* (y0[ind] - y1[ind-1]) + y1[ind-1])
lut[0] = y1[0]
lut[-1] = y0[-1]
# ensure that the lut is confined to values between 0 and 1 by clipping it
- npy.clip(lut, 0.0, 1.0)
+ np.clip(lut, 0.0, 1.0)
#lut = where(lut > 1., 1., lut)
#lut = where(lut < 0., 0., lut)
return lut
@@ -437,26 +437,26 @@
mask_bad = None
if not cbook.iterable(X):
vtype = 'scalar'
- xa = npy.array([X])
+ xa = np.array([X])
else:
vtype = 'array'
xma = ma.asarray(X)
xa = xma.filled(0)
mask_bad = ma.getmask(xma)
- if xa.dtype.char in npy.typecodes['Float']:
- npy.putmask(xa, xa==1.0, 0.9999999) #Treat 1.0 as slightly less than 1.
+ if xa.dtype.char in np.typecodes['Float']:
+ np.putmask(xa, xa==1.0, 0.9999999) #Treat 1.0 as slightly less than 1.
xa = (xa * self.N).astype(int)
# Set the over-range indices before the under-range;
# otherwise the under-range values get converted to over-range.
- npy.putmask(xa, xa>self.N-1, self._i_over)
- npy.putmask(xa, xa<0, self._i_under)
+ np.putmask(xa, xa>self.N-1, self._i_over)
+ np.putmask(xa, xa<0, self._i_under)
if mask_bad is not None and mask_bad.shape == xa.shape:
- npy.putmask(xa, mask_bad, self._i_bad)
+ np.putmask(xa, mask_bad, self._i_bad)
if bytes:
- lut = (self._lut * 255).astype(npy.uint8)
+ lut = (self._lut * 255).astype(np.uint8)
else:
lut = self._lut
- rgba = npy.empty(shape=xa.shape+(4,), dtype=lut.dtype)
+ rgba = np.empty(shape=xa.shape+(4,), dtype=lut.dtype)
lut.take(xa, axis=0, mode='clip', out=rgba)
# twice as fast as lut[xa];
# using the clip or wrap mode and providing an
@@ -501,8 +501,8 @@
raise NotImplementedError("Abstract class only")
def is_gray(self):
- return (npy.alltrue(self._lut[:,0] == self._lut[:,1])
- and npy.alltrue(self._lut[:,0] == self._lut[:,2]))
+ return (np.alltrue(self._lut[:,0] == self._lut[:,1])
+ and np.alltrue(self._lut[:,0] == self._lut[:,2]))
class LinearSegmentedColormap(Colormap):
@@ -527,7 +527,7 @@
self._segmentdata = segmentdata
def _init(self):
- self._lut = npy.ones((self.N + 3, 4), npy.float)
+ self._lut = np.ones((self.N + 3, 4), np.float)
self._lut[:-3, 0] = makeMappingArray(self.N, self._segmentdata['red'])
self._lut[:-3, 1] = makeMappingArray(self.N, self._segmentdata['green'])
self._lut[:-3, 2] = makeMappingArray(self.N, self._segmentdata['blue'])
@@ -579,9 +579,9 @@
def _init(self):
- rgb = npy.array([colorConverter.to_rgb(c)
- for c in self.colors], npy.float)
- self._lut = npy.zeros((self.N + 3, 4), npy.float)
+ rgb = np.array([colorConverter.to_rgb(c)
+ for c in self.colors], np.float)
+ self._lut = np.zeros((self.N + 3, 4), np.float)
self._lut[:-3, :-1] = rgb
self._lut[:-3, -1] = 1
self._isinit = True
@@ -615,10 +615,10 @@
if cbook.iterable(value):
vtype = 'array'
- val = ma.asarray(value).astype(npy.float)
+ val = ma.asarray(value).astype(np.float)
else:
vtype = 'scalar'
- val = ma.array([value]).astype(npy.float)
+ val = ma.array([value]).astype(np.float)
self.autoscale_None(val)
vmin, vmax = self.vmin, self.vmax
@@ -629,7 +629,7 @@
else:
if clip:
mask = ma.getmask(val)
- val = ma.array(npy.clip(val.filled(vmax), vmin, vmax),
+ val = ma.array(np.clip(val.filled(vmax), vmin, vmax),
mask=mask)
result = (val-vmin) * (1.0/(vmax-vmin))
if vtype == 'scalar':
@@ -674,10 +674,10 @@
if cbook.iterable(value):
vtype = 'array'
- val = ma.asarray(value).astype(npy.float)
+ val = ma.asarray(value).astype(np.float)
else:
vtype = 'scalar'
- val = ma.array([value]).astype(npy.float)
+ val = ma.array([value]).astype(np.float)
self.autoscale_None(val)
vmin, vmax = self.vmin, self.vmax
@@ -690,9 +690,9 @@
else:
if clip:
mask = ma.getmask(val)
- val = ma.array(npy.clip(val.filled(vmax), vmin, vmax),
+ val = ma.array(np.clip(val.filled(vmax), vmin, vmax),
mask=mask)
- result = (ma.log(val)-npy.log(vmin))/(npy.log(vmax)-npy.log(vmin))
+ result = (ma.log(val)-np.log(vmin))/(np.log(vmax)-np.log(vmin))
if vtype == 'scalar':
result = result[0]
return result
@@ -737,7 +737,7 @@
self.clip = clip
self.vmin = boundari...
[truncated message content] |
|
From: <md...@us...> - 2008-04-29 14:24:06
|
Revision: 5097
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5097&view=rev
Author: mdboom
Date: 2008-04-29 07:22:48 -0700 (Tue, 29 Apr 2008)
Log Message:
-----------
Check the return value of fwrite (and eliminate gcc 4.x warnings)
Modified Paths:
--------------
trunk/matplotlib/src/_backend_agg.cpp
Modified: trunk/matplotlib/src/_backend_agg.cpp
===================================================================
--- trunk/matplotlib/src/_backend_agg.cpp 2008-04-29 13:35:47 UTC (rev 5096)
+++ trunk/matplotlib/src/_backend_agg.cpp 2008-04-29 14:22:48 UTC (rev 5097)
@@ -1300,12 +1300,16 @@
const char *file_name = fileName.c_str();
if ((fp = fopen(file_name, "wb")) == NULL)
throw Py::RuntimeError( Printf("Could not open file %s", file_name).str() );
- fwrite(pixBuffer, 1, NUMBYTES, fp);
+ if (fwrite(pixBuffer, 1, NUMBYTES, fp) != NUMBYTES) {
+ fclose(fp);
+ throw Py::RuntimeError( Printf("Error writing to file %s", file_name).str() );
+ }
close_file = true;
- fclose(fp);
} else if (PyFile_CheckExact(py_fileobj.ptr())) {
fp = PyFile_AsFile(py_fileobj.ptr());
- fwrite(pixBuffer, 1, NUMBYTES, fp);
+ if (fwrite(pixBuffer, 1, NUMBYTES, fp) != NUMBYTES) {
+ throw Py::RuntimeError( "Error writing to file" );
+ }
} else {
PyObject* write_method = PyObject_GetAttrString(py_fileobj.ptr(), "write");
if (!(write_method && PyCallable_Check(write_method))) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mme...@us...> - 2008-04-29 13:35:52
|
Revision: 5096
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5096&view=rev
Author: mmetz_bn
Date: 2008-04-29 06:35:47 -0700 (Tue, 29 Apr 2008)
Log Message:
-----------
fixed bug in mlab.sqrtm; numpy.linalg.eig behaves different than Numeric did
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/mlab.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-04-29 13:21:48 UTC (rev 5095)
+++ trunk/matplotlib/CHANGELOG 2008-04-29 13:35:47 UTC (rev 5096)
@@ -1,3 +1,5 @@
+2008-04-29 Fix bug in mlab.sqrtm - MM
+
2008-04-28 Fix bug in SVG text with Mozilla-based viewers (the symbol
tag is not supported) - MGD
Modified: trunk/matplotlib/lib/matplotlib/mlab.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mlab.py 2008-04-29 13:21:48 UTC (rev 5095)
+++ trunk/matplotlib/lib/matplotlib/mlab.py 2008-04-29 13:35:47 UTC (rev 5096)
@@ -1901,7 +1901,7 @@
def sqrtm(x):
"""
Returns the square root of a square matrix.
- This means that s=sqrtm(x) implies s*s = x.
+ This means that s=sqrtm(x) implies dot(s,s) = x.
Note that s and x are matrices.
"""
return mfuncC(npy.sqrt, x)
@@ -1914,9 +1914,10 @@
"""
x = npy.asarray(x)
- (v, u) = npy.linalg.eig(x)
- uT = u.transpose()
+ (v,uT) = npy.linalg.eig(x)
V = npy.diag(f(v+0j))
+ # todo: warning: this is not exactly what matlab does
+ # MATLAB "B/A is roughly the same as B*inv(A)"
y = npy.dot(uT, npy.dot(V, npy.linalg.inv(uT)))
return approx_real(y)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mme...@us...> - 2008-04-29 13:22:29
|
Revision: 5095
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5095&view=rev
Author: mmetz_bn
Date: 2008-04-29 06:21:48 -0700 (Tue, 29 Apr 2008)
Log Message:
-----------
fixed bug in mlab.sqrtm; numpy.linalg.eig behaves different than Numeric did
Modified Paths:
--------------
branches/v0_91_maint/CHANGELOG
branches/v0_91_maint/lib/matplotlib/mlab.py
Modified: branches/v0_91_maint/CHANGELOG
===================================================================
--- branches/v0_91_maint/CHANGELOG 2008-04-28 19:17:31 UTC (rev 5094)
+++ branches/v0_91_maint/CHANGELOG 2008-04-29 13:21:48 UTC (rev 5095)
@@ -1,3 +1,5 @@
+2008-04-29 Fix bug in mlab.sqrtm - MM
+
2008-04-28 Fix bug in SVG text with Mozilla-based viewers (the symbol
tag is not supported) - MGD
Modified: branches/v0_91_maint/lib/matplotlib/mlab.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/mlab.py 2008-04-28 19:17:31 UTC (rev 5094)
+++ branches/v0_91_maint/lib/matplotlib/mlab.py 2008-04-29 13:21:48 UTC (rev 5095)
@@ -1901,7 +1901,7 @@
def sqrtm(x):
"""
Returns the square root of a square matrix.
- This means that s=sqrtm(x) implies s*s = x.
+ This means that s=sqrtm(x) implies dot(s,s) = x.
Note that s and x are matrices.
"""
return mfuncC(npy.sqrt, x)
@@ -1914,9 +1914,10 @@
"""
x = npy.asarray(x)
- (v, u) = npy.linalg.eig(x)
- uT = u.transpose()
+ (v,uT) = npy.linalg.eig(x)
V = npy.diag(f(v+0j))
+ # todo: warning: this is not exactly what matlab does
+ # MATLAB "B/A is roughly the same as B*inv(A)"
y = npy.dot(uT, npy.dot(V, npy.linalg.inv(uT)))
return approx_real(y)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mme...@us...> - 2008-04-28 19:19:52
|
Revision: 5094
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5094&view=rev
Author: mmetz_bn
Date: 2008-04-28 12:17:31 -0700 (Mon, 28 Apr 2008)
Log Message:
-----------
npy usage
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/axes.py
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py 2008-04-28 18:26:08 UTC (rev 5093)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2008-04-28 19:17:31 UTC (rev 5094)
@@ -4519,14 +4519,13 @@
x = npy.log10(x)
if yscale=='log':
y = npy.log10(y)
- xmin = min(x)
- xmax = max(x)
- ymin = min(y)
- ymax = max(y)
+ xmin = npy.amin(x)
+ xmax = npy.amax(x)
+ ymin = npy.amin(y)
+ ymax = npy.amax(y)
# In the x-direction, the hexagons exactly cover the region from
# xmin to xmax. Need some padding to avoid roundoff errors.
- width = xmax - xmin
- padding = 1.e-9 * width
+ padding = 1.e-9 * (xmax - xmin)
xmin -= padding
xmax += padding
sx = (xmax-xmin) / nx
@@ -4551,21 +4550,22 @@
d1 = (x-ix1)**2 + 3.0 * (y-iy1)**2
d2 = (x-ix2-0.5)**2 + 3.0 * (y-iy2-0.5)**2
+ bdist = (d1<d2)
for i in xrange(len(x)):
- if d1[i] < d2[i]:
+ if bdist[i]:
lattice1[ix1[i], iy1[i]]+=1
else:
lattice2[ix2[i], iy2[i]]+=1
px = xmin + sx * npy.array([ 0.5, 0.5, 0.0, -0.5, -0.5, 0.0])
- py = ymin + sy * npy.array([-0.5, 0.5 ,1.0, 0.5, -0.5, -1.0]) / 3.0
+ py = ymin + sy * npy.array([-0.5, 0.5, 1.0, 0.5, -0.5, -1.0]) / 3.0
polygons = npy.zeros((6, n, 2), float)
polygons[:,:nx1*ny1,0] = npy.repeat(npy.arange(nx1), ny1)
- polygons[:,:nx1*ny1,1] = npy.array(range(ny1) * nx1)
+ polygons[:,:nx1*ny1,1] = npy.tile(npy.arange(ny1), nx1)
polygons[:,nx1*ny1:,0] = npy.repeat(npy.arange(nx2) + 0.5, ny2)
- polygons[:,nx1*ny1:,1] = npy.array(range(ny2) * nx2) + 0.5
+ polygons[:,nx1*ny1:,1] = npy.tile(npy.arange(ny2), nx2) + 0.5
polygons = npy.transpose(polygons, axes=[1,0,2])
polygons[:,:,0] *= sx
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ef...@us...> - 2008-04-28 18:27:25
|
Revision: 5093
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5093&view=rev
Author: efiring
Date: 2008-04-28 11:26:08 -0700 (Mon, 28 Apr 2008)
Log Message:
-----------
Add hexbin_demo, and use log10 for log in hexbin
Modified Paths:
--------------
trunk/matplotlib/examples/backend_driver.py
trunk/matplotlib/lib/matplotlib/axes.py
Added Paths:
-----------
trunk/matplotlib/examples/hexbin_demo.py
Modified: trunk/matplotlib/examples/backend_driver.py
===================================================================
--- trunk/matplotlib/examples/backend_driver.py 2008-04-28 16:52:44 UTC (rev 5092)
+++ trunk/matplotlib/examples/backend_driver.py 2008-04-28 18:26:08 UTC (rev 5093)
@@ -49,6 +49,7 @@
'fill_demo.py',
'finance_demo.py',
'fonts_demo_kw.py',
+ 'hexbin_demo.py',
'histogram_demo.py',
'hline_demo.py',
'image_demo.py',
Added: trunk/matplotlib/examples/hexbin_demo.py
===================================================================
--- trunk/matplotlib/examples/hexbin_demo.py (rev 0)
+++ trunk/matplotlib/examples/hexbin_demo.py 2008-04-28 18:26:08 UTC (rev 5093)
@@ -0,0 +1,34 @@
+'''
+hexbin is an axes method or pyplot function that is essentially
+a pcolor of a 2-D histogram with hexagonal cells. It can be
+much more informative than a scatter plot; in the first subplot
+below, try substituting 'scatter' for 'hexbin'.
+'''
+
+from matplotlib.pyplot import *
+import numpy as np
+
+n = 100000
+x = np.random.standard_normal(n)
+y = 2.0 + 3.0 * x + 4.0 * np.random.standard_normal(n)
+xmin = x.min()
+xmax = x.max()
+ymin = y.min()
+ymax = y.max()
+
+subplot(121)
+hexbin(x,y)
+axis([xmin, xmax, ymin, ymax])
+title("Hexagon binning")
+cb = colorbar()
+cb.set_label('counts')
+
+subplot(122)
+hexbin(x,y,bins='log')
+axis([xmin, xmax, ymin, ymax])
+title("With a log color scale")
+cb = colorbar()
+cb.set_label('log10(N)')
+
+show()
+
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py 2008-04-28 16:52:44 UTC (rev 5092)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2008-04-28 18:26:08 UTC (rev 5093)
@@ -4447,7 +4447,7 @@
each hexagon directly corresponds to its count
value.
bins='log' : Use a logarithmic scale for the color map.
- Internally, log(count+1) is used to determine
+ Internally, log10(count+1) is used to determine
the hexagon color.
bins=<integer> : Divide the counts in the specified number of
bins, and color the hexagons accordingly
@@ -4456,10 +4456,10 @@
to be used.
* xscale = 'linear' | 'log':
- Use a logarithmic scale on the horizontal axis.
+ Use a log10 scale on the horizontal axis.
* yscale = 'linear' | 'log':
- Use a logarithmic scale on the vertical axis.
+ Use a log10 scale on the vertical axis.
Other keyword args; the color mapping and normalization arguments.
@@ -4516,9 +4516,9 @@
x = npy.array(x, float)
y = npy.array(y, float)
if xscale=='log':
- x = npy.log(x)
+ x = npy.log10(x)
if yscale=='log':
- y = npy.log(y)
+ y = npy.log10(y)
xmin = min(x)
xmax = max(x)
ymin = min(y)
@@ -4574,14 +4574,14 @@
polygons[:,:,1] += py
if xscale=='log':
- polygons[:,:,0] = npy.exp(polygons[:,:,0])
- xmin = math.exp(xmin)
- xmax = math.exp(xmax)
+ polygons[:,:,0] = 10**(polygons[:,:,0])
+ xmin = 10**xmin
+ xmax = 10**xmax
self.set_xscale('log')
if yscale=='log':
- polygons[:,:,1] = npy.exp(polygons[:,:,1])
- ymin = math.exp(ymin)
- ymax = math.exp(ymax)
+ polygons[:,:,1] = 10**(polygons[:,:,1])
+ ymin = 10**ymin
+ ymax = 10**ymax
self.set_yscale('log')
class HexagonBinCollection(mcoll.PolyCollection):
@@ -4607,7 +4607,7 @@
# Transform the counts if needed
if bins=='log':
- counts = npy.log(counts+1)
+ counts = npy.log10(counts+1)
elif bins!=None:
if not iterable(bins):
minimum, maximum = min(counts), max(counts)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-04-28 17:16:02
|
Revision: 5092
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5092&view=rev
Author: mdboom
Date: 2008-04-28 09:52:44 -0700 (Mon, 28 Apr 2008)
Log Message:
-----------
Removing SVN conflict marker.
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-04-28 14:19:06 UTC (rev 5091)
+++ trunk/matplotlib/CHANGELOG 2008-04-28 16:52:44 UTC (rev 5092)
@@ -14,7 +14,6 @@
2008-04-24 Fix compilation issues on VS2003 (Thanks Martin Spacek for
all the help) - MGD
->>>>>>> .merge-right.r5090
2008-04-24 Fix sub/superscripts when the size of the font has been
changed - MGD
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-04-28 14:19:25
|
Revision: 5091
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5091&view=rev
Author: mdboom
Date: 2008-04-28 07:19:06 -0700 (Mon, 28 Apr 2008)
Log Message:
-----------
Merged revisions 5069-5090 via svnmerge from
https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v0_91_maint
........
r5088 | mdboom | 2008-04-28 09:07:41 -0400 (Mon, 28 Apr 2008) | 2 lines
Fix SVG text rendering bug affecting Mozilla-based viewers.
........
r5089 | mdboom | 2008-04-28 09:41:28 -0400 (Mon, 28 Apr 2008) | 3 lines
Fix bug where fraction beams were too wide at lower dpi's. Fix
sub/superscript placement at different dpi's.
........
r5090 | mdboom | 2008-04-28 09:49:50 -0400 (Mon, 28 Apr 2008) | 2 lines
Oops in last commit -- left in debugging info.
........
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/backends/backend_svg.py
trunk/matplotlib/lib/matplotlib/mathtext.py
Property Changed:
----------------
trunk/matplotlib/
Property changes on: trunk/matplotlib
___________________________________________________________________
Name: svnmerge-integrated
- /branches/v0_91_maint:1-5068
+ /branches/v0_91_maint:1-5090
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-04-28 13:49:50 UTC (rev 5090)
+++ trunk/matplotlib/CHANGELOG 2008-04-28 14:19:06 UTC (rev 5091)
@@ -1,3 +1,6 @@
+2008-04-28 Fix bug in SVG text with Mozilla-based viewers (the symbol
+ tag is not supported) - MGD
+
2008-04-27 Applied patch by Michiel de Hoon to add hexbin
axes method and pyplot function - EF
@@ -11,6 +14,7 @@
2008-04-24 Fix compilation issues on VS2003 (Thanks Martin Spacek for
all the help) - MGD
+>>>>>>> .merge-right.r5090
2008-04-24 Fix sub/superscripts when the size of the font has been
changed - MGD
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_svg.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2008-04-28 13:49:50 UTC (rev 5090)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2008-04-28 14:19:06 UTC (rev 5091)
@@ -401,7 +401,7 @@
currx, curry = step[-2], -step[-1]
path_data = ''.join(path_data)
char_num = 'c_%s' % md5.new(path_data).hexdigest()
- path_element = '<symbol id="%s"><path d="%s"/></symbol>\n' % (char_num, ''.join(path_data))
+ path_element = '<path id="%s" d="%s"/>\n' % (char_num, ''.join(path_data))
self._char_defs[char_id] = char_num
return path_element
Modified: trunk/matplotlib/lib/matplotlib/mathtext.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mathtext.py 2008-04-28 13:49:50 UTC (rev 5090)
+++ trunk/matplotlib/lib/matplotlib/mathtext.py 2008-04-28 14:19:06 UTC (rev 5091)
@@ -651,12 +651,12 @@
# Some fonts don't store the xHeight, so we do a poor man's xHeight
metrics = self.get_metrics(font, 'it', 'x', fontsize, dpi)
return metrics.iceberg
- xHeight = (pclt['xHeight'] / 64.0) * (fontsize / 12.0)
+ xHeight = (pclt['xHeight'] / 64.0) * (fontsize / 12.0) * (dpi / 100.0)
return xHeight
def get_underline_thickness(self, font, fontsize, dpi):
cached_font = self._get_font(font)
- return max(1.0, cached_font.font.underline_thickness / 64.0 / fontsize * 10.0)
+ return cached_font.font.underline_thickness / 64.0 / fontsize * (10.0 * dpi / 100.0)
def get_kern(self, font1, fontclass1, sym1, fontsize1,
font2, fontclass2, sym2, fontsize2, dpi):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-04-28 13:50:02
|
Revision: 5090
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5090&view=rev
Author: mdboom
Date: 2008-04-28 06:49:50 -0700 (Mon, 28 Apr 2008)
Log Message:
-----------
Oops in last commit -- left in debugging info.
Modified Paths:
--------------
branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py
Modified: branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py 2008-04-28 13:41:28 UTC (rev 5089)
+++ branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py 2008-04-28 13:49:50 UTC (rev 5090)
@@ -390,7 +390,6 @@
currx, curry = step[-2], -step[-1]
path_data = ''.join(path_data)
char_num = 'c_%s' % md5.new(path_data).hexdigest()
- char_num = len(self._char_defs)
path_element = '<path id="%s" d="%s"/>\n' % (char_num, ''.join(path_data))
self._char_defs[char_id] = char_num
return path_element
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-04-28 13:41:36
|
Revision: 5089
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5089&view=rev
Author: mdboom
Date: 2008-04-28 06:41:28 -0700 (Mon, 28 Apr 2008)
Log Message:
-----------
Fix bug where fraction beams were too wide at lower dpi's. Fix
sub/superscript placement at different dpi's.
Modified Paths:
--------------
branches/v0_91_maint/lib/matplotlib/mathtext.py
Modified: branches/v0_91_maint/lib/matplotlib/mathtext.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/mathtext.py 2008-04-28 13:07:41 UTC (rev 5088)
+++ branches/v0_91_maint/lib/matplotlib/mathtext.py 2008-04-28 13:41:28 UTC (rev 5089)
@@ -651,12 +651,12 @@
# Some fonts don't store the xHeight, so we do a poor man's xHeight
metrics = self.get_metrics(font, 'it', 'x', fontsize, dpi)
return metrics.iceberg
- xHeight = (pclt['xHeight'] / 64.0) * (fontsize / 12.0)
+ xHeight = (pclt['xHeight'] / 64.0) * (fontsize / 12.0) * (dpi / 100.0)
return xHeight
def get_underline_thickness(self, font, fontsize, dpi):
cached_font = self._get_font(font)
- return max(1.0, cached_font.font.underline_thickness / 64.0 / fontsize * 10.0)
+ return cached_font.font.underline_thickness / 64.0 / fontsize * (10.0 * dpi / 100.0)
def get_kern(self, font1, fontclass1, sym1, fontsize1,
font2, fontclass2, sym2, fontsize2, dpi):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-04-28 13:08:42
|
Revision: 5088
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5088&view=rev
Author: mdboom
Date: 2008-04-28 06:07:41 -0700 (Mon, 28 Apr 2008)
Log Message:
-----------
Fix SVG text rendering bug affecting Mozilla-based viewers.
Modified Paths:
--------------
branches/v0_91_maint/CHANGELOG
branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py
Modified: branches/v0_91_maint/CHANGELOG
===================================================================
--- branches/v0_91_maint/CHANGELOG 2008-04-28 11:31:19 UTC (rev 5087)
+++ branches/v0_91_maint/CHANGELOG 2008-04-28 13:07:41 UTC (rev 5088)
@@ -1,3 +1,6 @@
+2008-04-28 Fix bug in SVG text with Mozilla-based viewers (the symbol
+ tag is not supported) - MGD
+
2008-04-24 Fix sub/superscripts when the size of the font has been
changed - MGD
Modified: branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py 2008-04-28 11:31:19 UTC (rev 5087)
+++ branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py 2008-04-28 13:07:41 UTC (rev 5088)
@@ -390,7 +390,8 @@
currx, curry = step[-2], -step[-1]
path_data = ''.join(path_data)
char_num = 'c_%s' % md5.new(path_data).hexdigest()
- path_element = '<symbol id="%s"><path d="%s"/></symbol>\n' % (char_num, ''.join(path_data))
+ char_num = len(self._char_defs)
+ path_element = '<path id="%s" d="%s"/>\n' % (char_num, ''.join(path_data))
self._char_defs[char_id] = char_num
return path_element
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mme...@us...> - 2008-04-28 11:31:28
|
Revision: 5087
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5087&view=rev
Author: mmetz_bn
Date: 2008-04-28 04:31:19 -0700 (Mon, 28 Apr 2008)
Log Message:
-----------
array of indices as integers in hexbin
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/axes.py
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py 2008-04-28 07:41:25 UTC (rev 5086)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2008-04-28 11:31:19 UTC (rev 5087)
@@ -4533,10 +4533,10 @@
sy = (ymax-ymin) / ny
x = (x-xmin)/sx
y = (y-ymin)/sy
- ix1 = npy.round(x)
- iy1 = npy.round(y)
- ix2 = npy.floor(x)
- iy2 = npy.floor(y)
+ ix1 = npy.round(x).astype(int)
+ iy1 = npy.round(y).astype(int)
+ ix2 = npy.floor(x).astype(int)
+ iy2 = npy.floor(y).astype(int)
nx1 = nx + 1
ny1 = ny + 1
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|