Issue 1:
Hello,

When i run this simple portion of code

import numpy as np
from scipy.spatial import SphericalVoronoi, distance
from scipy.spatial import _spherical_voronoi as spherical_voronoi

test = np.array([[-0.1382177 , -0.66701253, 0.36649207],
[-0.33718559, -0.0515926 , 0.7109696 ],
[-0.13633904, -0.65712506, 0.3830903 ],
[ 0.04510981, 0.72285262, 0.35677763],
[-0.14008791, -0.65997704, 0.37445958],
[-0.7253343 , -0.26837762, 0.00655405],
[-0.58085674, -0.40511863, -0.36093304],
[ 0.2780397 , 0.72729778, 0.24511902],
[-0.33315233, -0.16453994, -0.6972229 ],
[-0.46532148, 0.35901168, -0.45935981],
[-0.72827086, -0.25884677, -0.00137087],
[-0.72758263, -0.25989862, 0.00278446],
[-0.70204518, -0.31395337, -0.0467136 ],
[-0.71771464, -0.28226784, -0.01436788],
[-0.72884793, -0.25239507, 0.01278218],
[-0.72528059, -0.26018933, -0.00931674],
[ 0.23175783, -0.68754004, 0.24004559],
[ 0.69090723, -0.2371959 , -0.19492292],
[ 0.40653046, -0.63173528, -0.25505239],
[ 0.53203067, -0.52945865, -0.14520801],
[ 0.52527016, -0.53501648, -0.2155609 ],
[ 0.56226738, -0.31942141, -0.39975375]])

sv = SphericalVoronoi(test)
sv.sort_vertices_of_regions()

I get the following error :

Python 2.7.12 |Anaconda custom (64-bit)| (default, Jul 2 2016, 17:42:40)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import numpy as np
>>> from scipy.spatial import SphericalVoronoi, distance
>>> from scipy.spatial import _spherical_voronoi as spherical_voronoi
>>>
>>> test = np.array([[-0.1382177 , -0.66701253, 0.36649207],
... [-0.33718559, -0.0515926 , 0.7109696 ],
... [-0.13633904, -0.65712506, 0.3830903 ],
... [ 0.04510981, 0.72285262, 0.35677763],
... [-0.14008791, -0.65997704, 0.37445958],
... [-0.7253343 , -0.26837762, 0.00655405],
... [-0.58085674, -0.40511863, -0.36093304],
... [ 0.2780397 , 0.72729778, 0.24511902],
... [-0.33315233, -0.16453994, -0.6972229 ],
... [-0.46532148, 0.35901168, -0.45935981],
... [-0.72827086, -0.25884677, -0.00137087],
... [-0.72758263, -0.25989862, 0.00278446],
... [-0.70204518, -0.31395337, -0.0467136 ],
... [-0.71771464, -0.28226784, -0.01436788],
... [-0.72884793, -0.25239507, 0.01278218],
... [-0.72528059, -0.26018933, -0.00931674],
... [ 0.23175783, -0.68754004, 0.24004559],
... [ 0.69090723, -0.2371959 , -0.19492292],
... [ 0.40653046, -0.63173528, -0.25505239],
... [ 0.53203067, -0.52945865, -0.14520801],
... [ 0.52527016, -0.53501648, -0.2155609 ],
... [ 0.56226738, -0.31942141, -0.39975375]])
>>>
>>> sv = SphericalVoronoi(test)
>>> sv.sort_vertices_of_regions()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/env/export/cns_n02_agc/agc/home/ggautrea/anaconda2/lib/python2.7/site-packages/scipy/spatial/_spherical_voronoi.py", line 319, in sort_vertices_of_regions
][0]
IndexError: list index out of range

I use scipy 0.18.1.

Can you help me ?

Thank you.

Issue 2:
Hi all,

It seems nquad has a memory leak when integrating a function implemented using ctypes. Here is the code that can be used to replicate this issue:

Save this as testlib.c:

//testlib.c

# include <math.h>

double f(int n, double args[n]){

return pow(args[0], 2) - exp(args[1]) * args[2]; //corresponds to x0 - x1 * x2

}

Compile the function:

gcc -shared -o testlib.so -fPIC testlib.c

Run this in Python:

import ctypes

from scipy import integrate

lib = ctypes.CDLL('./testlib.so')

func = lib.f

func.restype = ctypes.c_double

func.argtypes = (ctypes.c_int, ctypes.c_double)

while True:

integrate.nquad(func, [[0, 10], [-10, 0], [-1, 1]])

and use "top" to watch how the memory usage grows.

Any chance for a quick fix?

Cheers,

Brani