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

Skip to content

Commit 3033590

Browse files
committed
Remove unneeded function and argument from contouring internals
svn path=/trunk/matplotlib/; revision=7342
1 parent 3115976 commit 3033590

2 files changed

Lines changed: 8 additions & 49 deletions

File tree

lib/matplotlib/contour.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -601,8 +601,7 @@ def __init__(self, ax, *args, **kwargs):
601601
lowers = self._levels[:-1]
602602
uppers = self._levels[1:]
603603
for level, level_upper in zip(lowers, uppers):
604-
nlist = C.trace(level, level_upper, points = 0,
605-
nchunk = self.nchunk)
604+
nlist = C.trace(level, level_upper, nchunk = self.nchunk)
606605
nseg = len(nlist)//2
607606
segs = nlist[:nseg]
608607
kinds = nlist[nseg:]
@@ -624,7 +623,7 @@ def __init__(self, ax, *args, **kwargs):
624623
tlinestyles = self._process_linestyles()
625624
C = _cntr.Cntr(x, y, z.filled(), _mask)
626625
for level, width, lstyle in zip(self.levels, tlinewidths, tlinestyles):
627-
nlist = C.trace(level, points = 0)
626+
nlist = C.trace(level)
628627
nseg = len(nlist)//2
629628
segs = nlist[:nseg]
630629
kinds = nlist[nseg:]

src/cntr.c

Lines changed: 6 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,38 +1321,6 @@ void cntr_del(Csite *site)
13211321
site = NULL;
13221322
}
13231323

1324-
/* Build a list of lists of points, where each point is an (x,y,k)
1325-
tuple.
1326-
*/
1327-
static PyObject *
1328-
build_cntr_list_p(long *np, double *xp, double *yp, short *kp,
1329-
int nparts, long ntotal)
1330-
{
1331-
PyObject *point, *contourList, *all_contours;
1332-
int start = 0, end = 0;
1333-
int i, j, k;
1334-
1335-
all_contours = PyList_New(nparts);
1336-
1337-
for (i = 0; i < nparts; i++)
1338-
{
1339-
start = end;
1340-
end += np[i];
1341-
contourList = PyList_New(np[i]);
1342-
for (k = 0, j = start; j < end; j++, k++)
1343-
{
1344-
point = Py_BuildValue("(ddh)", xp[j], yp[j], kp[j]);
1345-
if (PyList_SetItem(contourList, k, point)) goto error;
1346-
}
1347-
if (PyList_SetItem(all_contours, i, contourList)) goto error;
1348-
}
1349-
return all_contours;
1350-
1351-
error:
1352-
Py_XDECREF(all_contours);
1353-
return NULL;
1354-
}
1355-
13561324

13571325
/* Build a list of XY 2-D arrays, shape (N,2), to which a list of K arrays
13581326
is concatenated concatenated. */
@@ -1409,7 +1377,7 @@ build_cntr_list_v2(long *np, double *xp, double *yp, short *kp,
14091377
*/
14101378

14111379
PyObject *
1412-
cntr_trace(Csite *site, double levels[], int nlevels, int points, long nchunk)
1380+
cntr_trace(Csite *site, double levels[], int nlevels, long nchunk)
14131381
{
14141382
PyObject *c_list = NULL;
14151383
double *xp0;
@@ -1491,15 +1459,8 @@ cntr_trace(Csite *site, double levels[], int nlevels, int points, long nchunk)
14911459
}
14921460
}
14931461

1462+
c_list = build_cntr_list_v2(nseg0, xp0, yp0, kp0, nparts, ntotal);
14941463

1495-
if (points) /* It is False when called; we don't need the point version */
1496-
{
1497-
c_list = build_cntr_list_p(nseg0, xp0, yp0, kp0, nparts, ntotal);
1498-
}
1499-
else
1500-
{
1501-
c_list = build_cntr_list_v2(nseg0, xp0, yp0, kp0, nparts, ntotal);
1502-
}
15031464
PyMem_Free(xp0);
15041465
PyMem_Free(yp0);
15051466
PyMem_Free(kp0);
@@ -1676,18 +1637,17 @@ Cntr_trace(Cntr *self, PyObject *args, PyObject *kwds)
16761637
{
16771638
double levels[2] = {0.0, -1e100};
16781639
int nlevels = 2;
1679-
int points = 0;
16801640
long nchunk = 0L;
1681-
static char *kwlist[] = {"level0", "level1", "points", "nchunk", NULL};
1641+
static char *kwlist[] = {"level0", "level1", "nchunk", NULL};
16821642

1683-
if (! PyArg_ParseTupleAndKeywords(args, kwds, "d|dil", kwlist,
1684-
levels, levels+1, &points, &nchunk))
1643+
if (! PyArg_ParseTupleAndKeywords(args, kwds, "d|dl", kwlist,
1644+
levels, levels+1, &nchunk))
16851645
{
16861646
return NULL;
16871647
}
16881648
if (levels[1] == -1e100 || levels[1] <= levels[0])
16891649
nlevels = 1;
1690-
return cntr_trace(self->site, levels, nlevels, points, nchunk);
1650+
return cntr_trace(self->site, levels, nlevels, nchunk);
16911651
}
16921652

16931653
static PyMethodDef Cntr_methods[] = {

0 commit comments

Comments
 (0)