Skip to content

Commit dad281b

Browse files
committed
2.2 fixes
svn path=/trunk/matplotlib/; revision=709
1 parent 34b6e9e commit dad281b

File tree

6 files changed

+58
-38
lines changed

6 files changed

+58
-38
lines changed

examples/backend_driver.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,24 +47,37 @@
4747
'multiple_figs_demo.py',
4848
'pcolor_demo.py',
4949
'pcolor_demo2.py',
50-
'pcolor_small.py',
50+
'pcolor_small.py',
51+
'polar_demo.py',
52+
'polar_scatter.py',
5153
'psd_demo.py',
5254
'scatter_demo.py',
5355
'scatter_demo2.py',
5456
'simple_plot.py',
5557
'specgram_demo.py',
5658
'stock_demo.py',
5759
'subplot_demo.py',
60+
# 'set_and_get.py',
5861
'table_demo.py',
5962
'text_handles.py',
6063
'text_themes.py',
6164
'two_scales.py',
6265
'vline_demo.py',
6366
)
6467

65-
def drive(backend):
6668

69+
#tests known to fail on python22 (require datetime)
70+
fail22 = (
71+
'date_demo1.py',
72+
'date_demo2.py',
73+
'finance_demo.py',
74+
)
75+
def drive(backend, python='python2.3'):
76+
6777
for fname in files:
78+
if python=='python2.2' and fname in fail22:
79+
print '\tSkipping %s, known to fail on python2.2'%fname
80+
continue
6881
lines = [
6982
'from __future__ import division\n',
7083
'import matplotlib\n',
@@ -84,18 +97,19 @@ def drive(backend):
8497
lines.append('savefig("%s", dpi=150)' % outfile)
8598
tmpfile = '_tmp_%s.py' % basename
8699
file(tmpfile, 'w').write(''.join(lines))
87-
os.system('python %s' % tmpfile)
100+
os.system('%s %s' % (python, tmpfile))
88101

89102
times = {}
90103
backends = ['PS', 'GD', 'Paint', 'Agg', 'Template']
91104
#backends.extend([ 'GTK', 'WX', 'TkAgg'])
92105
#backends = [ 'Agg']
93106
backends = [ 'SVG', 'PS', 'Agg', 'Template']
94107

108+
python = 'python2.3'
95109
for backend in backends:
96110
print 'testing %s' % backend
97111
t0 = time.time()
98-
drive(backend)
112+
drive(backend, python)
99113
t1 = time.time()
100114
times[backend] = (t1-t0)/60.0
101115

examples/set_and_get.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,5 @@
9292
set(t)
9393
print 'Text getters'
9494
get(t)
95+
96+
show()

lib/matplotlib/axes.py

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from artist import Artist
1010
from axis import XAxis, YAxis
1111
from cbook import iterable, is_string_like, flatten, enumerate, True, False,\
12-
allequal
12+
allequal, dict_delall
1313
from collections import RegularPolyCollection, PolyCollection
1414
from colors import colorConverter, normalize, Colormap, LinearSegmentedColormap
1515
import cm
@@ -281,8 +281,6 @@ def _grab_next_args(self, *args, **kwargs):
281281

282282

283283

284-
285-
286284
class Axes(Artist):
287285
"""
288286
Emulate matlab's axes command, creating axes with
@@ -1457,13 +1455,13 @@ def legend(self, *args, **kwargs):
14571455
if len(args)==0:
14581456
labels = [line.get_label() for line in self.lines]
14591457
lines = self.lines
1460-
loc = kwargs.pop('loc', 1)
1458+
loc = kwargs.gry('loc', 1)
14611459

14621460
elif len(args)==1:
14631461
# LABELS
14641462
labels = args[0]
14651463
lines = [line for line, label in zip(self.lines, labels)]
1466-
loc = kwargs.pop('loc', 1)
1464+
loc = kwargs.get('loc', 1)
14671465

14681466
elif len(args)==2:
14691467
if is_string_like(args[1]) or isinstance(args[1], int):
@@ -1473,7 +1471,7 @@ def legend(self, *args, **kwargs):
14731471
else:
14741472
# LINES, LABELS
14751473
lines, labels = args
1476-
loc = kwargs.pop('loc', 1)
1474+
loc = kwargs.get('loc', 1)
14771475

14781476
elif len(args)==3:
14791477
# LINES, LABELS, LOC
@@ -1506,15 +1504,18 @@ def loglog(self, *args, **kwargs):
15061504
* subsy: the location of the minor yticks; None defaults to range(2,basey)
15071505
"""
15081506
if not self._hold: self.cla()
1509-
dx = {'basex': kwargs.pop('basex', 10),
1510-
'subsx': kwargs.pop('subsx', None),
1507+
1508+
dx = {'basex': kwargs.get('basex', 10),
1509+
'subsx': kwargs.get('subsx', None),
15111510
}
1512-
dy = {'basey': kwargs.pop('basey', 10),
1513-
'subsy': kwargs.pop('subsy', None),
1511+
dy = {'basey': kwargs.get('basey', 10),
1512+
'subsy': kwargs.get('subsy', None),
15141513
}
15151514

15161515
self.set_xscale('log', **dx)
15171516
self.set_yscale('log', **dy)
1517+
dict_delall( kwargs, ('basex', 'basey', 'subsx', 'subsy'))
1518+
15181519
l = self.plot(*args, **kwargs)
15191520
return l
15201521

@@ -1596,14 +1597,12 @@ def pcolor(self, *args, **kwargs):
15961597
"""
15971598
if not self._hold: self.cla()
15981599

1599-
alpha = kwargs.pop('alpha', 1.0)
1600-
norm = kwargs.pop('norm', None)
1601-
cmap = kwargs.pop('cmap', None)
1602-
vmin = kwargs.pop('vmin', None)
1603-
vmax = kwargs.pop('vmax', None)
1604-
shading = kwargs.pop('shading', 'faceted')
1605-
if len(kwargs):
1606-
raise TypeError, 'Unknown argument "%s"'%kwargs.keys()[0]
1600+
alpha = kwargs.get('alpha', 1.0)
1601+
norm = kwargs.get('norm', None)
1602+
cmap = kwargs.get('cmap', None)
1603+
vmin = kwargs.get('vmin', None)
1604+
vmax = kwargs.get('vmax', None)
1605+
shading = kwargs.get('shading', 'faceted')
16071606

16081607
if len(args)==1:
16091608
C = args[0]
@@ -1716,12 +1715,10 @@ def pcolor_classic(self, *args, **kwargs):
17161715
"""
17171716

17181717
if not self._hold: self.cla()
1719-
shading = kwargs.pop('shading', 'faceted')
1720-
cmap = kwargs.pop('cmap', cm.get_cmap())
1721-
norm = kwargs.pop('norm', normalize())
1722-
alpha = kwargs.pop('alpha', 1.0)
1723-
if len(kwargs):
1724-
raise TypeError, 'Unknown argument "%s"'%kwargs.keys()[0]
1718+
shading = kwargs.get('shading', 'faceted')
1719+
cmap = kwargs.get('cmap', cm.get_cmap())
1720+
norm = kwargs.get('norm', normalize())
1721+
alpha = kwargs.get('alpha', 1.0)
17251722

17261723
if len(args)==1:
17271724
C = args[0]
@@ -2225,11 +2222,12 @@ def semilogx(self, *args, **kwargs):
22252222
22262223
"""
22272224

2228-
d = {'basex': kwargs.pop('basex', 10),
2229-
'subsx': kwargs.pop('subsx', None),
2225+
d = {'basex': kwargs.get('basex', 10),
2226+
'subsx': kwargs.get('subsx', None),
22302227
}
22312228

22322229
self.set_xscale('log', **d)
2230+
dict_delall( kwargs, ('basex', 'subsx'))
22332231
l = self.plot(*args, **kwargs)
22342232
return l
22352233

@@ -2251,11 +2249,11 @@ def semilogy(self, *args, **kwargs):
22512249
range(2,basey)
22522250
22532251
"""
2254-
d = {'basey': kwargs.pop('basey', 10),
2255-
'subsy': kwargs.pop('subsy', None),
2252+
d = {'basey': kwargs.get('basey', 10),
2253+
'subsy': kwargs.get('subsy', None),
22562254
}
2257-
22582255
self.set_yscale('log', **d)
2256+
dict_delall( kwargs, ('basey', 'subsy'))
22592257
l = self.plot(*args, **kwargs)
22602258
return l
22612259

lib/matplotlib/backends/backend_ps.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
"""
55

66
from __future__ import division
7-
import sys, os
7+
import sys, os, time
88
from cStringIO import StringIO
9-
from datetime import datetime
109
from matplotlib import verbose, __version__
1110
from matplotlib._matlab_helpers import Gcf
1211
from matplotlib.backend_bases import RendererBase, GraphicsContextBase,\
@@ -581,7 +580,7 @@ def print_figure(self, outfile, dpi=72,
581580
if title: print >>fh, "%%Title: "+title
582581
print >>fh, ("%%Creator: matplotlib version "
583582
+__version__+", http://matplotlib.sourceforge.net/")
584-
print >>fh, "%%CreationDate: "+datetime.today().ctime()
583+
print >>fh, "%%CreationDate: "+time.ctime(time.time())
585584
if not isEPSF:
586585
if paperWidth > paperHeight:
587586
ostr="Landscape"

lib/matplotlib/cbook.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,13 @@ def mkdirs(newdir, mode=0777):
217217
raise
218218

219219

220+
def dict_delall(d, keys):
221+
'delete all of the keys from the dict d'
222+
for key in keys:
223+
try: del d[key]
224+
except KeyError: pass
225+
226+
220227
class RingBuffer:
221228
""" class that implements a not-yet-full buffer """
222229
def __init__(self,size_max):

lib/matplotlib/figure.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import sys
22
from artist import Artist
33
from axes import Axes, Subplot, PolarSubplot, PolarAxes
4-
from cbook import flatten, True, False, allequal
4+
from cbook import flatten, True, False, allequal, dict_delall
55
import _image
66
from colors import normalize
77
from image import FigureImage
@@ -191,7 +191,7 @@ def add_subplot(self, *args, **kwargs):
191191
The Axes instance will be returned
192192
"""
193193
ispolar = kwargs.get('polar', False)
194-
194+
dict_delall(kwargs, ('polar', ) )
195195
if ispolar:
196196
a = PolarSubplot(self, *args, **kwargs)
197197
else:

0 commit comments

Comments
 (0)