|
From: <nn...@us...> - 2007-07-19 15:26:28
|
Revision: 3574
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3574&view=rev
Author: nnemec
Date: 2007-07-19 08:26:27 -0700 (Thu, 19 Jul 2007)
Log Message:
-----------
minimized remaining numerix wrapper code
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/numerix/__init__.py
trunk/matplotlib/setup.py
Added Paths:
-----------
trunk/matplotlib/lib/matplotlib/numerix/fft.py
trunk/matplotlib/lib/matplotlib/numerix/linear_algebra.py
trunk/matplotlib/lib/matplotlib/numerix/ma.py
trunk/matplotlib/lib/matplotlib/numerix/mlab.py
trunk/matplotlib/lib/matplotlib/numerix/npyma.py
trunk/matplotlib/lib/matplotlib/numerix/random_array.py
Removed Paths:
-------------
trunk/matplotlib/NUMARRAY_ISSUES
trunk/matplotlib/lib/matplotlib/numerix/_na_imports.py
trunk/matplotlib/lib/matplotlib/numerix/_nc_imports.py
trunk/matplotlib/lib/matplotlib/numerix/_sp_imports.py
trunk/matplotlib/lib/matplotlib/numerix/fft/
trunk/matplotlib/lib/matplotlib/numerix/linear_algebra/
trunk/matplotlib/lib/matplotlib/numerix/ma/
trunk/matplotlib/lib/matplotlib/numerix/mlab/
trunk/matplotlib/lib/matplotlib/numerix/npyma/
trunk/matplotlib/lib/matplotlib/numerix/random_array/
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2007-07-19 03:53:37 UTC (rev 3573)
+++ trunk/matplotlib/CHANGELOG 2007-07-19 15:26:27 UTC (rev 3574)
@@ -1,3 +1,7 @@
+2007-07-19 replaced the Python code in numerix/ by a minimal wrapper around
+ numpy that explicitly mentions all symbols that need to be
+ addressed for further numpification - NN
+
2007-07-18 make usetex respect changes to rcParams. texmanager used to
only configure itself when it was created, now it
reconfigures when rcParams are changed. Thank you Alexander
Deleted: trunk/matplotlib/NUMARRAY_ISSUES
===================================================================
--- trunk/matplotlib/NUMARRAY_ISSUES 2007-07-19 03:53:37 UTC (rev 3573)
+++ trunk/matplotlib/NUMARRAY_ISSUES 2007-07-19 15:26:27 UTC (rev 3574)
@@ -1,27 +0,0 @@
-Todd Miller has added a matplotlib.numerix module to allow matplotlib
-to choose between Numeric or numarry. See the header of that file for
-information on how to choose between Numeric or Numarray from the
-command line or using environment variables.
-
-For the most part this is seamless and should provide any problems.
-Below is a status report of known issues
-
-* divide array by float - Many of the matplotlib examples do things
- like exp(-t/2.0) where t is an array. If you have 'from __future__
- import division (as matplotlib.matlab does) then you will get an
- error along the lines of
-
- TypeError: unsupported operand type(s) for /: 'NumArray' and 'float'"
-
- Solution: use numarray 0.9 or later; for older versions, use
- divide(-t, 2.0)
-
-* stock demo does not run with "TypeError: unsubscriptable object"
-
- Solution: array resize/reshape bug fixed in numarray CVS
-
-* Use of convolve in csd demo fails with "ValueError: Invalid
- convolution mode"
-
- Solution: fixed in numarray CVS
-
Modified: trunk/matplotlib/lib/matplotlib/numerix/__init__.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/numerix/__init__.py 2007-07-19 03:53:37 UTC (rev 3573)
+++ trunk/matplotlib/lib/matplotlib/numerix/__init__.py 2007-07-19 15:26:27 UTC (rev 3574)
@@ -1,171 +1,54 @@
-"""
-numerix imports either Numeric or numarray based on various selectors.
+import sys
-0. If the value "--numpy","--numarray" or "--Numeric" is specified on the
- command line, then numerix imports the specified
- array package.
-
-1. The value of numerix in matplotlibrc: either Numeric or numarray
-
-2. If none of the above is done, the default array package is Numeric.
- Because the matplotlibrc always provides *some* value for numerix
- (it has it's own system of default values), this default is most
- likely never used.
-
-To summarize: the commandline is examined first, the rc file second,
-and the default array package is Numeric.
-"""
-
-import sys, os, struct
-from matplotlib import rcParams, verbose
-
-which = None, None
use_maskedarray = None
-# First, see if --numarray or --Numeric was specified on the command
-# line:
-
for a in sys.argv:
- if a in ["--Numeric", "--numeric", "--NUMERIC",
- "--Numarray", "--numarray", "--NUMARRAY",
- "--NumPy", "--numpy", "--NUMPY", "--Numpy",
- ]:
- which = a[2:], "command line"
if a == "--maskedarray":
use_maskedarray = True
if a == "--ma":
use_maskedarray = False
del a
-if which[0] is None:
- try: # In theory, rcParams always has *some* value for numerix.
- which = rcParams['numerix'], "rc"
- except KeyError:
- pass
-
if use_maskedarray is None:
+ import matplotlib
try:
- use_maskedarray = rcParams['maskedarray']
+ use_maskedarray = matplotlib.rcParams['maskedarray']
except KeyError:
use_maskedarray = False
-# If all the above fail, default to Numeric. Most likely not used.
-if which[0] is None:
- which = "numeric", "defaulted"
+#########################
-which = which[0].strip().lower(), which[1]
-if which[0] not in ["numeric", "numarray", "numpy"]:
- raise ValueError("numerix selector must be either 'Numeric', 'numarray', or 'numpy' but the value obtained from the %s was '%s'." % (which[1], which[0]))
+from numpy import *
-if which[0] == "numarray":
- import warnings
- warnings.warn("numarray use as a numerix backed for matplotlib is deprecated",
- DeprecationWarning, stacklevel=1)
+#########################
- #from na_imports import *
- from numarray import *
- from _na_imports import nx, inf, infinity, Infinity, Matrix, isnan, all
- from numarray.numeric import nonzero
- from numarray.convolve import cross_correlate, convolve
- import numarray
- version = 'numarray %s'%numarray.__version__
- nan = struct.unpack('d', struct.pack('Q', 0x7ff8000000000000))[0]
+asum = sum
+matrixmultiply = dot
-elif which[0] == "numeric":
- import warnings
- warnings.warn("Numeric use as a numerix backed for matplotlib is deprecated",
- DeprecationWarning, stacklevel=1)
+#from numpy.oldnumeric import *
+from numpy.oldnumeric import \
+ ArrayType, cross_correlate, NewAxis, \
+ arrayrange, innerproduct, outerproduct
- #from nc_imports import *
- from Numeric import *
- from _nc_imports import nx, inf, infinity, Infinity, isnan, all, any
- from Matrix import Matrix
- import Numeric
- version = 'Numeric %s'%Numeric.__version__
- nan = struct.unpack('d', struct.pack('Q', 0x7ff8000000000000))[0]
+newaxis = NewAxis
-elif which[0] == "numpy":
- try:
- import numpy.oldnumeric as numpy
- from numpy.oldnumeric import *
- except ImportError:
- import numpy
- from numpy import *
- print 'except asarray', asarray
- from _sp_imports import nx, infinity, rand, randn, isnan, all, any
- from _sp_imports import UInt8, UInt16, UInt32, Infinity
- try:
- from numpy.oldnumeric.matrix import Matrix
- except ImportError:
- Matrix = matrix
- version = 'numpy %s' % numpy.__version__
- from numpy import nan
-else:
- raise RuntimeError("invalid numerix selector")
+from numpy.oldnumeric import Int8, UInt8, \
+ Int16, UInt16, \
+ Int32, UInt32, \
+ Float32, Float64, \
+ Complex32, Complex64, \
+ Float, Int, Complex
+from numpy.oldnumeric.matrix import Matrix
-# Some changes are only applicable to the new numpy:
-if (which[0] == 'numarray' or
- which[0] == 'numeric'):
- from mlab import amin, amax
- newaxis = NewAxis
- def typecode(a):
- return a.typecode()
- def iscontiguous(a):
- return a.iscontiguous()
- def byteswapped(a):
- return a.byteswapped()
- def itemsize(a):
- return a.itemsize()
- def angle(a):
- return arctan2(a.imag, a.real)
+from numpy.oldnumeric.mlab import min as amin
+from numpy.oldnumeric.mlab import max as amax
-else:
- # We've already checked for a valid numerix selector,
- # so assume numpy.
- from mlab import amin, amax
- newaxis = NewAxis
- from numpy import angle
- def typecode(a):
- return a.dtype.char
- def iscontiguous(a):
- return a.flags.contiguous
- def byteswapped(a):
- return a.byteswap()
- def itemsize(a):
- return a.itemsize
-
-verbose.report('numerix %s'%version)
-# a bug fix for blas numeric suggested by Fernando Perez
-matrixmultiply=dot
-asum = sum
-
-
-def _import_fail_message(module, version):
- """Prints a message when the array package specific version of an extension
- fails to import correctly.
- """
- _dict = { "which" : which[0],
- "module" : module,
- "specific" : version + module
- }
- print """
-The import of the %(which)s version of the %(module)s module,
-%(specific)s, failed. This is is either because %(which)s was
-unavailable when matplotlib was compiled, because a dependency of
-%(specific)s could not be satisfied, or because the build flag for
-this module was turned off in setup.py. If it appears that
-%(specific)s was not built, make sure you have a working copy of
-%(which)s and then re-install matplotlib. Otherwise, the following
-traceback gives more details:\n""" % _dict
-
-g = globals()
-l = locals()
-__import__('ma', g, l)
-__import__('fft', g, l)
-__import__('linear_algebra', g, l)
-__import__('random_array', g, l)
-__import__('mlab', g, l)
-
-la = linear_algebra
-ra = random_array
+def typecode(a):
+ return a.dtype.char
+def iscontiguous(a):
+ return a.flags.contiguous
+def byteswapped(a):
+ return a.byteswap()
+def itemsize(a):
+ return a.itemsize
Deleted: trunk/matplotlib/lib/matplotlib/numerix/_na_imports.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/numerix/_na_imports.py 2007-07-19 03:53:37 UTC (rev 3573)
+++ trunk/matplotlib/lib/matplotlib/numerix/_na_imports.py 2007-07-19 15:26:27 UTC (rev 3574)
@@ -1,76 +0,0 @@
-"""Imports from numarray for numerix, the numarray/Numeric interchangeability
-module. These array functions are used when numarray is chosen.
-"""
-from numarray import Int8, UInt8, Int16, UInt16, Int32, UInt32, \
- Float32, Float64, Complex32, Complex64, Float, Int, Complex,\
- typecode
-import numarray.ieeespecial as _ieee
-inf = infinity = infty = Infinity = _ieee.inf
-isnan = _ieee.isnan
-
-class _TypeNamespace:
- """Numeric compatible type aliases for use with extension functions."""
- Int8 = typecode[Int8]
- UInt8 = typecode[UInt8]
- Int16 = typecode[Int16]
- UInt16 = typecode[UInt16]
- Int32 = typecode[Int32]
- #UInt32 = typecode[UInt32] # Todd: this appears broken
- Float32 = typecode[Float32]
- Float64 = typecode[Float64]
- Complex32 = typecode[Complex32]
- Complex64 = typecode[Complex64]
-
-nx = _TypeNamespace()
-
-from numarray import asarray, dot, fromlist, NumArray, shape, alltrue
-from numarray import all as _all
-
-def all(a, axis=None):
- '''Numpy-compatible version of all()'''
- if axis is None:
- return _all(a)
- return alltrue(a, axis)
-
-class _Matrix(NumArray):
- """_Matrix is a ported, stripped down version of the Numeric Matrix
- class which supplies only matrix multiplication.
- """
- def _rc(self, a):
- if len(shape(a)) == 0:
- return a
- else:
- return Matrix(a)
-
- def __mul__(self, other):
- aother = asarray(other)
- #if len(aother.shape) == 0:
- # return self._rc(self*aother)
- #else:
- # return self._rc(dot(self, aother))
- #return self._rc(dot(self, aother))
- return dot(self, aother)
-
- def __rmul__(self, other):
- aother = asarray(other)
- if len(aother.shape) == 0:
- return self._rc(aother*self)
- else:
- return self._rc(dot(aother, self))
-
- def __imul__(self,other):
- aother = asarray(other)
- self[:] = dot(self, aother)
- return self
-
-def Matrix(data, typecode=None, copy=1, savespace=0):
- """Matrix constructs new matrices from 2D nested lists of numbers"""
- if isinstance(data, type("")):
- raise TypeError("numerix Matrix does not support Numeric matrix string notation. Use nested lists.")
- a = fromlist(data, type=typecode)
- if a.rank == 0:
- a.shape = (1,1)
- elif a.rank == 1:
- a.shape = (1,) + a.shape
- a.__class__ = _Matrix
- return a
Deleted: trunk/matplotlib/lib/matplotlib/numerix/_nc_imports.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/numerix/_nc_imports.py 2007-07-19 03:53:37 UTC (rev 3573)
+++ trunk/matplotlib/lib/matplotlib/numerix/_nc_imports.py 2007-07-19 15:26:27 UTC (rev 3574)
@@ -1,42 +0,0 @@
-from Numeric import array, ravel, reshape, shape, alltrue, sometrue
-from Numeric import Int8, UInt8, Int16, UInt16, Int32, UInt32, \
- Float32, Float64, Complex32, Complex64, Float, Int, Complex
-from numpy import isnan as _isnan
-
-class _TypeNamespace:
- """Numeric compatible type aliases for use with extension functions."""
- Int8 = Int8
- UInt8 = UInt8
- Int16 = Int16
- UInt16 = UInt16
- Int32 = Int32
- UInt32 = UInt32
- Float32 = Float32
- Float64 = Float64
- Complex32 = Complex32
- Complex64 = Complex64
-
-nx = _TypeNamespace()
-
-def isnan(a):
- """y = isnan(x) returns True where x is Not-A-Number"""
- return reshape(array([_isnan(i) for i in ravel(a)],'b'), shape(a))
-
-def all(a, axis=None):
- '''Numpy-compatible version of all()'''
- if axis is None:
- return alltrue(ravel(a))
- else:
- return alltrue(a, axis)
-
-def any(a, axis=None):
- if axis is None:
- return sometrue(ravel(a))
- else:
- return sometrue(a, axis)
-
-
-# inf is useful for testing infinities in results of array divisions
-# (which don't raise exceptions)
-
-inf = infty = infinity = Infinity = (array([1])/0.0)[0]
Deleted: trunk/matplotlib/lib/matplotlib/numerix/_sp_imports.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/numerix/_sp_imports.py 2007-07-19 03:53:37 UTC (rev 3573)
+++ trunk/matplotlib/lib/matplotlib/numerix/_sp_imports.py 2007-07-19 15:26:27 UTC (rev 3574)
@@ -1,34 +0,0 @@
-try:
- from numpy.oldnumeric import Int8, UInt8, \
- Int16, UInt16, \
- Int32, UInt32, \
- Float32, Float64, \
- Complex32, Complex64, \
- Float, Int, Complex
-except ImportError:
- from numpy import Int8, UInt8, \
- Int16, UInt16, \
- Int32, UInt32, \
- Float32, Float64, \
- Complex32, Complex64, \
- Float, Int, Complex
-
-class _TypeNamespace:
- """Numeric compatible type aliases for use with extension functions."""
- Int8 = Int8
- UInt8 = UInt8
- Int16 = Int16
- UInt16 = UInt16
- Int32 = Int32
- UInt32 = UInt32
- Float32 = Float32
- Float64 = Float64
- Complex32 = Complex32
- Complex64 = Complex64
-
-nx = _TypeNamespace()
-
-from numpy import inf, infty, Infinity
-from numpy.random import rand, randn
-infinity = Infinity
-from numpy import all, isnan, any
Added: trunk/matplotlib/lib/matplotlib/numerix/fft.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/numerix/fft.py (rev 0)
+++ trunk/matplotlib/lib/matplotlib/numerix/fft.py 2007-07-19 15:26:27 UTC (rev 3574)
@@ -0,0 +1 @@
+from numpy.oldnumeric.fft import *
Added: trunk/matplotlib/lib/matplotlib/numerix/linear_algebra.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/numerix/linear_algebra.py (rev 0)
+++ trunk/matplotlib/lib/matplotlib/numerix/linear_algebra.py 2007-07-19 15:26:27 UTC (rev 3574)
@@ -0,0 +1 @@
+from numpy.oldnumeric.linear_algebra import *
Added: trunk/matplotlib/lib/matplotlib/numerix/ma.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/numerix/ma.py (rev 0)
+++ trunk/matplotlib/lib/matplotlib/numerix/ma.py 2007-07-19 15:26:27 UTC (rev 3574)
@@ -0,0 +1,16 @@
+from matplotlib.numerix import use_maskedarray
+
+from numpy.core.ma import *
+
+if use_maskedarray:
+ from maskedarray import *
+ print "using maskedarray"
+else:
+ from numpy.core.ma import *
+ #print "using ma"
+
+def getmaskorNone(obj):
+ _msk = getmask(obj)
+ if _msk is nomask:
+ return None
+ return _msk
Added: trunk/matplotlib/lib/matplotlib/numerix/mlab.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/numerix/mlab.py (rev 0)
+++ trunk/matplotlib/lib/matplotlib/numerix/mlab.py 2007-07-19 15:26:27 UTC (rev 3574)
@@ -0,0 +1,4 @@
+from numpy.oldnumeric.mlab import *
+
+amin = min
+amax = max
Added: trunk/matplotlib/lib/matplotlib/numerix/npyma.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/numerix/npyma.py (rev 0)
+++ trunk/matplotlib/lib/matplotlib/numerix/npyma.py 2007-07-19 15:26:27 UTC (rev 3574)
@@ -0,0 +1,10 @@
+from matplotlib.numerix import use_maskedarray
+
+from numpy.core.ma import *
+
+if use_maskedarray:
+ from maskedarray import *
+ print "using maskedarray"
+else:
+ from numpy.core.ma import *
+ #print "using ma"
Added: trunk/matplotlib/lib/matplotlib/numerix/random_array.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/numerix/random_array.py (rev 0)
+++ trunk/matplotlib/lib/matplotlib/numerix/random_array.py 2007-07-19 15:26:27 UTC (rev 3574)
@@ -0,0 +1 @@
+from numpy.oldnumeric.random_array import *
Modified: trunk/matplotlib/setup.py
===================================================================
--- trunk/matplotlib/setup.py 2007-07-19 03:53:37 UTC (rev 3573)
+++ trunk/matplotlib/setup.py 2007-07-19 15:26:27 UTC (rev 3574)
@@ -124,12 +124,6 @@
'matplotlib.backends',
'matplotlib.toolkits',
'matplotlib.numerix',
- 'matplotlib.numerix.mlab',
- 'matplotlib.numerix.ma',
- 'matplotlib.numerix.npyma',
- 'matplotlib.numerix.linear_algebra',
- 'matplotlib.numerix.random_array',
- 'matplotlib.numerix.fft',
]
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|