Revision: 7217
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7217&view=rev
Author: efiring
Date: 2009-06-14 01:32:20 +0000 (Sun, 14 Jun 2009)
Log Message:
-----------
partial cleanup of mlab and of the pylab imports from mlab
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/cbook.py
trunk/matplotlib/lib/matplotlib/mlab.py
trunk/matplotlib/lib/matplotlib/pylab.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2009-06-13 21:13:14 UTC (rev 7216)
+++ trunk/matplotlib/CHANGELOG 2009-06-14 01:32:20 UTC (rev 7217)
@@ -1,3 +1,5 @@
+2009-06-13 partial cleanup of mlab and its importation in pylab - EF
+
2009-06-13 Introduce a rotation_mode property for the Text artist. See
examples/pylab_examples/demo_text_rotation_mode.py -JJL
Modified: trunk/matplotlib/lib/matplotlib/cbook.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/cbook.py 2009-06-13 21:13:14 UTC (rev
7216)
+++ trunk/matplotlib/lib/matplotlib/cbook.py 2009-06-14 01:32:20 UTC (rev
7217)
@@ -761,36 +761,6 @@
-
-# python 2.2 dicts don't have pop--but we don't support 2.2 any more
-def popd(d, *args):
- """
- Should behave like python2.3 :meth:`dict.pop` method; *d* is a
- :class:`dict`::
-
- # returns value for key and deletes item; raises a KeyError if key
- # is not in dict
- val = popd(d, key)
-
- # returns value for key if key exists, else default. Delete key,
- # val item if it exists. Will not raise a KeyError
- val = popd(d, key, default)
-
- """
- warnings.warn("Use native python dict.pop method", DeprecationWarning)
- # warning added 2008/07/22
- if len(args)==1:
- key = args[0]
- val = d[key]
- del d[key]
- elif len(args)==2:
- key, default = args
- val = d.get(key, default)
- try: del d[key]
- except KeyError: pass
- return val
-
-
class maxdict(dict):
"""
A dictionary with a maximum size; this doesn't override all the
Modified: trunk/matplotlib/lib/matplotlib/mlab.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mlab.py 2009-06-13 21:13:14 UTC (rev
7216)
+++ trunk/matplotlib/lib/matplotlib/mlab.py 2009-06-14 01:32:20 UTC (rev
7217)
@@ -130,39 +130,12 @@
care--function signatures may differ):
-:meth:`conv`
- convolution (numpy.convolve)
-
-:meth:`corrcoef`
- The matrix of correlation coefficients
-
-:meth:`hist`
- Histogram (numpy.histogram)
-
-:meth:`linspace`
- Linear spaced array from min to max
-
:meth:`load`
load ASCII file - use numpy.loadtxt
-:meth:`meshgrid`
- Make a 2D grid from 2 1 arrays (numpy.meshgrid)
-
-:meth:`polyfit`
- least squares best polynomial fit of x to y (numpy.polyfit)
-
-:meth:`polyval`
- evaluate a vector for a vector of polynomial coeffs (numpy.polyval)
-
:meth:`save`
save ASCII file - use numpy.savetxt
-:meth:`trapz`
- trapeziodal integration (trapz(x,y) -> numpy.trapz(y,x))
-
-:meth:`vander`
- the Vandermonde matrix (numpy.vander)
-
"""
from __future__ import division
@@ -176,20 +149,6 @@
import matplotlib.cbook as cbook
-def linspace(*args, **kw):
- warnings.warn("use numpy.linspace", DeprecationWarning)
- return np.linspace(*args, **kw)
-
-def meshgrid(x,y):
- warnings.warn("use numpy.meshgrid", DeprecationWarning)
- return np.meshgrid(x,y)
-
-def mean(x, dim=None):
- warnings.warn("Use numpy.mean(x) or x.mean()", DeprecationWarning)
- if len(x)==0: return None
- return np.mean(x, axis=dim)
-
-
def logspace(xmin,xmax,N):
return np.exp(np.linspace(np.log(xmin), np.log(xmax), N))
@@ -205,12 +164,6 @@
"No window function; simply return x"
return x
-#from numpy import convolve as conv
-def conv(x, y, mode=2):
- 'convolve x with y'
- warnings.warn("Use numpy.convolve(x, y, mode='full')", DeprecationWarning)
- return np.convolve(x,y,mode)
-
def detrend(x, key=None):
if key is None or key=='constant':
return detrend_mean(x)
@@ -537,111 +490,7 @@
cohere.__doc__ = cohere.__doc__ % kwdocd
-def corrcoef(*args):
- """
- corrcoef(*X*) where *X* is a matrix returns a matrix of correlation
- coefficients for the columns of *X*
- corrcoef(*x*, *y*) where *x* and *y* are vectors returns the matrix of
- correlation coefficients for *x* and *y*.
-
- Numpy arrays can be real or complex.
-
- The correlation matrix is defined from the covariance matrix *C*
- as
-
- .. math::
-
- r_{ij} = \\frac{C_{ij}}{\\sqrt{C_{ii}C_{jj}}}
- """
- warnings.warn("Use numpy.corrcoef", DeprecationWarning)
- kw = dict(rowvar=False)
- return np.corrcoef(*args, **kw)
-
-
-def polyfit(*args, **kwargs):
- u"""
- polyfit(*x*, *y*, *N*)
-
- Do a best fit polynomial of order *N* of *y* to *x*. Return value
- is a vector of polynomial coefficients [pk ... p1 p0]. Eg, for
- *N* = 2::
-
- p2*x0^2 + p1*x0 + p0 = y1
- p2*x1^2 + p1*x1 + p0 = y1
- p2*x2^2 + p1*x2 + p0 = y2
- .....
- p2*xk^2 + p1*xk + p0 = yk
-
-
- Method: if *X* is a the Vandermonde Matrix computed from *x* (see
- `vandermonds
- <http://mathworld.wolfram.com/VandermondeMatrix.html>`_), then the
- polynomial least squares solution is given by the '*p*' in
-
- X*p = y
-
- where *X* is a (len(*x*) \N{MULTIPLICATION SIGN} *N* + 1) matrix,
- *p* is a *N*+1 length vector, and *y* is a (len(*x*)
- \N{MULTIPLICATION SIGN} 1) vector.
-
- This equation can be solved as
-
- .. math::
-
- p = (X_t X)^-1 X_t y
-
- where :math:`X_t` is the transpose of *X* and -1 denotes the
- inverse. Numerically, however, this is not a good method, so we
- use :func:`numpy.linalg.lstsq`.
-
- For more info, see `least squares fitting
- <http://mathworld.wolfram.com/LeastSquaresFittingPolynomial.html>`_,
- but note that the *k*'s and *n*'s in the superscripts and
- subscripts on that page. The linear algebra is correct, however.
-
- .. seealso::
-
- :func:`polyval`
- polyval function
- """
- warnings.warn("use numpy.polyfit", DeprecationWarning)
- return np.polyfit(*args, **kwargs)
-
-
-def polyval(*args, **kwargs):
- """
- *y* = polyval(*p*, *x*)
-
- *p* is a vector of polynomial coeffients and *y* is the polynomial
- evaluated at *x*.
-
- Example code to remove a polynomial (quadratic) trend from y::
-
- p = polyfit(x, y, 2)
- trend = polyval(p, x)
- resid = y - trend
-
- .. seealso::
-
- :func:`polyfit`
- polyfit function
- """
- warnings.warn("use numpy.polyval", DeprecationWarning)
- return np.polyval(*args, **kwargs)
-
-def vander(*args, **kwargs):
- """
- *X* = vander(*x*, *N* = *None*)
-
- The Vandermonde matrix of vector *x*. The *i*-th column of *X* is the
- the *i*-th power of *x*. *N* is the maximum power to compute; if *N* is
- *None* it defaults to len(*x*).
- """
- warnings.warn("Use numpy.vander()", DeprecationWarning)
- return np.vander(*args, **kwargs)
-
-
def donothing_callback(*args):
pass
@@ -826,24 +675,6 @@
#S = -1.0*np.sum(p*log(p))
return S
-def hist(y, bins=10, normed=0):
- """
- Return the histogram of *y* with *bins* equally sized bins. If
- bins is an array, use those bins. Return value is (*n*, *x*)
- where *n* is the count for each bin in *x*.
-
- If *normed* is *False*, return the counts in the first element of
- the returned tuple. If *normed* is *True*, return the probability
- density :math:`\\frac{n}{(len(y)\mathrm{dbin}}`.
-
- If *y* has rank > 1, it will be raveled. If *y* is masked, only the
- unmasked values will be used.
-
- Credits: the Numeric 22 documentation
- """
- warnings.warn("Use numpy.histogram()", DeprecationWarning)
- return np.histogram(y, bins=bins, range=None, normed=normed)
-
def normpdf(x, *args):
"Return the normal pdf evaluated at *x*; args provides *mu*, *sigma*"
mu, sigma = args
@@ -879,14 +710,7 @@
res, = np.nonzero(np.ravel(condition))
return res
-def trapz(x, y):
- """
- Trapezoidal integral of *y*(*x*).
- """
- warnings.warn("Use numpy.trapz(y,x) instead of trapz(x,y)",
DeprecationWarning)
- return np.trapz(y, x)
-
def longest_contiguous_ones(x):
"""
Return the indices of the longest stretch of contiguous ones in *x*,
@@ -1203,6 +1027,8 @@
*x* is a very long trajectory from a map, and *fprime* returns the
derivative of *x*.
+ This function will be removed from matplotlib.
+
Returns :
.. math::
@@ -1221,6 +1047,9 @@
It also seems that this function's name is badly misspelled.
"""
+
+ warnings.warn("This does not belong in matplotlib and will be removed",
DeprecationWarning) # 2009/06/13
+
return np.mean(np.log(np.absolute(fprime(x))))
class FIFOBuffer:
@@ -1330,6 +1159,8 @@
Save the data in *X* to file *fname* using *fmt* string to convert the
data to strings.
+ Deprecated. Use numpy.savetxt.
+
*fname* can be a filename or a file handle. If the filename ends
in '.gz', the file is automatically saved in compressed gzip
format. The :func:`load` function understands gzipped files
@@ -1346,6 +1177,8 @@
for comma-separated values.
"""
+ warnings.warn("use numpy.savetxt", DeprecationWarning) # 2009/06/13
+
if cbook.is_string_like(fname):
if fname.endswith('.gz'):
import gzip
@@ -1377,6 +1210,8 @@
"""
Load ASCII data from *fname* into an array and return the array.
+ Deprecated: use numpy.loadtxt.
+
The data must be regular, same number of values in every row
*fname* can be a filename or a file handle. Support for gzipped
@@ -1429,6 +1264,8 @@
Exercises many of these options.
"""
+ warnings.warn("use numpy.loadtxt", DeprecationWarning) # 2009/06/13
+
if converters is None: converters = {}
fh = cbook.to_filehandle(fname)
X = []
@@ -1720,33 +1557,6 @@
return np.array(map(fn,*args))
-#from numpy import zeros_like
-def zeros_like(a):
- """
- Return an array of zeros of the shape and typecode of *a*.
- """
- warnings.warn("Use numpy.zeros_like(a)", DeprecationWarning)
- return np.zeros_like(a)
-
-#from numpy import sum as sum_flat
-def sum_flat(a):
- """
- Return the sum of all the elements of *a*, flattened out.
-
- It uses ``a.flat``, and if *a* is not contiguous, a call to
- ``ravel(a)`` is made.
- """
- warnings.warn("Use numpy.sum(a) or a.sum()", DeprecationWarning)
- return np.sum(a)
-
-#from numpy import mean as mean_flat
-def mean_flat(a):
- """
- Return the mean of all the elements of *a*, flattened out.
- """
- warnings.warn("Use numpy.mean(a) or a.mean()", DeprecationWarning)
- return np.mean(a)
-
def rms_flat(a):
"""
Return the root mean square of all the elements of *a*, flattened out.
@@ -1852,14 +1662,6 @@
return np.arange(npts)*delta+xini
# end frange()
-#import numpy.diag as diagonal_matrix
-def diagonal_matrix(diag):
- """
- Return square diagonal matrix whose non-zero elements are given by the
- input array.
- """
- warnings.warn("Use numpy.diag(d)", DeprecationWarning)
- return np.diag(diag)
def identity(n, rank=2, dtype='l', typecode=None):
"""
@@ -1962,73 +1764,11 @@
"""
return np.prod(X.shape)==np.max(X.shape)
-#from numpy import fromfunction as fromfunction_kw
-def fromfunction_kw(function, dimensions, **kwargs):
- """
- Drop-in replacement for :func:`numpy.fromfunction`.
-
- Allows passing keyword arguments to the desired function.
-
- Call it as (keywords are optional)::
-
- fromfunction_kw(MyFunction, dimensions, keywords)
-
- The function ``MyFunction`` is responsible for handling the
- dictionary of keywords it will receive.
- """
- warnings.warn("Use numpy.fromfunction()", DeprecationWarning)
- return np.fromfunction(function, dimensions, **kwargs)
-
### end fperez numutils code
-def rem(x,y):
- """
- Deprecated - see :func:`numpy.remainder`
- """
- raise NotImplementedError('Deprecated - see numpy.remainder')
-
-def norm(x,y=2):
- """
- Deprecated - see :func:`numpy.linalg.norm`
- """
- raise NotImplementedError('Deprecated - see numpy.linalg.norm')
-
-
-def orth(A):
- """
- Deprecated - needs clean room implementation
- """
- raise NotImplementedError('Deprecated - needs clean room implementation')
-
-def rank(x):
- """
- Deprecated - see :func:`numpy.rank`
- """
- raise NotImplementedError('Deprecated - see numpy.rank')
-
-def sqrtm(x):
- """
- Deprecated - needs clean room implementation
- """
- raise NotImplementedError('Deprecated - see scipy.linalg.sqrtm')
-
-
-def mfuncC(f, x):
- """
- Deprecated
- """
- raise NotImplementedError('Deprecated - needs clean room implementation')
-
-def approx_real(x):
- """
- Deprecated - needs clean room implementation
- """
- raise NotImplementedError('Deprecated - needs clean room implementation')
-
#helpers for loading, saving, manipulating and viewing numpy record arrays
-
def safe_isnan(x):
':func:`numpy.isnan` for arbitrary types'
if cbook.is_string_like(x):
@@ -2047,15 +1787,6 @@
except TypeError: 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*. This function is Deprecated. Please use
- :func:`rec_append_fields`.
- """
- warnings.warn("use rec_append_fields", DeprecationWarning)
- return rec_append_fields(rec, name, arr, dtype)
-
def rec_append_fields(rec, names, arrs, dtypes=None):
"""
Return a new record array with field names populated with data
@@ -2114,7 +1845,7 @@
if cbook.is_string_like(names):
names = names.split(',')
-
+
arrays = []
for name in names:
arrays.append(rec[name])
@@ -2745,7 +2476,7 @@
if fields is not None:
r = rec_keep_fields(r, fields)
-
+
if cbook.is_numlike(precision):
precision = [precision]*len(r.dtype)
Modified: trunk/matplotlib/lib/matplotlib/pylab.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/pylab.py 2009-06-13 21:13:14 UTC (rev
7216)
+++ trunk/matplotlib/lib/matplotlib/pylab.py 2009-06-14 01:32:20 UTC (rev
7217)
@@ -150,12 +150,12 @@
_Statistics
+ amax - the maximum along dimension m
+ amin - the minimum along dimension m
corrcoef - correlation coefficient
cov - covariance matrix
- amax - the maximum along dimension m
mean - the mean along dimension m
median - the median along dimension m
- amin - the minimum along dimension m
norm - the norm of vector x
prod - the product along dimension m
ptp - the max-min along dimension m
@@ -185,12 +185,14 @@
_Other
angle - the angle of a complex array
- griddata - interpolate irregularly distributed data to a regular grid
- load - load ASCII data into array
+ griddata - interpolate irregularly distributed data to a regular grid
+ load - Deprecated--please use loadtxt.
+ loadtxt - load ASCII data into array.
polyfit - fit x, y to an n-th order polynomial
polyval - evaluate an n-th order polynomial
roots - the roots of the polynomial coefficients in p
- save - save an array to an ASCII file
+ save - Deprecated--please use savetxt.
+ savetxt - save an array to an ASCII file.
trapz - trapezoidal integration
__end
@@ -198,12 +200,9 @@
"""
import sys, warnings
-from cbook import flatten, is_string_like, exception_to_str, popd, \
+from cbook import flatten, is_string_like, exception_to_str, \
silent_list, iterable, dedent
-import numpy as np
-from numpy import ma
-
from matplotlib import mpl # pulls in most modules
from matplotlib.dates import date2num, num2date,\
@@ -214,45 +213,38 @@
DayLocator, HourLocator, MinuteLocator, SecondLocator,\
rrule, MO, TU, WE, TH, FR, SA, SU, YEARLY, MONTHLY,\
WEEKLY, DAILY, HOURLY, MINUTELY, SECONDLY, relativedelta
-import matplotlib.dates
+import matplotlib.dates # Do we need this at all?
+
# bring all the symbols in so folks can import them from
# pylab in one fell swoop
-from matplotlib.mlab import window_hanning, window_none,\
- conv, detrend, detrend_mean, detrend_none, detrend_linear,\
- polyfit, polyval, entropy, normpdf, griddata,\
- levypdf, find, trapz, prepca, rem, norm, orth, rank,\
- sqrtm, prctile, center_matrix, rk4, exp_safe, amap,\
- sum_flat, mean_flat, rms_flat, l1norm, l2norm, norm, frange,\
- diagonal_matrix, base_repr, binary_repr, log2, ispower2,\
- bivariate_normal, load, save
-from matplotlib.mlab import stineman_interp, slopes, \
- stineman_interp, inside_poly, poly_below, poly_between, \
+## We are still importing too many things from mlab; more cleanup is needed.
+
+from matplotlib.mlab import griddata, stineman_interp, slopes, \
+ inside_poly, poly_below, poly_between, \
is_closed_polygon, path_length, distances_along_curve, vector_lengths
-from numpy import *
-from numpy.fft import *
-from numpy.random import *
-from numpy.linalg import *
-
-from matplotlib.mlab import window_hanning, window_none, conv, detrend,
demean, \
+from matplotlib.mlab import window_hanning, window_none, detrend, demean, \
detrend_mean, detrend_none, detrend_linear, entropy, normpdf, levypdf, \
find, longest_contiguous_ones, longest_ones, prepca, prctile,
prctile_rank, \
center_matrix, rk4, bivariate_normal, get_xyz_where, get_sparse_matrix,
dist, \
dist_point_to_segment, segments_intersect, fftsurr, liaupunov, movavg, \
save, load, exp_safe, \
- amap, rms_flat, l1norm, l2norm, norm_flat, frange, diagonal_matrix,
identity, \
- base_repr, binary_repr, log2, ispower2, fromfunction_kw, rem, norm, orth,
rank, sqrtm,\
- mfuncC, approx_real, rec_append_field, rec_drop_fields, rec_join,
csv2rec, rec2csv, isvector
+ amap, rms_flat, l1norm, l2norm, norm_flat, frange, identity, \
+ base_repr, binary_repr, log2, ispower2, \
+ rec_append_fields, rec_drop_fields, rec_join, csv2rec, rec2csv, isvector
+from numpy import *
+from numpy.fft import *
+from numpy.random import *
+from numpy.linalg import *
-
-
-
from matplotlib.pyplot import *
# provide the recommended module abbrevs in the pylab namespace
import matplotlib.pyplot as plt
import numpy as np
+import numpy.ma as ma
+
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins