# Path: pyhull/delaunay.py
# class DelaunayTri(object):
#     """
#     Delaunay triangulation for a set of points.
# 
#     .. attribute: dim
# 
#         Dimension of the points.
# 
#     .. attribute: points
# 
#         Original points supplied.
# 
#     .. attribute: vertices
# 
#         Vertices of the Delaunay triangulation as a list of list of integer
#         indices. E.g., [[0, 2], [1, 0], [2, 3], [3, 1]]
#     """
# 
#     def __init__(self, points, joggle=False):
#         """
#         Initializes a DelaunayTri from points.
# 
#         Args:
#             points ([[float]]): All the points as a sequence of sequences.
#                 e.g., [[-0.5, -0.5], [-0.5, 0.5], [0.5, -0.5], [0.5, 0.5]]
#             joggle (bool): Use qhull option to joggle inputs until simplical
#                 result is obtained instead of merging facets.
#         """
#         self.points = points
#         dim = [len(i) for i in self.points]
#         if max(dim) != min(dim):
#             raise ValueError("Input points must all have the same dimension!")
#         self.dim = dim[0]
#         if joggle:
#             options = "i QJ"
#         else:
#             options = "i Qt"
#         output = qdelaunay(options, points)
#         output.pop(0)
#         self.vertices = [[int(i)for i in row.strip().split()] for row in output]
# 
#     @property
#     def simplices(self):
#         """
#         Returns the simplices of the triangulation.
#         """
#         return [Simplex([self.points[i] for i in v]) for v in self.vertices]


import unittest
import numpy as np
from pyhull.delaunay import DelaunayTri
                        -0.1968618818332127],
                       [-0.4630278928730662, -0.1886147011806086,
                        0.005446551209538857]]
        self.spdelau = DelaunayTri(sphere_data)

        #Make sure higher dim works.
        points = np.random.randn(10, 5)
        self.hddelau = DelaunayTri(points)

        #Check that bad points raises an error.
        bad_points = [[0,0], [0,1,0], [0,0]]
        self.assertRaises(ValueError, DelaunayTri, bad_points)

    def test_vertices(self):
        expected_ans = [[3, 0, 1], [0, 2, 1], [4, 0, 3], [0, 4, 2]]
        self.assertEqual(self.delau.vertices, expected_ans)
        expected_ans = [[1, 3, 6, 0], [1, 8, 6, 9], [8, 1, 6, 0], [2, 5, 1, 9],
                        [2, 5, 3, 1], [2, 1, 6, 9], [3, 2, 1, 6], [7, 3, 1, 0],
                        [5, 7, 3, 1], [7, 4, 3, 0], [7, 4, 5, 3]]
        self.assertEqual(self.spdelau.vertices, expected_ans)

    def test_simplices(self):
        self.assertEqual(len(self.delau.simplices), 4)
        self.assertEqual(len(self.spdelau.simplices), 11)

    def test_dim(self):
        self.assertEqual(self.delau.dim, 2)
        self.assertEqual(self.spdelau.dim, 3)

    def test_joggle(self):

# Path: pyhull/delaunay.py
# class DelaunayTri(object):
#     """
#     Delaunay triangulation for a set of points.
# 
#     .. attribute: dim
# 
#         Dimension of the points.
# 
#     .. attribute: points
# 
#         Original points supplied.
# 
#     .. attribute: vertices
# 
#         Vertices of the Delaunay triangulation as a list of list of integer
#         indices. E.g., [[0, 2], [1, 0], [2, 3], [3, 1]]
#     """
# 
#     def __init__(self, points, joggle=False):
#         """
#         Initializes a DelaunayTri from points.
# 
#         Args:
#             points ([[float]]): All the points as a sequence of sequences.
#                 e.g., [[-0.5, -0.5], [-0.5, 0.5], [0.5, -0.5], [0.5, 0.5]]
#             joggle (bool): Use qhull option to joggle inputs until simplical
#                 result is obtained instead of merging facets.
#         """
#         self.points = points
#         dim = [len(i) for i in self.points]
#         if max(dim) != min(dim):
#             raise ValueError("Input points must all have the same dimension!")
#         self.dim = dim[0]
#         if joggle:
#             options = "i QJ"
#         else:
#             options = "i Qt"
#         output = qdelaunay(options, points)
#         output.pop(0)
#         self.vertices = [[int(i)for i in row.strip().split()] for row in output]
# 
#     @property
#     def simplices(self):
#         """
#         Returns the simplices of the triangulation.
#         """
#         return [Simplex([self.points[i] for i in v]) for v in self.vertices]


# Path: pyhull/tests/test_delaunay.py
import unittest
import numpy as np
from pyhull.delaunay import DelaunayTri

                        -0.1968618818332127],
                       [-0.4630278928730662, -0.1886147011806086,
                        0.005446551209538857]]
        self.spdelau = DelaunayTri(sphere_data)

        #Make sure higher dim works.
        points = np.random.randn(10, 5)
        self.hddelau = DelaunayTri(points)

        #Check that bad points raises an error.
        bad_points = [[0,0], [0,1,0], [0,0]]
        self.assertRaises(ValueError, DelaunayTri, bad_points)

    def test_vertices(self):
        expected_ans = [[3, 0, 1], [0, 2, 1], [4, 0, 3], [0, 4, 2]]
        self.assertEqual(self.delau.vertices, expected_ans)
        expected_ans = [[1, 3, 6, 0], [1, 8, 6, 9], [8, 1, 6, 0], [2, 5, 1, 9],
                        [2, 5, 3, 1], [2, 1, 6, 9], [3, 2, 1, 6], [7, 3, 1, 0],
                        [5, 7, 3, 1], [7, 4, 3, 0], [7, 4, 5, 3]]
        self.assertEqual(self.spdelau.vertices, expected_ans)

    def test_simplices(self):
        self.assertEqual(len(self.delau.simplices), 4)
        self.assertEqual(len(self.spdelau.simplices), 11)

    def test_dim(self):
        self.assertEqual(self.delau.dim, 2)
        self.assertEqual(self.spdelau.dim, 3)

    def test_joggle(self):

        joggled_delau = DelaunayTri(self.delau.points, joggle=True)