Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d9f3fba

Browse files
committed
minimized remaining numerix wrapper code
svn path=/trunk/matplotlib/; revision=3574
1 parent 878b636 commit d9f3fba

19 files changed

Lines changed: 64 additions & 417 deletions

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2007-07-19 replaced the Python code in numerix/ by a minimal wrapper around
2+
numpy that explicitly mentions all symbols that need to be
3+
addressed for further numpification - NN
4+
15
2007-07-18 make usetex respect changes to rcParams. texmanager used to
26
only configure itself when it was created, now it
37
reconfigures when rcParams are changed. Thank you Alexander

NUMARRAY_ISSUES

Lines changed: 0 additions & 27 deletions
This file was deleted.

lib/matplotlib/numerix/__init__.py

Lines changed: 35 additions & 152 deletions
Original file line numberDiff line numberDiff line change
@@ -1,171 +1,54 @@
1-
"""
2-
numerix imports either Numeric or numarray based on various selectors.
1+
import sys
32

4-
0. If the value "--numpy","--numarray" or "--Numeric" is specified on the
5-
command line, then numerix imports the specified
6-
array package.
7-
8-
1. The value of numerix in matplotlibrc: either Numeric or numarray
9-
10-
2. If none of the above is done, the default array package is Numeric.
11-
Because the matplotlibrc always provides *some* value for numerix
12-
(it has it's own system of default values), this default is most
13-
likely never used.
14-
15-
To summarize: the commandline is examined first, the rc file second,
16-
and the default array package is Numeric.
17-
"""
18-
19-
import sys, os, struct
20-
from matplotlib import rcParams, verbose
21-
22-
which = None, None
233
use_maskedarray = None
244

25-
# First, see if --numarray or --Numeric was specified on the command
26-
# line:
27-
285
for a in sys.argv:
29-
if a in ["--Numeric", "--numeric", "--NUMERIC",
30-
"--Numarray", "--numarray", "--NUMARRAY",
31-
"--NumPy", "--numpy", "--NUMPY", "--Numpy",
32-
]:
33-
which = a[2:], "command line"
346
if a == "--maskedarray":
357
use_maskedarray = True
368
if a == "--ma":
379
use_maskedarray = False
3810
del a
3911

40-
if which[0] is None:
41-
try: # In theory, rcParams always has *some* value for numerix.
42-
which = rcParams['numerix'], "rc"
43-
except KeyError:
44-
pass
45-
4612
if use_maskedarray is None:
13+
import matplotlib
4714
try:
48-
use_maskedarray = rcParams['maskedarray']
15+
use_maskedarray = matplotlib.rcParams['maskedarray']
4916
except KeyError:
5017
use_maskedarray = False
5118

52-
# If all the above fail, default to Numeric. Most likely not used.
53-
if which[0] is None:
54-
which = "numeric", "defaulted"
55-
56-
which = which[0].strip().lower(), which[1]
57-
if which[0] not in ["numeric", "numarray", "numpy"]:
58-
raise ValueError("numerix selector must be either 'Numeric', 'numarray', or 'numpy' but the value obtained from the %s was '%s'." % (which[1], which[0]))
59-
60-
if which[0] == "numarray":
61-
import warnings
62-
warnings.warn("numarray use as a numerix backed for matplotlib is deprecated",
63-
DeprecationWarning, stacklevel=1)
64-
65-
#from na_imports import *
66-
from numarray import *
67-
from _na_imports import nx, inf, infinity, Infinity, Matrix, isnan, all
68-
from numarray.numeric import nonzero
69-
from numarray.convolve import cross_correlate, convolve
70-
import numarray
71-
version = 'numarray %s'%numarray.__version__
72-
nan = struct.unpack('d', struct.pack('Q', 0x7ff8000000000000))[0]
19+
#########################
7320

74-
elif which[0] == "numeric":
75-
import warnings
76-
warnings.warn("Numeric use as a numerix backed for matplotlib is deprecated",
77-
DeprecationWarning, stacklevel=1)
21+
from numpy import *
7822

79-
#from nc_imports import *
80-
from Numeric import *
81-
from _nc_imports import nx, inf, infinity, Infinity, isnan, all, any
82-
from Matrix import Matrix
83-
import Numeric
84-
version = 'Numeric %s'%Numeric.__version__
85-
nan = struct.unpack('d', struct.pack('Q', 0x7ff8000000000000))[0]
23+
#########################
8624

87-
elif which[0] == "numpy":
88-
try:
89-
import numpy.oldnumeric as numpy
90-
from numpy.oldnumeric import *
91-
except ImportError:
92-
import numpy
93-
from numpy import *
94-
print 'except asarray', asarray
95-
from _sp_imports import nx, infinity, rand, randn, isnan, all, any
96-
from _sp_imports import UInt8, UInt16, UInt32, Infinity
97-
try:
98-
from numpy.oldnumeric.matrix import Matrix
99-
except ImportError:
100-
Matrix = matrix
101-
version = 'numpy %s' % numpy.__version__
102-
from numpy import nan
103-
else:
104-
raise RuntimeError("invalid numerix selector")
105-
106-
107-
# Some changes are only applicable to the new numpy:
108-
if (which[0] == 'numarray' or
109-
which[0] == 'numeric'):
110-
from mlab import amin, amax
111-
newaxis = NewAxis
112-
def typecode(a):
113-
return a.typecode()
114-
def iscontiguous(a):
115-
return a.iscontiguous()
116-
def byteswapped(a):
117-
return a.byteswapped()
118-
def itemsize(a):
119-
return a.itemsize()
120-
def angle(a):
121-
return arctan2(a.imag, a.real)
122-
123-
else:
124-
# We've already checked for a valid numerix selector,
125-
# so assume numpy.
126-
from mlab import amin, amax
127-
newaxis = NewAxis
128-
from numpy import angle
129-
def typecode(a):
130-
return a.dtype.char
131-
def iscontiguous(a):
132-
return a.flags.contiguous
133-
def byteswapped(a):
134-
return a.byteswap()
135-
def itemsize(a):
136-
return a.itemsize
137-
138-
verbose.report('numerix %s'%version)
139-
# a bug fix for blas numeric suggested by Fernando Perez
140-
matrixmultiply=dot
14125
asum = sum
142-
143-
144-
def _import_fail_message(module, version):
145-
"""Prints a message when the array package specific version of an extension
146-
fails to import correctly.
147-
"""
148-
_dict = { "which" : which[0],
149-
"module" : module,
150-
"specific" : version + module
151-
}
152-
print """
153-
The import of the %(which)s version of the %(module)s module,
154-
%(specific)s, failed. This is is either because %(which)s was
155-
unavailable when matplotlib was compiled, because a dependency of
156-
%(specific)s could not be satisfied, or because the build flag for
157-
this module was turned off in setup.py. If it appears that
158-
%(specific)s was not built, make sure you have a working copy of
159-
%(which)s and then re-install matplotlib. Otherwise, the following
160-
traceback gives more details:\n""" % _dict
161-
162-
g = globals()
163-
l = locals()
164-
__import__('ma', g, l)
165-
__import__('fft', g, l)
166-
__import__('linear_algebra', g, l)
167-
__import__('random_array', g, l)
168-
__import__('mlab', g, l)
169-
170-
la = linear_algebra
171-
ra = random_array
26+
matrixmultiply = dot
27+
28+
#from numpy.oldnumeric import *
29+
from numpy.oldnumeric import \
30+
ArrayType, cross_correlate, NewAxis, \
31+
arrayrange, innerproduct, outerproduct
32+
33+
newaxis = NewAxis
34+
35+
from numpy.oldnumeric import Int8, UInt8, \
36+
Int16, UInt16, \
37+
Int32, UInt32, \
38+
Float32, Float64, \
39+
Complex32, Complex64, \
40+
Float, Int, Complex
41+
42+
from numpy.oldnumeric.matrix import Matrix
43+
44+
from numpy.oldnumeric.mlab import min as amin
45+
from numpy.oldnumeric.mlab import max as amax
46+
47+
def typecode(a):
48+
return a.dtype.char
49+
def iscontiguous(a):
50+
return a.flags.contiguous
51+
def byteswapped(a):
52+
return a.byteswap()
53+
def itemsize(a):
54+
return a.itemsize

lib/matplotlib/numerix/_na_imports.py

Lines changed: 0 additions & 76 deletions
This file was deleted.

lib/matplotlib/numerix/_nc_imports.py

Lines changed: 0 additions & 42 deletions
This file was deleted.

lib/matplotlib/numerix/_sp_imports.py

Lines changed: 0 additions & 34 deletions
This file was deleted.

lib/matplotlib/numerix/fft.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from numpy.oldnumeric.fft import *

0 commit comments

Comments
 (0)