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

Skip to content

Commit 68f599a

Browse files
anntzerianthomas23
andcommitted
Switch to reentrant qhull 2020 8.0.2.
(the current version) Co-authored-by: Ian Thomas <[email protected]>
1 parent 760dd03 commit 68f599a

File tree

6 files changed

+21
-18
lines changed

6 files changed

+21
-18
lines changed

INSTALL.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ FreeType and Qhull
222222

223223
Matplotlib depends on `FreeType <https://www.freetype.org/>`_ (>=
224224
2.3), a font rendering library, and on `Qhull
225-
<http://www.qhull.org/>`_ (>= 2015.2), a library for computing
225+
<http://www.qhull.org/>`_ (>= 2020.2), a library for computing
226226
triangulations. By default (except on AIX) Matplotlib downloads and
227227
builds its own copy of FreeType (this is necessary to run the test
228228
suite, because different versions of FreeType rasterize characters

lib/matplotlib/tests/test_triangulation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ def z(x, y):
730730
matest.assert_array_almost_equal(interpz, interp_z0[interp_key])
731731

732732

733-
@image_comparison(['tri_smooth_contouring.png'], remove_text=True, tol=0.07)
733+
@image_comparison(['tri_smooth_contouring.png'], remove_text=True, tol=0.072)
734734
def test_tri_smooth_contouring():
735735
# Image comparison based on example tricontour_smooth_user.
736736
n_angles = 20

lib/mpl_toolkits/tests/test_mplot3d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def test_contourf3d_fill():
152152
ax.set_zlim(-1, 1)
153153

154154

155-
@mpl3d_image_comparison(['tricontour.png'])
155+
@mpl3d_image_comparison(['tricontour.png'], tol=0.02)
156156
def test_tricontour():
157157
fig = plt.figure()
158158

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ def __init__(self, dist):
8888

8989

9090
def _download_qhull_to(dest):
91-
url = "http://www.qhull.org/download/qhull-2015-src-7.2.0.tgz"
92-
sha = "78b010925c3b577adc3d58278787d7df08f7c8fb02c3490e375eab91bb58a436"
91+
url = "http://www.qhull.org/download/qhull-2020-src-8.0.2.tgz"
92+
sha = "b5c2d7eb833278881b952c8a52d20179eab87766b00b865000469a45c1838b7e"
9393
if (dest / f"qhull-{LOCAL_QHULL_VERSION}").exists():
9494
return
9595
dest.mkdir(parents=True, exist_ok=True)

setupext.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def download_or_cache(url, sha):
136136
LOCAL_FREETYPE_VERSION = '2.6.1'
137137
LOCAL_FREETYPE_HASH = _freetype_hashes.get(LOCAL_FREETYPE_VERSION, 'unknown')
138138

139-
LOCAL_QHULL_VERSION = '2015.2'
139+
LOCAL_QHULL_VERSION = '2020.2'
140140

141141

142142
# matplotlib build options, which can be altered using setup.cfg
@@ -517,7 +517,7 @@ def add_qhull_flags(ext):
517517
else:
518518
qhull_path = Path(f'extern/qhull-{LOCAL_QHULL_VERSION}/src')
519519
ext.include_dirs.insert(0, str(qhull_path))
520-
ext.sources.extend(map(str, sorted(qhull_path.glob('libqhull/*.c'))))
520+
ext.sources.extend(map(str, sorted(qhull_path.glob('libqhull_r/*.c'))))
521521
if sysconfig.get_config_var("LIBM") == "-lm":
522522
ext.libraries.extend("m")
523523

src/qhull_wrap.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#define PY_SSIZE_T_CLEAN
99
#include "Python.h"
1010
#include "numpy/ndarrayobject.h"
11-
#include "libqhull/qhull_a.h"
11+
#include "libqhull_r/qhull_ra.h"
1212
#include <stdio.h>
1313

1414

@@ -32,11 +32,11 @@ static const char* qhull_error_msg[6] = {
3232
/* Return the indices of the 3 vertices that comprise the specified facet (i.e.
3333
* triangle). */
3434
static void
35-
get_facet_vertices(const facetT* facet, int indices[3])
35+
get_facet_vertices(qhT* qh, const facetT* facet, int indices[3])
3636
{
3737
vertexT *vertex, **vertexp;
3838
FOREACHvertex_(facet->vertices)
39-
*indices++ = qh_pointid(vertex->point);
39+
*indices++ = qh_pointid(qh, vertex->point);
4040
}
4141

4242
/* Return the indices of the 3 triangles that are neighbors of the specified
@@ -88,6 +88,8 @@ static PyObject*
8888
delaunay_impl(int npoints, const double* x, const double* y,
8989
int hide_qhull_errors)
9090
{
91+
qhT qh_qh; /* qh variable type and name must be like */
92+
qhT* qh = &qh_qh; /* this for Qhull macros to work correctly. */
9193
coordT* points = NULL;
9294
facetT* facet;
9395
int i, ntri, max_facet_id;
@@ -148,7 +150,8 @@ delaunay_impl(int npoints, const double* x, const double* y,
148150
}
149151

150152
/* Perform Delaunay triangulation. */
151-
exitcode = qh_new_qhull(ndim, npoints, points, False,
153+
qh_zero(qh, error_file);
154+
exitcode = qh_new_qhull(qh, ndim, npoints, points, False,
152155
"qhull d Qt Qbb Qc Qz", NULL, error_file);
153156
if (exitcode != qh_ERRnone) {
154157
PyErr_Format(PyExc_RuntimeError,
@@ -159,7 +162,7 @@ delaunay_impl(int npoints, const double* x, const double* y,
159162
}
160163

161164
/* Split facets so that they only have 3 points each. */
162-
qh_triangulate();
165+
qh_triangulate(qh);
163166

164167
/* Determine ntri and max_facet_id.
165168
Note that libqhull uses macros to iterate through collections. */
@@ -169,7 +172,7 @@ delaunay_impl(int npoints, const double* x, const double* y,
169172
++ntri;
170173
}
171174

172-
max_facet_id = qh facet_id - 1;
175+
max_facet_id = qh->facet_id - 1;
173176

174177
/* Create array to map facet id to triangle index. */
175178
tri_indices = (int*)malloc((max_facet_id+1)*sizeof(int));
@@ -204,7 +207,7 @@ delaunay_impl(int npoints, const double* x, const double* y,
204207
FORALLfacets {
205208
if (!facet->upperdelaunay) {
206209
tri_indices[facet->id] = i++;
207-
get_facet_vertices(facet, indices);
210+
get_facet_vertices(qh, facet, indices);
208211
*triangles_ptr++ = (facet->toporient ? indices[0] : indices[2]);
209212
*triangles_ptr++ = indices[1];
210213
*triangles_ptr++ = (facet->toporient ? indices[2] : indices[0]);
@@ -224,8 +227,8 @@ delaunay_impl(int npoints, const double* x, const double* y,
224227
}
225228

226229
/* Clean up. */
227-
qh_freeqhull(!qh_ALL);
228-
qh_memfreeshort(&curlong, &totlong);
230+
qh_freeqhull(qh, !qh_ALL);
231+
qh_memfreeshort(qh, &curlong, &totlong);
229232
if (curlong || totlong)
230233
PyErr_WarnEx(PyExc_RuntimeWarning,
231234
"Qhull could not free all allocated memory", 1);
@@ -243,8 +246,8 @@ delaunay_impl(int npoints, const double* x, const double* y,
243246
/* Clean up. */
244247
Py_XDECREF(triangles);
245248
Py_XDECREF(neighbors);
246-
qh_freeqhull(!qh_ALL);
247-
qh_memfreeshort(&curlong, &totlong);
249+
qh_freeqhull(qh, !qh_ALL);
250+
qh_memfreeshort(qh, &curlong, &totlong);
248251
/* Don't bother checking curlong and totlong as raising error anyway. */
249252
if (hide_qhull_errors)
250253
fclose(error_file);

0 commit comments

Comments
 (0)