GithubHelp home page GithubHelp logo

materialsvirtuallab / pyhull Goto Github PK

View Code? Open in Web Editor NEW
99.0 24.0 30.0 1.3 MB

Pyhull is a Python wrapper to Qhull (http://www.qhull.org/) for the computation of the convex hull, Delaunay triangulation and Voronoi diagram.

Home Page: http://packages.python.org/pyhull/

License: MIT License

Python 3.90% CMake 1.77% C 78.11% HTML 12.43% Makefile 0.69% QMake 0.16% C++ 2.94%

pyhull's Introduction

Pyhull

Pyhull is a Python wrapper to qhull (http://www.qhull.org/) for the computation of the convex hull, Delaunay triangulation and Voronoi diagram. It is written as a Python C extension, with both high-level and low-level interfaces to qhull. It is currently based on the 2012.1 version of qhull.

Pyhull has been tested to scale to 10,000 7D points for convex hull calculations (results in ~ 10 seconds), and 10,000 6D points for Delaunay triangulations and Voronoi tesselations (~ 100 seconds). Higher number of points and higher dimensions should be accessible depending on your machine, but may take a significant amount of time.

For more information, visit the documentation page at http://packages.python.org/pyhull/. To report bugs, please use the pyhull's Github Issues page at https://github.com/materialsvirtuallab/pyhull/issues.

Note

At the time of development of pyhull, the scipy.spatial package was the only other package that supports the computation of higher dimensional convex hulls. However, the version of scipy at that time (scipy 0.11.0) only supported the computation of Delaunay triangulation and the convex hull was computed from the Delaunay triangulation, which is slower and less reliable than directly computing the convex hull. As of version 0.12.0, scipy now supports the direct computation of convex hulls and is in fact ~50% faster than pyhull for larger hulls. I will still make pyhull available for the simple reason that the scipy package is fairly large and not everyone wants to install such a large package for computing hulls.

Performance of pyhull

The table below indicates the time taken in seconds to generate the convex hull for a given number of points in a specified number of dimensions. The final col (Cmd-line qconvex) is the time taken to generate the data using a subprocess call to command line qconvex as a comparison for pyhull. Note that these are based on older versions of scipy (< 0.12.0) where the hull is computed by first performing the Delaunay triangulation.

No of points Dim scipy pyhull Cmd line
100 3 0.00237 0.00209 0.01354
100 4 0.00609 0.00333 0.01053
100 5 0.03125 0.00834 0.01743
100 6 0.16662 0.04627 0.05048
1000 3 0.02543 0.01166 0.01398
1000 4 0.15308 0.01438 0.01741
1000 5 1.04724 0.05105 0.05279
1000 6 7.45985 0.25104 0.29058
2000 3 0.05124 0.01968 0.02431
2000 4 0.32277 0.02326 0.02742
2000 5 2.38308 0.06664 0.06845
2000 6 20.64062 0.41188 0.42673

Here are new benchmarks for pyhull against scipy 0.12.0, which supports the direct computation of the convex hull.

Npts Dim scipy pyhull

100

3

0.00044 0.00120

100

4

0.00062 0.00215

100

5

0.00347 0.00838

100

6

0.01382 0.03698

1000

3

0.00051 0.00778

1000

4

0.00194 0.01226

1000

5

0.01417 0.04079

1000

6

0.14036 0.20594

2000

3

0.00072 0.01772

2000

4

0.00392 0.02941

2000

5

0.02350 0.07712

2000

6

0.25601 0.36650

Usage

It is generally recommended that you use the high-level wrapper functions and classes in pyhull.

For useful analysis outputs, please use the high-level ConvexHull, DelaunayTri and VoronoiTess classes in the convex_hull, delaunay and voronoi modules respectively. For example,

>>> from pyhull.convex_hull import ConvexHull >>> pts = [[-0.5, -0.5], [-0.5, 0.5], [0.5, -0.5], [0.5, 0.5], [0,0]] >>> hull = ConvexHull(pts) >>> hull.vertices [[0, 2], [1, 0], [2, 3], [3, 1]] >>> hull.points [[-0.5, -0.5], [-0.5, 0.5], [0.5, -0.5], [0.5, 0.5], [0, 0]] >>> >>> from pyhull.delaunay import DelaunayTri >>> tri = DelaunayTri(pts) >>> tri.vertices [[2, 4, 0], [4, 1, 0], [3, 4, 2], [4, 3, 1]] >>> tri.points [[-0.5, -0.5], [-0.5, 0.5], [0.5, -0.5], [0.5, 0.5], [0, 0]] >>> >>> from pyhull.voronoi import VoronoiTess >>> v = VoronoiTess(pts) >>> v.vertices [[-10.101, -10.101], [0.0, -0.5], [-0.5, 0.0], [0.5, 0.0], [0.0, 0.5]] >>> v.regions [[2, 0, 1], [4, 0, 2], [3, 0, 1], [4, 0, 3], [4, 2, 1, 3]]

If you need more detailed output, consider using the lower-level interface functions that are modelled after standard command line syntax of various qhull programs:

>>> from pyhull import qconvex, qdelaunay, qvoronoi >>> >>> pts = [[-0.5, -0.5], [-0.5, 0.5], [0.5, -0.5], [0.5, 0.5], [0,0]] >>> >>> qconvex("i", pts) ['4', '0 2', '1 0', '2 3', '3 1'] >>> >>> qdelaunay("i", pts) ['4', '2 4 0', '4 1 0', '3 4 2', '4 3 1'] >>> >>> qvoronoi("o", pts) ['2', '5 5 1', '-10.101 -10.101', '0 -0.5', '-0.5 0', '0.5 0', '0 0.5', '3 2 0 1', '3 4 0 2', '3 3 0 1', '3 4 0 3', '4 4 2 1 3']

The return values are simply a list of strings from the output.

pyhull's People

Contributors

ashafix avatar dependabot[bot] avatar shyuep avatar wmdrichards avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyhull's Issues

pyhull fails to start on ubuntu

I installed pyhull for python3 on my ubuntu (13.10). And I got this error on importing module :

import pyhull
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.3/dist-packages/pyhull/init.py", line 15, in
import pyhull._pyhull as hull
ImportError: /usr/local/lib/python3.3/dist-packages/pyhull/_pyhull.cpython-33m.so: undefined symbol: Py_InitModule

does not work on OpenBSD amd64

It compiles with some warnings, can be imported to python but when used Segementation fault happens. Brief inspection of dumped core suggests problems with libc/stdio/fgets - though I am not an expert in gdb so I might be wrong. What info do you need to try to tackle this issue?

Installation problem in ubuntu

I am getting the following errors during easy-installation of Pyhull.

parag@Dabba:~$ sudo easy_install pyhull
Searching for pyhull
Reading https://pypi.python.org/simple/pyhull/
Best match: pyhull 1.4.3
Downloading https://pypi.python.org/packages/source/p/pyhull/pyhull-1.4.3.tar.gz#md5=25e62181a8430f102b7d853aaaec3401
Processing pyhull-1.4.3.tar.gz
Writing /tmp/easy_install-PaeyF9/pyhull-1.4.3/setup.cfg
Running pyhull-1.4.3/setup.py -q bdist_egg --dist-dir /tmp/easy_install-PaeyF9/pyhull-1.4.3/egg-dist-tmp-9RNC0Y
warning: no files found matching '.md'
warning: no files found matching '
.c'
no previously-included directories found matching '**/tests'
src/_pyhull.c:28:20: fatal error: Python.h: No such file or directory
#include <Python.h>
^
compilation terminated.
error: Setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

P.S. - I am unable to fix this. Is there any other way to install pyhull.

Misleading benchmarks

Hi,

The pyhull documentation includes some benchmarks against scipy.spatial. What the benchmark is however comparing is the speed of qhull Delaunay triangulation to the speed of qhull computing a convex hull. The former is equivalent to computing a N+1 dimensional convex hull, so it can naturally be quite a bit slower than directly computing the N dimensional hull.

Scipy versions prior to 0.12.0 included only interface to qhull's Delaunay routines, but direct convex hulls were added in 0.12.0. You may want to update the benchmarks accordingly.

Installation Issue

I could install pyhull using easy_install but not using pip. I've appended the complete log of the error. Note that pmg_install.py (pymatgen) also failed because of this error.

[mhargrove~/Downloads]$ sudo pip install pyhull
Downloading/unpacking pyhull
Running setup.py egg_info for package pyhull
Extracting in /tmp/tmpOvhzcE
Now working in /tmp/tmpOvhzcE/distribute-0.6.10
Building a Distribute egg in /private/tmp/pip-build-root/pyhull
Traceback (most recent call last):
File "setup.py", line 37, in
exec(open(init_path).read(), d)
File "", line 8, in
File "/private/tmp/tmpOvhzcE/distribute-0.6.10/setuptools/init.py", line 2, in
from setuptools.extension import Extension, Library
File "/private/tmp/tmpOvhzcE/distribute-0.6.10/setuptools/extension.py", line 2, in
from setuptools.dist import _get_unpatched
File "/private/tmp/tmpOvhzcE/distribute-0.6.10/setuptools/dist.py", line 6, in
from setuptools.command.install import install
File "/private/tmp/tmpOvhzcE/distribute-0.6.10/setuptools/command/init.py", line 8, in
from setuptools.command import install_scripts
File "/private/tmp/tmpOvhzcE/distribute-0.6.10/setuptools/command/install_scripts.py", line 3, in
from pkg_resources import Distribution, PathMetadata, ensure_directory
File "/private/tmp/tmpOvhzcE/distribute-0.6.10/pkg_resources.py", line 2675, in
add_activation_listener(lambda dist: dist.activate())
File "/private/tmp/tmpOvhzcE/distribute-0.6.10/pkg_resources.py", line 662, in subscribe
callback(dist)
File "/private/tmp/tmpOvhzcE/distribute-0.6.10/pkg_resources.py", line 2675, in
add_activation_listener(lambda dist: dist.activate())
File "/private/tmp/tmpOvhzcE/distribute-0.6.10/pkg_resources.py", line 2177, in activate
self.insert_on(path)
File "/private/tmp/tmpOvhzcE/distribute-0.6.10/pkg_resources.py", line 2278, in insert_on
"with distribute. Found one at %s" % str(self.location))
ValueError: A 0.7-series setuptools cannot be installed with distribute. Found one at /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools-0.7.2-py2.7.egg
/private/tmp/pip-build-root/pyhull/distribute-0.6.10-py2.7.egg
Traceback (most recent call last):
File "", line 16, in
File "/private/tmp/pip-build-root/pyhull/setup.py", line 7, in
use_setuptools(version='0.6.10')
File "distribute_setup.py", line 145, in use_setuptools
return _do_download(version, download_base, to_dir, download_delay)
File "distribute_setup.py", line 125, in _do_download
_build_egg(egg, tarball, to_dir)
File "distribute_setup.py", line 116, in _build_egg
raise IOError('Could not build the egg.')
IOError: Could not build the egg.
Complete output from command python setup.py egg_info:
Extracting in /tmp/tmpOvhzcE

Now working in /tmp/tmpOvhzcE/distribute-0.6.10

Building a Distribute egg in /private/tmp/pip-build-root/pyhull

Traceback (most recent call last):

File "setup.py", line 37, in

exec(open(init_path).read(), d)

File "", line 8, in

File "/private/tmp/tmpOvhzcE/distribute-0.6.10/setuptools/init.py", line 2, in

from setuptools.extension import Extension, Library

File "/private/tmp/tmpOvhzcE/distribute-0.6.10/setuptools/extension.py", line 2, in

from setuptools.dist import _get_unpatched

File "/private/tmp/tmpOvhzcE/distribute-0.6.10/setuptools/dist.py", line 6, in

from setuptools.command.install import install

File "/private/tmp/tmpOvhzcE/distribute-0.6.10/setuptools/command/init.py", line 8, in

from setuptools.command import install_scripts

File "/private/tmp/tmpOvhzcE/distribute-0.6.10/setuptools/command/install_scripts.py", line 3, in

from pkg_resources import Distribution, PathMetadata, ensure_directory

File "/private/tmp/tmpOvhzcE/distribute-0.6.10/pkg_resources.py", line 2675, in

add_activation_listener(lambda dist: dist.activate())

File "/private/tmp/tmpOvhzcE/distribute-0.6.10/pkg_resources.py", line 662, in subscribe

callback(dist)

File "/private/tmp/tmpOvhzcE/distribute-0.6.10/pkg_resources.py", line 2675, in

add_activation_listener(lambda dist: dist.activate())

File "/private/tmp/tmpOvhzcE/distribute-0.6.10/pkg_resources.py", line 2177, in activate

self.insert_on(path)

File "/private/tmp/tmpOvhzcE/distribute-0.6.10/pkg_resources.py", line 2278, in insert_on

"with distribute. Found one at %s" % str(self.location))

ValueError: A 0.7-series setuptools cannot be installed with distribute. Found one at /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools-0.7.2-py2.7.egg

/private/tmp/pip-build-root/pyhull/distribute-0.6.10-py2.7.egg

Traceback (most recent call last):

File "", line 16, in

File "/private/tmp/pip-build-root/pyhull/setup.py", line 7, in

use_setuptools(version='0.6.10')

File "distribute_setup.py", line 145, in use_setuptools

return _do_download(version, download_base, to_dir, download_delay)

File "distribute_setup.py", line 125, in _do_download

_build_egg(egg, tarball, to_dir)

File "distribute_setup.py", line 116, in _build_egg

raise IOError('Could not build the egg.')

IOError: Could not build the egg.


Command python setup.py egg_info failed with error code 1 in /private/tmp/pip-build-root/pyhull
Storing complete log in /Users/mhargrove/.pip/pip.log

Windows 10: pyhull not compiling

I am trying to install a plugin for Blender that is able to read SM64 Roms and output 3D models in C code format. (https://gitlab.com/scuttlebugraiser/rom-manger-2-c) I have the Microsoft Visual studio compiler and build tools and have had them for some time. When I use pip3 it gives me the console output linked in the text file named out.txt. According to pip3 I am using "pip 21.1 from c:\program files\blender foundation\blender 2.82\2.82\python\lib\site-packages\pip (python 3.7)" I have no idea why it is not working. One of the errors I saw was that it could not find Python.h which I do have on my computer so I am baffled as to how this is occuring. Is it just blender being weird or is it something different?
out.txt

Qhull installation trouble in windows

Hi,
I am trying to pip install qhull in a win7 environment. It failed giving and is throwing up the following error.
error: command 'C:\Users\xxxxxx\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe' failed with exit status 2
Any ideas?

the full message is a follows
C:\Users\xxxxxxx\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Isrc\libqhull -IC:\Python27\include -IC:\Python27\PC /Tcsrc_pyhull.c /Fobuild\temp.win32-2.7\Release\src_pyhull.obj
_pyhull.c
src_pyhull.c(91) : warning C4013: 'strtok_r' undefined; assuming extern returning int
src_pyhull.c(91) : warning C4047: '=' : 'char *' differs in levels of indirection from 'int'
src_pyhull.c(100) : warning C4013: 'fmemopen' undefined; assuming extern returning int
src_pyhull.c(100) : warning C4047: '=' : 'FILE *' differs in levels of indirection from 'int'
src_pyhull.c(101) : warning C4013: 'open_memstream' undefined; assuming extern returning int
src_pyhull.c(101) : warning C4047: '=' : 'FILE *' differs in levels of indirection from 'int'
src_pyhull.c(169) : warning C4047: '=' : 'char *' differs in levels of indirection from 'int'
src_pyhull.c(180) : warning C4047: '=' : 'FILE *' differs in levels of indirection from 'int'
src_pyhull.c(181) : warning C4047: '=' : 'FILE *' differs in levels of indirection from 'int'
src_pyhull.c(255) : warning C4047: '=' : 'char *' differs in levels of indirection from 'int'
src_pyhull.c(264) : warning C4047: '=' : 'FILE *' differs in levels of indirection from 'int'
src_pyhull.c(265) : warning C4047: '=' : 'FILE *' differs in levels of indirection from 'int'
src_pyhull.c(338) : warning C4047: '=' : 'char *' differs in levels of indirection from 'int'
src_pyhull.c(347) : warning C4047: '=' : 'FILE *' differs in levels of indirection from 'int'
src_pyhull.c(348) : warning C4047: '=' : 'FILE *' differs in levels of indirection from 'int'
src_pyhull.c(453) : error C2143: syntax error : missing ')' before '('
src_pyhull.c(453) : error C2143: syntax error : missing ')' before '('
src_pyhull.c(453) : error C2091: function returns function
src_pyhull.c(453) : error C2143: syntax error : missing ')' before 'string'
src_pyhull.c(453) : error C2091: function returns function
src_pyhull.c(453) : error C2143: syntax error : missing '{' before 'string'
src_pyhull.c(453) : error C2059: syntax error : ''
src_pyhull.c(453) : error C2059: syntax error : ')'
src_pyhull.c(453) : error C2059: syntax error : ')'

Regards
Hari

compiling

Hi,

I found that icc has a problem compiling the qhull libraries. The setup of pyhull takes the CC environmental to compile. When I compile qhull from source, it always uses gcc. Just exporting CC=gcc before running pyhull setup solves the issue.

Best,
Michiel

Windows install

I couldn't install pyhull on windows:
I could go over the error on "vcvarsall.bat" by installing Visual Studio 2008 and run the bat file "C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Tools\vsvars32.bat", but after that I get a lot of compilation errors and installation fail.
Would be very interested to get a solution.
Best

pyhull install on Windows 7

Dear colleagues,
Getting an error when installing the pyhull package under Windows7 in a 64 bits version using the pip or easy_install. I´ve tried set the mingwg compiler in distutils.cfg, as well as useing Visual Studio runtime version 10, and I´ve also tried to run it inside a cygwin64 terminal. The error message is:

c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: build\temp.win-amd64-2.7\Release\src_pyhull.o: bad reloc address 0x0 in section `.data'
collect2.exe: error: ld returned 1 exit status
error: Setup script exited with error: command 'gcc' failed with exit status 1

Is a tested build procedure availabe for Windows 7 64 bits? Thanks in advance for your support.
Regards, Claude

License file missing

Could you include a license file in this? We are looking for a replacement for SciPy to make it easier to build Cura and we need to make sure the license is compatible with the GPLv3.

pyhull should depend on qhull, not ship it

I already have qhull installed on our system,
so I used this patch to use the installed qhull, instead of building the one shipped with pyhull..
https://github.com/hpcugent/easybuild-easyconfigs/blob/0f709b5dccc6325285acd9624c88254d8b01ae92/easybuild/easyconfigs/p/pyhull/pyhull-1.5.4_use-provided-Qhull.patch

I prefer using my own qhull installation instead of using the one shipped with pyhull, because we also compile other python packages against qhull (e.g. matplotlib) and it is nicer to use the same version, and actually library, for each python package.

Trouble with Cygwin

I'm having some trouble running pyhull on cygwin. It seems to install fine (creates _pyhull.dll), but when I run it through pymatgen (pymatgen.electronic_structure.plotter.BSPlotter.plot_brillouin), it gives me an error. Upon further investigation, it seems that qvoronoi (which imports just fine) isn't returning any values?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.