Skip to content

Commit 8351044

Browse files
committed
fixed os.rename bug
svn path=/trunk/matplotlib/; revision=1832
1 parent d870813 commit 8351044

File tree

7 files changed

+73
-28
lines changed

7 files changed

+73
-28
lines changed

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
New entries should be added at the top
22

3+
2005-10-10 Replaced all instances of os.rename with shutil.move
4+
5+
2005-10-05 Added Michael Brady's ydate patch
6+
37
2005-10-04 Added rkern's texmanager patch
48

59
2005-09-25 contour.py modified to use a single ContourSet class

lib/matplotlib/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,11 @@
143143
from __future__ import generators
144144

145145

146-
__version__ = '0.84'
146+
__version__ = '0.85.cvs'
147147
__revision__ = '$Revision$'
148148
__date__ = '$Date$'
149149

150-
import sys, os, warnings
150+
import sys, os, warnings, shutil
151151
import distutils.sysconfig
152152

153153
if not hasattr(sys, 'argv'): # for modpython
@@ -758,7 +758,7 @@ def matplotlib_fname():
758758
WARNING: Old rc filename ".matplotlibrc" found in working dir
759759
and and renamed to new default rc file name "matplotlibrc"
760760
(no leading"dot"). """
761-
os.rename('.matplotlibrc', 'matplotlibrc')
761+
shutil.move('.matplotlibrc', 'matplotlibrc')
762762

763763
home = get_home()
764764
oldname = os.path.join( home, '.matplotlibrc')
@@ -769,7 +769,7 @@ def matplotlib_fname():
769769
WARNING: Old rc filename "%s" found and renamed to
770770
new default rc file name "%s"."""%(oldname, newname)
771771

772-
os.rename(oldname, newname)
772+
shutil.move(oldname, newname)
773773

774774

775775
fname = os.path.join( os.getcwd(), 'matplotlibrc')

lib/matplotlib/axes.py

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2591,33 +2591,43 @@ def plot(self, *args, **kwargs):
25912591
self.autoscale_view()
25922592
return lines
25932593

2594-
def plot_date(self, d, y, fmt='bo', tz=None, **kwargs):
2594+
def plot_date(self, x, y, fmt='bo', tz=None, xdate=True, ydate=False,
2595+
**kwargs):
25952596
"""
2596-
PLOT_DATE(d, y, fmt='bo', tz=None, **kwargs)
2597+
PLOT_DATE(x, y, fmt='bo', tz=None, xdate=True, ydate=False, **kwargs)
25972598
2598-
d is a sequence of dates represented as float days since
2599-
0001-01-01 UTC and y are the y values at those dates. fmt is
2600-
a plot format string. kwargs are passed on to plot. See plot
2601-
for more information.
2599+
Similar to the plot() command, except the x or y (or both) data
2600+
is considered to be dates, and the axis is labeled accordingly.
2601+
2602+
x or y (or both) can be a sequence of dates represented as
2603+
float days since 0001-01-01 UTC.
2604+
2605+
fmt is a plot format string.
2606+
2607+
tz is the time zone to use in labelling dates. Defaults to rc value.
2608+
2609+
If xdate is True, the x-axis will be labeled with dates.
2610+
2611+
If ydate is True, the y-axis will be labeled with dates.
2612+
2613+
kwargs are passed on to plot. See plot for more information.
26022614
26032615
See matplotlib.dates for helper functions date2num, num2date
26042616
and drange for help on creating the required floating point dates
2605-
2606-
tz is the timezone - defaults to rc value
26072617
"""
26082618

26092619
if not matplotlib._havedate:
26102620
raise SystemExit('plot_date: no dates support - dates require python2.3')
26112621

26122622
if not self._hold: self.cla()
26132623

2614-
ret = self.plot(d, y, fmt, **kwargs)
2615-
2616-
span = self.dataLim.intervalx().span()
2624+
ret = self.plot(x, y, fmt, **kwargs)
26172625

2618-
locator, formatter = date_ticker_factory(span, tz)
2619-
self.xaxis.set_major_locator(locator)
2620-
self.xaxis.set_major_formatter(formatter)
2626+
if xdate:
2627+
self.xaxis_date(tz)
2628+
if ydate:
2629+
self.yaxis_date(tz)
2630+
26212631
self.autoscale_view()
26222632

26232633
return ret
@@ -3586,6 +3596,27 @@ def vlines(self, x, ymin, ymax, fmt='k-', **kwargs):
35863596
lines.append(line)
35873597
return lines
35883598

3599+
def xaxis_date(self, tz=None):
3600+
"""Sets up x-axis ticks and labels that treat the x data as dates.
3601+
3602+
tz is the time zone to use in labeling dates. Defaults to rc value.
3603+
"""
3604+
3605+
span = self.dataLim.intervalx().span()
3606+
locator, formatter = date_ticker_factory(span, tz)
3607+
self.xaxis.set_major_locator(locator)
3608+
self.xaxis.set_major_formatter(formatter)
3609+
3610+
def yaxis_date(self, tz=None):
3611+
"""Sets up y-axis ticks and labels that treat the y data as dates.
3612+
3613+
tz is the time zone to use in labeling dates. Defaults to rc value.
3614+
"""
3615+
3616+
span = self.dataLim.intervaly().span()
3617+
locator, formatter = date_ticker_factory(span, tz)
3618+
self.yaxis.set_major_locator(locator)
3619+
self.yaxis.set_major_formatter(formatter)
35893620

35903621
def zoomx(self, numsteps):
35913622
'Zoom in on the x xaxis numsteps (plus for zoom in, minus for zoom out)'

lib/matplotlib/font_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
see license/LICENSE_TTFQUERY.
3434
"""
3535

36-
import os, sys, glob, warnings
36+
import os, sys, glob, warnings, shutil
3737
import matplotlib
3838
from matplotlib import afm
3939
from matplotlib import ft2font
@@ -811,7 +811,7 @@ def __init__(self, size=12.0, weight='normal'):
811811
ttfcache = os.path.join(get_configdir(), 'ttffont.cache')
812812
if os.path.exists(oldcache):
813813
print >> sys.stderr, 'Moving old ttfcache location "%s" to new location "%s"'%(oldcache, ttfcache)
814-
os.rename(oldcache, ttfcache)
814+
shutil.move(oldcache, ttfcache)
815815

816816

817817

lib/matplotlib/texmanager.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class TexManager:
6060
print >> sys.stderr, """\
6161
WARNING: found a TeX cache dir in the deprecated location "%s".
6262
Moving it to the new default location "%s"."""%(oldcache, texcache)
63-
os.rename(oldcache, texcache)
63+
shutil.move(oldcache, texcache)
6464

6565
dvipngVersion = None
6666

@@ -80,7 +80,7 @@ def get_tex_command(self, tex, fname):
8080

8181
fontcmd = {'sans-serif' : r'{\sffamily %s}',
8282
'monospace' : r'{\ttfamily %s}'}.get(
83-
rcParams['font.family'],r'{\rmfamily %s}')
83+
rcParams['font.family'], r'{\rmfamily %s}')
8484
tex = fontcmd % tex
8585
fh = file(fname, 'w')
8686
if rcParams['text.tex.engine'] == 'latex':
@@ -129,7 +129,7 @@ def make_dvi(self, tex, force=0):
129129
# if not in TEXMFOUTPUT. So check for existence in current
130130
# dir and move it if necessary and then cleanup
131131
if os.path.exists(dvibase):
132-
os.rename(dvibase, dvifile)
132+
shutil.move(dvibase, dvifile)
133133
for fname in glob.glob(prefix+'*'):
134134
os.remove(fname)
135135
return dvifile
@@ -308,20 +308,19 @@ def get_rgba(self, tex, fontsize=10, dpi=80, rgb=(0,0,0)):
308308

309309
vers = self.get_dvipng_version()
310310
if vers<'1.6':
311+
# hack the alpha channel as described in comment above
311312
alpha = sqrt(1-X[:,:,0])
312313
else:
313-
# 1.6 has the alpha channel right
314+
# dvipng 1.6 and above handles the alpha channel
315+
# properly
314316
alpha = sqrt(X[:,:,-1])
315317

316-
#from matplotlib.mlab import prctile
317-
#print 'ptile', prctile(ravel(X[:,:,0])), prctile(ravel(X[:,:,-1]))
318318

319319
Z = zeros(X.shape, Float)
320320
Z[:,:,0] = r
321321
Z[:,:,1] = g
322322
Z[:,:,2] = b
323323
Z[:,:,3] = alpha
324-
#im = fromarray(Z, 1)
325324

326325
self.arrayd[key] = Z
327326
return Z

setupext.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ def add_base_flags(module):
102102
libdirs = [os.path.join(p, 'lib') for p in basedir[sys.platform]
103103
if os.path.exists(p)]
104104
module.include_dirs.extend(incdirs)
105+
module.include_dirs.append('.')
105106
module.library_dirs.extend(libdirs)
106107

107108

@@ -169,6 +170,16 @@ def add_pygtk_flags(module):
169170
module.include_dirs.extend(
170171
['win32_static/include/pygtk-2.0',
171172
'C:/GTK/include',
173+
'C:/GTK/include/gobject',
174+
'C:/GTK/include/gmodule',
175+
'C:/GTK/include/glib',
176+
'C:/GTK/include/pango',
177+
'C:/GTK/include/atk',
178+
'C:/GTK/include/X11',
179+
'C:/GTK/include/cairo',
180+
'C:/GTK/include/gdk',
181+
'C:/GTK/include/gdk-pixbuf',
182+
'C:/GTK/include/gtk',
172183
])
173184

174185
add_base_flags(module)

src/_backend_agg.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include "agg_pixfmt_rgb.h"
2626
#include "agg_pixfmt_rgba.h"
2727
#include "agg_rasterizer_outline.h"
28-
#include "agg_rasterizer_scanline_aa.h"
28+
#include "agg_rasterizer_aa.h"
2929
#include "agg_renderer_outline_aa.h"
3030
#include "agg_renderer_raster_text.h"
3131
#include "agg_renderer_scanline.h"

0 commit comments

Comments
 (0)