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

Skip to content

Commit dec6a53

Browse files
committed
Restore a stripped-down numerix with a deprecation warning.
svn path=/trunk/matplotlib/; revision=6933
1 parent 6adc54e commit dec6a53

9 files changed

Lines changed: 157 additions & 2 deletions

File tree

CHANGELOG

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
2009-02-25 Remove numerix; it remains in the maintenance branches. - EF
1+
2009-02-25 Deprecate numerix, and strip out all but the numpy
2+
part of the code. - EF
23

34
2009-02-21 Improve scatter argument handling; add an early error
45
message, allow inputs to have more than one dimension. - EF

lib/matplotlib/numerix/__init__.py

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
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
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
try:
2+
from numpy.oldnumeric import Int8, UInt8, \
3+
Int16, UInt16, \
4+
Int32, UInt32, \
5+
Float32, Float64, \
6+
Complex32, Complex64, \
7+
Float, Int, Complex
8+
except ImportError:
9+
from numpy import Int8, UInt8, \
10+
Int16, UInt16, \
11+
Int32, UInt32, \
12+
Float32, Float64, \
13+
Complex32, Complex64, \
14+
Float, Int, Complex
15+
16+
class _TypeNamespace:
17+
"""Numeric compatible type aliases for use with extension functions."""
18+
Int8 = Int8
19+
UInt8 = UInt8
20+
Int16 = Int16
21+
UInt16 = UInt16
22+
Int32 = Int32
23+
UInt32 = UInt32
24+
Float32 = Float32
25+
Float64 = Float64
26+
Complex32 = Complex32
27+
Complex64 = Complex64
28+
29+
nx = _TypeNamespace()
30+
31+
from numpy import inf, infty, Infinity
32+
from numpy.random import rand, randn
33+
infinity = Infinity
34+
from numpy import all, isnan, any
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
try:
2+
from numpy.oldnumeric.fft import *
3+
except ImportError:
4+
from numpy.dft.old import *
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
try:
2+
from numpy.oldnumeric.linear_algebra import *
3+
except ImportError:
4+
from numpy.linalg.old import *
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
try:
2+
from numpy.ma import * # numpy 1.05 and later
3+
except ImportError:
4+
from numpy.core.ma import * # earlier
5+
def getmaskorNone(obj):
6+
_msk = getmask(obj)
7+
if _msk is nomask:
8+
return None
9+
return _msk
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
try:
2+
from numpy.oldnumeric.mlab import *
3+
except ImportError:
4+
from numpy.lib.mlab import *
5+
6+
amin = min
7+
amax = max
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
try:
2+
from numpy.oldnumeric.random_array import *
3+
except ImportError:
4+
from numpy.random import *

setup.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,15 @@
5252
'matplotlib.projections',
5353
# 'matplotlib.toolkits',
5454
'mpl_toolkits',
55-
'matplotlib.sphinxext'
55+
'matplotlib.sphinxext',
56+
# The following are deprecated and will be removed.
57+
'matplotlib.numerix',
58+
'matplotlib.numerix.mlab',
59+
'matplotlib.numerix.ma',
60+
'matplotlib.numerix.linear_algebra',
61+
'matplotlib.numerix.random_array',
62+
'matplotlib.numerix.fft',
63+
5664
]
5765

5866
py_modules = ['pylab']

0 commit comments

Comments
 (0)