From: John H. <jdh...@ac...> - 2005-01-21 20:17:02
|
Following the extended discussion of namespace clashes on the dev and users list, and some discussions with Todd offlist, I took a new approach to fix these problems. The central sticking points were 1) pylab should not override built-ins 2) numerix should be faithful to the underlying packages while providing a consistent interface to them. Hence numerix would not change the names of the functions in mlab 3) pylab imports the numerix symbols, but didn't want to have a different policy than numerix. The resolution to this dilemma was to refactor numerix to preserve the namespaces. numerix now attempts to mirrors the numarray directory structure for namespaces (though this is currently incomplete as I just added enough to satisfy the needs of matplotlib). So you now do from matplotlib.numerix.mlab import min, max, mean from matplotlib.numerix import arange, array from matplotlib.fft import fft and you'll get the proper symbols from Numeric or numarray depending on your numerix setting. For convenience I added amin, amax to mlab and asum to numerix, though the original python incompatible symbols min, max, sum still reside in their correct numerix locations unchanged. At some point Todd will pull numerix out as a freestanding module, I think, which will make for less typing since the matplotlib prefix can be removed. The decision for numerix package structure to mirror numarray's seems like a good one to me, since everyone is still hoping to see Numeric disappear, and this provides the most natural path. When the great merging occurs, one can simply globally replace numerix with numarray and everything will follow. pylab still imports (almost) all the symbols from numerix, numerix.mlab, etc, except the ones that clash with python names. In their stead, pylab imports amin, amax and asym. pylab also tries to be a good citizen and defines __all__, to avoid problems like the time module problem described by danny on the user's list. This is explained in a little more detail in API_CHANGES. I've tested this a good bit and everything seems to be working. I am trying to get a release out the door for Joe Cooper to fold into his enthought build which is going out Monday. I would like to put a release up this afternoon on the user's list. Would you kind folks here mind taking this for a test drive and submit comments, feedback, problems, back to me as soon as possible? http://jdh.uchicago.edu/share/matplotlib-0.71rc1.tar.gz It would also be helpful if you would inspect the __all__ var of pylab to see if you think its correct. Currently: date2num, num2date, drange, epoch2num, num2epoch, mx2num, DateFormatter, IndexDateFormatter, DateLocator, RRuleLocator, YearLocator, MonthLocator, WeekdayLocator, DayLocator, HourLocator, MinuteLocator, SecondLocator, rrule, MO, TU, WE, TH, FR, SA, SU, YEARLY, MONTHLY, WEEKLY, DAILY, HOURLY, MINUTELY, SECONDLY, relativedelta, array, zeros, shape, rank, size, fromstring, take, put, putmask, reshape, repeat, choose, searchsorted, asum, cumsum, product, cumproduct, alltrue, sometrue, allclose, arrayrange, arange, asarray, convolve, swapaxes, concatenate, transpose, sort, argsort, argmax, argmin, innerproduct, dot, outerproduct, resize, indices, fromfunction, diagonal, trace, ravel, nonzero, shape, where, compress, clip, zeros, ones, identity, add, logical_or, exp, subtract, logical_xor, log, multiply, logical_not, log10, divide, maximum, sin, minimum, sinh, conjugate, bitwise_and, sqrt, power, bitwise_or, tan, absolute, bitwise_xor, tanh, negative, ceil, greater, fabs, greater_equal, floor, less, arccos, arctan2, less_equal, arcsin, fmod, equal, arctan, hypot, not_equal, cos, around, logical_and, cosh, arccosh, arcsinh, arctanh, cross_correlate, pi, ArrayType, matrixmultiply, rand, randn, eye, tri, diag, fliplr, flipud, rot90, tril, triu, ptp, mean, msort, median, std, cumsum, prod, cumprod, trapz, diff, cov, corrcoef, squeeze, kaiser, blackman, bartlett, hanning, hamming, sinc, eig, svd, angle, roots, amin, amax, linspace, window_hanning, window_none, conv, detrend, detrend_mean, detrend_none, detrend_linear, corrcoef, polyfit, polyval, vander, entropy, normpdf, levypdf, find, trapz, prepca, fix, rem, norm, orth, rank, sqrtm, prctile, center_matrix, meshgrid, rk4, exp_safe, amap, sum_flat, mean_flat, rms_flat, l1norm, l2norm, norm, frange, diagonal_matrix, base_repr, binary_repr, log2, ispower2, bivariate_normal, inverse, eigenvectors, fft, Int8, UInt8, Int16, UInt16, Int32, UInt32, Float32, Float64, Complex32, Complex64, Float, Int, Complex, TickHelper, Formatter, FixedFormatter, NullFormatter, FuncFormatter, FormatStrFormatter, ScalarFormatter, LogFormatter, LogFormatterExponent, LogFormatterMathtext, Locator, IndexLocator, FixedLocator, NullLocator, LinearLocator, LogLocator, AutoLocator, MultipleLocator, plotting, colormaps, get_current_fig_manager, connect, disconnect, get_plot_commands, raise_msg_to_str, axis, axes, delaxes, clim, close, clf, colorbar, draw, figtext, figimage, figlegend, figure, gca, gcf, gci, get, hold, ishold, isinteractive, imread, load, rc, rcdefaults, save, savefig, set, subplot, title, xlabel, ylabel, xlim, ylim, xticks, rgrids, thetagrids, yticks, polar, over, ioff, ion, axhline, axhspan, axvline, axvspan, bar, barh, cohere, contour, csd, errorbar, fill, hist, hlines, imshow, loglog, pcolor, pcolor_classic, pie, plot, plot_date, psd, scatter, scatter_classic, semilogx, semilogy, specgram, spy, spy2, stem, vlines, cla, grid, legend, table, text, autumn, bone, cool, copper, flag, gray, hot, hsv, jet, pink, prism, spring, summer, winter, Line2D, Polygon, Rectangle, Circle, Text, cm, get_cmap, normalize, show Thanks! JDH |