From: <md...@us...> - 2008-04-11 15:32:08
|
Revision: 5039 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5039&view=rev Author: mdboom Date: 2008-04-11 08:32:03 -0700 (Fri, 11 Apr 2008) Log Message: ----------- Merged revisions 5026-5038 via svnmerge from https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_91_maint ........ r5028 | jdh2358 | 2008-04-03 11:24:20 -0400 (Thu, 03 Apr 2008) | 1 line some small fixes to excel tools ........ r5032 | jrevans | 2008-04-07 18:26:21 -0400 (Mon, 07 Apr 2008) | 2 lines Fixed the double draw bug. ........ r5033 | jdh2358 | 2008-04-09 14:54:54 -0400 (Wed, 09 Apr 2008) | 1 line small fix for vlines w/ len 1 args ........ r5038 | mdboom | 2008-04-11 11:24:57 -0400 (Fri, 11 Apr 2008) | 3 lines Fixing global font rcParam setting after initialization time (thanks to Lev Givon and Eric Firing for finding this) ........ Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/examples/rec_groupby_demo.py trunk/matplotlib/lib/matplotlib/axes.py trunk/matplotlib/lib/matplotlib/backends/backend_qt4agg.py trunk/matplotlib/lib/matplotlib/font_manager.py trunk/matplotlib/lib/matplotlib/mlab.py Property Changed: ---------------- trunk/matplotlib/ Property changes on: trunk/matplotlib ___________________________________________________________________ Name: svnmerge-integrated - /branches/v0_91_maint:1-5025 + /branches/v0_91_maint:1-5038 Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008-04-11 15:24:57 UTC (rev 5038) +++ trunk/matplotlib/CHANGELOG 2008-04-11 15:32:03 UTC (rev 5039) @@ -1,7 +1,10 @@ -2008-04-11 Revert commits 5002 and 5031, which were intended to - avoid an unnecessary call to draw(). 5002 broke saving +2008-04-11 Fix global font rcParam setting after initialization + time. - MGD + +2008-04-11 Revert commits 5002 and 5031, which were intended to + avoid an unnecessary call to draw(). 5002 broke saving figures before show(). 5031 fixed the problem created in - 5002, but broke interactive plotting. Unnecessary call to + 5002, but broke interactive plotting. Unnecessary call to draw still needs resolution - DSD 2008-04-07 Improve color validation in rc handling, suggested Modified: trunk/matplotlib/examples/rec_groupby_demo.py =================================================================== --- trunk/matplotlib/examples/rec_groupby_demo.py 2008-04-11 15:24:57 UTC (rev 5038) +++ trunk/matplotlib/examples/rec_groupby_demo.py 2008-04-11 15:32:03 UTC (rev 5039) @@ -6,14 +6,20 @@ r.sort() def daily_return(prices): + 'an array of daily returns from price array' g = np.zeros_like(prices) g[1:] = (prices[1:]-prices[:-1])/prices[:-1] return g def volume_code(volume): + 'code the continuous volume data categorically' ind = np.searchsorted([1e5,1e6, 5e6,10e6, 1e7], volume) return ind +# a list of (dtype_name, summary_function, output_dtype_name). +# rec_summarize will call on each function on the indicated recarray +# attribute, and the result assigned to output name in the return +# record array. summaryfuncs = ( ('date', lambda x: [thisdate.year for thisdate in x], 'years'), ('date', lambda x: [thisdate.month for thisdate in x], 'months'), @@ -24,6 +30,10 @@ rsum = mlab.rec_summarize(r, summaryfuncs) +# stats is a list of (dtype_name, function, output_dtype_name). +# rec_groupby will summarize the attribute identified by the +# dtype_name over the groups in the groupby list, and assign the +# result to the output_dtype_name stats = ( ('dreturn', len, 'rcnt'), ('dreturn', np.mean, 'rmean'), @@ -31,6 +41,7 @@ ('dreturn', np.std, 'rsigma'), ) +# you can summarize over a single variable, like years or months print 'summary by years' ry = mlab.rec_groupby(rsum, ('years',), stats) print mlab. rec2txt(ry) @@ -39,6 +50,7 @@ rm = mlab.rec_groupby(rsum, ('months',), stats) print mlab.rec2txt(rm) +# or over multiple variables like years and months print 'summary by year and month' rym = mlab.rec_groupby(rsum, ('years','months'), stats) print mlab.rec2txt(rym) Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2008-04-11 15:24:57 UTC (rev 5038) +++ trunk/matplotlib/lib/matplotlib/axes.py 2008-04-11 15:32:03 UTC (rev 5039) @@ -2592,11 +2592,10 @@ xmax = npy.asarray(xmax) if len(xmin)==1: - xmin = xmin*npy.ones(y.shape, y.dtype) + xmin = npy.resize( xmin, y.shape ) if len(xmax)==1: - xmax = xmax*npy.ones(y.shape, y.dtype) + xmax = npy.resize( xmax, y.shape ) - if len(xmin)!=len(y): raise ValueError, 'xmin and y are unequal sized sequences' if len(xmax)!=len(y): @@ -2660,9 +2659,9 @@ ymin = npy.asarray(ymin) ymax = npy.asarray(ymax) if len(ymin)==1: - ymin = ymin*npy.ones(x.shape, x.dtype) + ymin = npy.resize( ymin, x.shape ) if len(ymax)==1: - ymax = ymax*npy.ones(x.shape, x.dtype) + ymax = npy.resize( ymax, x.shape ) if len(ymin)!=len(x): raise ValueError, 'ymin and x are unequal sized sequences' Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt4agg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_qt4agg.py 2008-04-11 15:24:57 UTC (rev 5038) +++ trunk/matplotlib/lib/matplotlib/backends/backend_qt4agg.py 2008-04-11 15:32:03 UTC (rev 5039) @@ -131,7 +131,6 @@ if DEBUG: print "FigureCanvasQtAgg.draw", self self.replot = True FigureCanvasAgg.draw(self) - self.update() def blit(self, bbox=None): """ Modified: trunk/matplotlib/lib/matplotlib/font_manager.py =================================================================== --- trunk/matplotlib/lib/matplotlib/font_manager.py 2008-04-11 15:24:57 UTC (rev 5038) +++ trunk/matplotlib/lib/matplotlib/font_manager.py 2008-04-11 15:32:03 UTC (rev 5039) @@ -625,20 +625,6 @@ fontconfig. """ - class FontPropertiesSet(object): - """This class contains all of the default properties at the - class level, which are then overridden (only if provided) at - the instance level.""" - family = rcParams['font.' + rcParams['font.family']] - if is_string_like(family): - family = [family] - slant = [rcParams['font.style']] - variant = [rcParams['font.variant']] - weight = [rcParams['font.weight']] - stretch = [rcParams['font.stretch']] - size = [rcParams['font.size']] - file = None - def __init__(self, family = None, style = None, @@ -649,12 +635,17 @@ fname = None, # if this is set, it's a hardcoded filename to use _init = None # used only by copy() ): + self._family = None + self._slant = None + self._variant = None + self._weight = None + self._stretch = None + self._size = None + self._file = None - self.__props = self.FontPropertiesSet() - # This is used only by copy() if _init is not None: - self.__props.__dict__.update(_init) + self.__dict__.update(_init.__dict__) return if is_string_like(family): @@ -666,9 +657,8 @@ stretch is None and size is None and fname is None): - self.__props.__dict__ = self._parse_fontconfig_pattern(family) + self.set_fontconfig_pattern(family) return - family = [family] self.set_family(family) self.set_style(style) @@ -682,7 +672,7 @@ return parse_fontconfig_pattern(pattern) def __hash__(self): - return hash(repr(self.__props.__dict__)) + return hash(repr(self.__dict__)) def __str__(self): return self.get_fontconfig_pattern() @@ -690,7 +680,12 @@ def get_family(self): """Return a list of font names that comprise the font family. """ - return self.__props.family + if self._family is None: + family = rcParams['font.family'] + if is_string_like(family): + return [family] + return family + return self._family def get_name(self): """Return the name of the font that best matches the font properties.""" @@ -698,38 +693,45 @@ def get_style(self): """Return the font style. Values are: normal, italic or oblique.""" - return self.__props.slant[0] + if self._slant is None: + return rcParams['font.style'] + return self._slant def get_variant(self): """Return the font variant. Values are: normal or small-caps.""" - return self.__props.variant[0] + if self._variant is None: + return rcParams['font.variant'] + return self._variant def get_weight(self): """ Return the font weight. See the FontProperties class for a a list of possible values. """ - return self.__props.weight[0] + if self._weight is None: + return rcParams['font.weight'] + return self._weight def get_stretch(self): """ Return the font stretch or width. Options are: normal, narrow, condensed, or wide. """ - return self.__props.stretch[0] + if self._stretch is None: + return rcParams['font.stretch'] + return self._stretch def get_size(self): """Return the font size.""" - return float(self.__props.size[0]) + if self._size is None: + return rcParams['font.size'] + return float(self._size) def get_file(self): - if self.__props.file is not None: - return self.__props.file[0] - else: - return None + return self._file def get_fontconfig_pattern(self): - return generate_fontconfig_pattern(self.__props.__dict__) + return generate_fontconfig_pattern(self) def set_family(self, family): """ @@ -738,58 +740,49 @@ fantasy, or monospace, or a real font name. """ if family is None: - self.__props.__dict__.pop('family', None) + self._family = None else: if is_string_like(family): family = [family] - self.__props.family = family + self._family = family set_name = set_family def set_style(self, style): """Set the font style. Values are: normal, italic or oblique.""" - if style is None: - self.__props.__dict__.pop('style', None) - else: - if style not in ('normal', 'italic', 'oblique'): - raise ValueError("style must be normal, italic or oblique") - self.__props.slant = [style] + if style not in ('normal', 'italic', 'oblique', None): + raise ValueError("style must be normal, italic or oblique") + self._slant = style def set_variant(self, variant): """Set the font variant. Values are: normal or small-caps.""" - if variant is None: - self.__props.__dict__.pop('variant', None) - else: - if variant not in ('normal', 'small-caps'): - raise ValueError("variant must be normal or small-caps") - self.__props.variant = [variant] + if variant not in ('normal', 'small-caps', None): + raise ValueError("variant must be normal or small-caps") + self._variant = variant def set_weight(self, weight): """ Set the font weight. See the FontProperties class for a a list of possible values. """ - if weight is None: - self.__props.__dict__.pop('weight', None) - else: - if (weight not in weight_dict and - weight not in weight_dict.keys()): - raise ValueError("weight is invalid") - self.__props.weight = [weight] + if (weight is not None and + weight not in weight_dict and + weight not in weight_dict.keys()): + raise ValueError("weight is invalid") + self._weight = weight def set_stretch(self, stretch): """ Set the font stretch or width. Options are: normal, narrow, condensed, or wide. """ - if stretch is None: - self.__props.__dict__.pop('stretch', None) - else: - self.__props.stretch = [stretch] + if stretch not in ('normal', 'narrow', 'condensed', 'wide', None): + raise ValueError("stretch is invalid") + self._stretch = stretch def set_size(self, size): """Set the font size.""" if size is None: - self.__props.__dict__.pop('size', None) + self._size = None else: if is_string_like(size): parent_size = fontManager.get_default_size() @@ -797,28 +790,25 @@ if scaling is not None: size = parent_size * scaling else: - size = parent_size - if isinstance(size, (int, float)): - size = [size] - self.__props.size = size + try: + size = float(size) + except ValueError: + size = parent_size + assert(type(size) in (int, float)) + self._size = size def set_file(self, file): - if file is None: - self.__props.__dict__.pop('file', None) - else: - self.__props.file = [file] + self._file = file get_size_in_points = get_size def set_fontconfig_pattern(self, pattern): - self.__props.__dict__ = self._parse_fontconfig_pattern(pattern) + for key, val in self._parse_fontconfig_pattern(pattern).items(): + getattr(self, "set_" + key)(val) - def add_property_pair(self, key, val): - self.__props.setdefault(key, []).append(val) - def copy(self): """Return a deep copy of self""" - return FontProperties(_init = self.__props.__dict__) + return FontProperties(_init = self) def ttfdict_to_fnames(d): 'flatten a ttfdict to all the filenames it contains' Modified: trunk/matplotlib/lib/matplotlib/mlab.py =================================================================== --- trunk/matplotlib/lib/matplotlib/mlab.py 2008-04-11 15:24:57 UTC (rev 5038) +++ trunk/matplotlib/lib/matplotlib/mlab.py 2008-04-11 15:32:03 UTC (rev 5039) @@ -1948,7 +1948,6 @@ except NotImplementedError: return False else: return b - def rec_append_field(rec, name, arr, dtype=None): 'return a new record array with field name populated with data from array arr' arr = npy.asarray(arr) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |