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

Skip to content

Commit 160d38e

Browse files
committed
Numpification of contour, stage 1
svn path=/trunk/matplotlib/; revision=3401
1 parent 7ede153 commit 160d38e

File tree

5 files changed

+16
-120
lines changed

5 files changed

+16
-120
lines changed

lib/matplotlib/_contour.py

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

lib/matplotlib/contour.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
cos, nonzero, take, concatenate, all, newaxis
1616

1717
from mlab import linspace, meshgrid
18-
import _contour
18+
import matplotlib._cntr as _cntr
1919
from cm import ScalarMappable
2020
from cbook import iterable, is_string_like, flatten, enumerate, \
2121
allequal, dict_delall, strip_math, popall, silent_list
@@ -449,7 +449,7 @@ def __init__(self, ax, *args, **kwargs):
449449
self.linewidths = 0.05 # Good default for Postscript.
450450
if iterable(self.linewidths):
451451
self.linewidths = self.linewidths[0]
452-
C = _contour.Cntr(x, y, z.filled(), ma.getmaskorNone(z))
452+
C = _cntr.Cntr(x, y, z.filled(), ma.getmaskorNone(z))
453453
lowers = self._levels[:-1]
454454
uppers = self._levels[1:]
455455
for level, level_upper in zip(lowers, uppers):
@@ -465,7 +465,7 @@ def __init__(self, ax, *args, **kwargs):
465465
else:
466466
tlinewidths = self._process_linewidths()
467467
self.tlinewidths = tlinewidths
468-
C = _contour.Cntr(x, y, z.filled(), ma.getmaskorNone(z))
468+
C = _cntr.Cntr(x, y, z.filled(), ma.getmaskorNone(z))
469469
for level, width in zip(self.levels, tlinewidths):
470470
nlist = C.trace(level, points = 0)
471471
col = LineCollection(nlist,

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ def havegtk():
275275
build_image(ext_modules, packages, NUMERIX)
276276

277277
if 1: # I don't think we need to make these optional
278-
build_contour(ext_modules, packages, NUMERIX)
278+
build_contour(ext_modules, packages)
279279
build_nxutils(ext_modules, packages, NUMERIX)
280280

281281
for mod in ext_modules:

setupext.py

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -844,43 +844,18 @@ def build_enthought(ext_modules, packages):
844844
])
845845
BUILT_ENTHOUGHT = True
846846

847-
def build_contour(ext_modules, packages, numerix):
847+
def build_contour(ext_modules, packages):
848848
global BUILT_CONTOUR
849849
if BUILT_CONTOUR: return # only build it if you you haven't already
850850

851-
if 'numarray' in numerix: # Build for numarray
852-
temp_copy('src/cntr.c', 'src/_na_cntr.c')
853-
module = Extension(
854-
'matplotlib._na_cntr',
855-
[ 'src/_na_cntr.c',],
856-
include_dirs=numarray_inc_dirs,
857-
)
858-
module.extra_compile_args.append('-DNUMARRAY=1')
859-
add_base_flags(module)
860-
ext_modules.append(module)
861-
862-
if 'Numeric' in numerix: # Build for Numeric
863-
temp_copy('src/cntr.c', 'src/_nc_cntr.c')
864-
module = Extension(
865-
'matplotlib._nc_cntr',
866-
[ 'src/_nc_cntr.c'],
867-
include_dirs=numeric_inc_dirs,
868-
)
869-
module.extra_compile_args.append('-DNUMERIC=1')
870-
add_base_flags(module)
871-
ext_modules.append(module)
872-
if 'numpy' in numerix: # Build for numpy
873-
temp_copy('src/cntr.c', 'src/_ns_cntr.c')
874-
module = Extension(
875-
'matplotlib._ns_cntr',
876-
[ 'src/_ns_cntr.c'],
877-
include_dirs=numeric_inc_dirs,
878-
)
879-
add_numpy_flags(module)
880-
module.extra_compile_args.append('-DSCIPY=1')
881-
add_base_flags(module)
882-
ext_modules.append(module)
883-
851+
module = Extension(
852+
'matplotlib._cntr',
853+
[ 'src/cntr.c'],
854+
include_dirs=numeric_inc_dirs,
855+
)
856+
add_numpy_flags(module)
857+
add_base_flags(module)
858+
ext_modules.append(module)
884859

885860
BUILT_CONTOUR = True
886861

src/cntr.c

Lines changed: 3 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1731,71 +1731,16 @@ static PyMethodDef module_methods[] = {
17311731
{NULL} /* Sentinel */
17321732
};
17331733

1734-
1735-
#ifdef NUMARRAY
1736-
#if PY_MINOR_VERSION > 2
1737-
PyMODINIT_FUNC
1738-
#else
1739-
DL_EXPORT(void)
1740-
#endif
1741-
init_na_cntr(void)
1742-
{
1743-
PyObject* m;
1744-
1745-
if (PyType_Ready(&CntrType) < 0)
1746-
return;
1747-
1748-
m = Py_InitModule3("_na_cntr", module_methods,
1749-
"Contouring engine as an extension type (numarray).");
1750-
1751-
if (m == NULL)
1752-
return;
1753-
1754-
import_array();
1755-
Py_INCREF(&CntrType);
1756-
PyModule_AddObject(m, "Cntr", (PyObject *)&CntrType);
1757-
}
1758-
#endif
1759-
#ifdef NUMERIC
1760-
#if PY_MINOR_VERSION > 2
1761-
PyMODINIT_FUNC
1762-
#else
1763-
DL_EXPORT(void)
1764-
#endif
1765-
init_nc_cntr(void)
1766-
{
1767-
PyObject* m;
1768-
1769-
if (PyType_Ready(&CntrType) < 0)
1770-
return;
1771-
1772-
m = Py_InitModule3("_nc_cntr", module_methods,
1773-
"Contouring engine as an extension type (Numeric).");
1774-
1775-
if (m == NULL)
1776-
return;
1777-
1778-
import_array();
1779-
Py_INCREF(&CntrType);
1780-
PyModule_AddObject(m, "Cntr", (PyObject *)&CntrType);
1781-
}
1782-
#endif
1783-
1784-
#ifdef SCIPY
1785-
#if PY_MINOR_VERSION > 2
17861734
PyMODINIT_FUNC
1787-
#else
1788-
DL_EXPORT(void)
1789-
#endif
1790-
init_ns_cntr(void)
1735+
init_cntr(void)
17911736
{
17921737
PyObject* m;
17931738

17941739
if (PyType_Ready(&CntrType) < 0)
17951740
return;
17961741

1797-
m = Py_InitModule3("_ns_cntr", module_methods,
1798-
"Contouring engine as an extension type (Scipy).");
1742+
m = Py_InitModule3("_cntr", module_methods,
1743+
"Contouring engine as an extension type (numpy).");
17991744

18001745
if (m == NULL)
18011746
return;
@@ -1804,6 +1749,5 @@ init_ns_cntr(void)
18041749
Py_INCREF(&CntrType);
18051750
PyModule_AddObject(m, "Cntr", (PyObject *)&CntrType);
18061751
}
1807-
#endif
18081752

18091753

0 commit comments

Comments
 (0)