From: <jd...@us...> - 2008-07-24 13:30:56
|
Revision: 5836 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5836&view=rev Author: jdh2358 Date: 2008-07-24 13:30:53 +0000 (Thu, 24 Jul 2008) Log Message: ----------- Merged revisions 5834 via svnmerge from https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_91_maint ........ r5834 | jdh2358 | 2008-07-24 08:15:23 -0500 (Thu, 24 Jul 2008) | 1 line deprecated mlab2 functions from mlab ........ Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/blocking_input.py trunk/matplotlib/lib/matplotlib/contour.py trunk/matplotlib/lib/matplotlib/mlab.py Property Changed: ---------------- trunk/matplotlib/ Property changes on: trunk/matplotlib ___________________________________________________________________ Modified: svnmerge-integrated - /branches/v0_91_maint:1-5833 + /branches/v0_91_maint:1-5835 Modified: trunk/matplotlib/lib/matplotlib/blocking_input.py =================================================================== --- trunk/matplotlib/lib/matplotlib/blocking_input.py 2008-07-24 13:21:17 UTC (rev 5835) +++ trunk/matplotlib/lib/matplotlib/blocking_input.py 2008-07-24 13:30:53 UTC (rev 5836) @@ -274,11 +274,22 @@ lw = cs.get_label_width(cs.labelLevelList[lmin], cs.labelFmt, cs.labelFontSizeList[lmin]) + """ + # requires python 2.5 # Figure out label rotation. rotation,nlc = cs.calc_label_rot_and_inline( slc, imin, lw, lc if self.inline else [], self.inline_spacing ) + """ + # Figure out label rotation. + if self.inline: lcarg = lc + else: lcarg = [] + rotation,nlc = cs.calc_label_rot_and_inline( + slc, imin, lw, lcarg, + self.inline_spacing ) + + cs.add_label(xmin,ymin,rotation,cs.labelLevelList[lmin], cs.labelCValueList[lmin]) Modified: trunk/matplotlib/lib/matplotlib/contour.py =================================================================== --- trunk/matplotlib/lib/matplotlib/contour.py 2008-07-24 13:21:17 UTC (rev 5835) +++ trunk/matplotlib/lib/matplotlib/contour.py 2008-07-24 13:30:53 UTC (rev 5836) @@ -329,15 +329,15 @@ return x, y, dind - def calc_label_rot_and_inline( self, slc, ind, lw, lc=[], spacing=5 ): + def calc_label_rot_and_inline( self, slc, ind, lw, lc=None, spacing=5 ): """ This function calculates the appropriate label rotation given the linecontour coordinates in screen units, the index of the label location and the label width. It will also break contour and calculate inlining if *lc* is - not empty. *spacing* is the space around the label in pixels - to leave empty. + not empty (lc defaults to the empty list if None). *spacing* + is the space around the label in pixels to leave empty. Do both of these tasks at once to avoid calling cbook.path_length multiple times, which is relatively costly. @@ -348,6 +348,7 @@ determine rotation and then to break contour if desired. """ + if lc is None: lc = [] # Half the label width hlw = lw/2.0 @@ -483,8 +484,10 @@ if self.print_label(slc,lw): x,y,ind = self.locate_label(slc, lw) + if inline: lcarg = lc + else: lcarg = [] rotation,new=self.calc_label_rot_and_inline( - slc0, ind, lw, lc if inline else [], + slc0, ind, lw, lcarg, inline_spacing ) # Actually add the label Modified: trunk/matplotlib/lib/matplotlib/mlab.py =================================================================== --- trunk/matplotlib/lib/matplotlib/mlab.py 2008-07-24 13:21:17 UTC (rev 5835) +++ trunk/matplotlib/lib/matplotlib/mlab.py 2008-07-24 13:30:53 UTC (rev 5836) @@ -1771,181 +1771,51 @@ ### end fperez numutils code -### begin mlab2 functions -# From MLab2: http://pdilib.sourceforge.net/MLab2.py -readme = \ - """ -MLab2.py, release 1 -Created on February 2003 by Thomas Wendler as part of the Emotionis Project. -This script is supposed to implement Matlab functions that were left out in -numerix.mlab.py (part of Numeric Python). -For further information on the Emotionis Project or on this script, please -contact their authors: -Rodrigo Benenson, rodrigob at elo dot utfsm dot cl -Thomas Wendler, thomasw at elo dot utfsm dot cl -Look at: http://pdilib.sf.net for new releases. -""" -## mlab2 functions numpified and checked 2007/08/04 -_eps_approx = 1e-13 - -#from numpy import fix -def fix(x): - """ - Rounds towards zero. - x_rounded = fix(x) rounds the elements of x to the nearest integers - towards zero. - For negative numbers is equivalent to ceil and for positive to floor. - """ - warnings.warn("Use numpy.fix()", DeprecationWarning) - return np.fix(x) - def rem(x,y): """ - Remainder after division. - rem(x,y) is equivalent to x - y.*fix(x./y) in case y is not zero. - By convention (but contrary to numpy), rem(x,0) returns None. - This also differs from numpy.remainder, which uses floor instead of - fix. + Deprecated - see numpy.remainder """ - x,y = np.asarray(x), np.asarray(y) - if np.any(y == 0): - return None - return x - y * np.fix(x/y) + raise NotImplementedError('Deprecated - see numpy.remainder') - def norm(x,y=2): """ - This function is deprecated - use numpy.linalg.norm instead. - - Norm of a matrix or a vector. Functions similar to the Matlab (TM) - function of the same name. - - Call signature:: - - norm(x,y=2) - - This function behaves differently for vectors and matrices. For vectors, - it returns the y'th norm of x (i.e. (sum(abs(x)**y))**(1.0/y). - - For matrices, if y=2, then it returns the largest singular value - of X, namely max(linalg.svd(x)). If y=1, returns the largest - column sum of x (i.e., max(sum(abs(x),axis=0)) ). If y=inf, - returns the largest row sum. If y='fro', returns the Frobenius - norm, sqrt(sum(diag(dot(x.transpose(),x)))). + Deprecated - see numpy.linalg.norm """ - warnings.warn( "Use numpy.linalg.norm instead", DeprecationWarning ) + raise NotImplementedError('Deprecated - see numpy.linalg.norm') - x = np.asarray(x) - if x.ndim == 2: - if y==2: - return np.max(np.linalg.svd(x)[1]) - elif y==1: - return np.max(np.sum(np.absolute((x)), axis=0)) - elif y=='inf': - return np.max(np.sum(np.absolute((np.transpose(x))), axis=0)) - elif y=='fro': - xx = np.dot(x.transpose(), x) - return np.sqrt(np.sum(np.diag(xx), axis=0)) - else: - raise ValueError('Second argument not permitted for matrices') - else: - xa = np.absolute(x) - if y == 'inf': - return np.max(xa) - elif y == '-inf': - return np.min(xa) - else: - return np.power(np.sum(np.power(xa,y)),1/float(y)) - - def orth(A): """ - Orthogonalization procedure similar to Matlab (TM) function of the same - name. - - Call signature:: - - Q = orth(A) - - Returns an orthonormal basis with the range of A. Q is an orthonormal - matrix (i.e., dot( Q.transpose(), Q ) is an identity matrix) and the - columns of Q span the same space as the columns of A. + Deprecated - needs clean room implementation """ + raise NotImplementedError('Deprecated - needs clean room implementation') - A = np.asarray(A) - U,S,V = np.linalg.svd(A) - - m,n = A.shape - if m > 1: - s = S - elif m == 1: - s = S[0] - else: - s = 0 - - tol = max(m,n) * np.max(s) * _eps_approx - r = np.sum(s > tol) - Q = np.take(U,range(r),1) - - return Q - def rank(x): """ - Returns the rank of a matrix. - The rank is understood here as the an estimation of the number of - linearly independent rows or columns (depending on the size of the - matrix). - Note that numerix.mlab.rank() is not equivalent to Matlab's rank. - This function is! + Deprecated - see numpy.rank """ - x = np.asarray(x) - s = np.linalg.svd(x, compute_uv=False) - maxabs = np.max(np.absolute(s)) - maxdim = max(x.shape) - tol = maxabs * maxdim * _eps_approx - return np.sum(s > tol) + raise NotImplementedError('Deprecated - see numpy.rank') def sqrtm(x): """ - Returns the square root of a square matrix. - This means that s=sqrtm(x) implies dot(s,s) = x. - Note that s and x are matrices. + Deprecated - needs clean room implementation """ - return mfuncC(np.sqrt, x) + raise NotImplementedError('Deprecated - needs clean room implementation') def mfuncC(f, x): """ - mfuncC(f, x) : matrix function with possibly complex eigenvalues. - Note: Numeric defines (v,u) = eig(x) => x*u.T = u.T * Diag(v) - This function is needed by sqrtm and allows further functions. + Deprecated """ + raise NotImplementedError('Deprecated - needs clean room implementation') - x = np.asarray(x) - (v,uT) = np.linalg.eig(x) - V = np.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 = np.dot(uT, np.dot(V, np.linalg.inv(uT))) - return approx_real(y) - def approx_real(x): - """ - approx_real(x) : returns x.real if |x.imag| < |x.real| * _eps_approx. - This function is needed by sqrtm and allows further functions. + Deprecated - needs clean room implementation """ - ai = np.absolute(x.imag) - ar = np.absolute(x.real) - if np.max(ai) <= np.max(ar) * _eps_approx: - return x.real - else: - return x + raise NotImplementedError('Deprecated - needs clean room implementation') -### end mlab2 functions - #helpers for loading, saving, manipulating and viewing numpy record arrays def safe_isnan(x): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |