|
| 1 | +""" |
| 2 | +numerix imports numpy with some compatibility adjustments for old |
| 3 | +code that had been based on Numeric. |
| 4 | +
|
| 5 | +It is deprecated and will go away soon. |
| 6 | +""" |
| 7 | + |
| 8 | +import sys, os, struct |
| 9 | +from matplotlib import rcParams, verbose |
| 10 | + |
| 11 | +import warnings |
| 12 | +msg = """ |
| 13 | +********************************************************** |
| 14 | +matplotlib.numerix and all its subpackages are deprecated. |
| 15 | +They will be removed soon. Please use numpy instead. |
| 16 | +********************************************************** |
| 17 | +""" |
| 18 | +warnings.warn(msg, DeprecationWarning) |
| 19 | + |
| 20 | +which = "numpy", "defaulted" # This is now the only choice |
| 21 | + |
| 22 | +try: |
| 23 | + import numpy.oldnumeric as numpy |
| 24 | + from numpy.oldnumeric import * |
| 25 | +except ImportError: |
| 26 | + import numpy |
| 27 | + from numpy import * |
| 28 | + print 'except asarray', asarray |
| 29 | +from _sp_imports import nx, infinity, rand, randn, isnan, all, any |
| 30 | +from _sp_imports import UInt8, UInt16, UInt32, Infinity |
| 31 | +try: |
| 32 | + from numpy.oldnumeric.matrix import Matrix |
| 33 | +except ImportError: |
| 34 | + Matrix = matrix |
| 35 | +version = 'numpy %s' % numpy.__version__ |
| 36 | +from numpy import nan |
| 37 | + |
| 38 | + |
| 39 | +from mlab import amin, amax |
| 40 | +newaxis = NewAxis |
| 41 | +from numpy import angle |
| 42 | +def typecode(a): |
| 43 | + return a.dtype.char |
| 44 | +def iscontiguous(a): |
| 45 | + return a.flags.contiguous |
| 46 | +def byteswapped(a): |
| 47 | + return a.byteswap() |
| 48 | +def itemsize(a): |
| 49 | + return a.itemsize |
| 50 | + |
| 51 | +verbose.report('numerix %s'%version) |
| 52 | +# a bug fix for blas numeric suggested by Fernando Perez |
| 53 | +matrixmultiply=dot |
| 54 | +asum = sum |
| 55 | + |
| 56 | + |
| 57 | +def _import_fail_message(module, version): |
| 58 | + """Prints a message when the array package specific version of an extension |
| 59 | + fails to import correctly. |
| 60 | + """ |
| 61 | + _dict = { "which" : which[0], |
| 62 | + "module" : module, |
| 63 | + "specific" : version + module |
| 64 | + } |
| 65 | + print """ |
| 66 | +The import of the %(which)s version of the %(module)s module, |
| 67 | +%(specific)s, failed. This is is either because %(which)s was |
| 68 | +unavailable when matplotlib was compiled, because a dependency of |
| 69 | +%(specific)s could not be satisfied, or because the build flag for |
| 70 | +this module was turned off in setup.py. If it appears that |
| 71 | +%(specific)s was not built, make sure you have a working copy of |
| 72 | +%(which)s and then re-install matplotlib. Otherwise, the following |
| 73 | +traceback gives more details:\n""" % _dict |
| 74 | + |
| 75 | +g = globals() |
| 76 | +l = locals() |
| 77 | +__import__('ma', g, l) |
| 78 | +__import__('fft', g, l) |
| 79 | +__import__('linear_algebra', g, l) |
| 80 | +__import__('random_array', g, l) |
| 81 | +__import__('mlab', g, l) |
| 82 | + |
| 83 | +la = linear_algebra |
| 84 | +ra = random_array |
0 commit comments