Skip to content

Commit

Permalink
Clean up some methods
Browse files Browse the repository at this point in the history
  • Loading branch information
natemacfadden committed Aug 18, 2024
1 parent 46c855c commit 6cec12a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
8 changes: 5 additions & 3 deletions src/cytools/cone.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,9 +625,11 @@ def contains(self, pt: "list-like", eps: float = 0) -> bool:
# cast to 2D array, transpose
if len(pt.shape) == 1:
pt = pt.reshape(-1,1)
return_list = False
else:
# transpose so columns are points
pt = pt.transpose()
return_list = True

# compute which points are in the cone
if len(H):
Expand All @@ -636,10 +638,10 @@ def contains(self, pt: "list-like", eps: float = 0) -> bool:
contained = [True for _ in range(pt.shape[1])]

# return
if len(contained)==1:
return contained[0]
else:
if return_list:
return tuple(contained)
else:
return contained[0]

def dual_cone(self):
"""
Expand Down
11 changes: 7 additions & 4 deletions src/cytools/polytope.py
Original file line number Diff line number Diff line change
Expand Up @@ -2064,10 +2064,12 @@ def _triang_labels(self,

def triangulate(self,
include_points_interior_to_facets: bool = None,
points: ArrayLike = None,
points: "ArrayLike" = None,
make_star: bool = None,
simplices: ArrayLike=None,check_input_simplices: bool=True,
heights: ArrayLike = None,check_heights: bool = True,
simplices: "ArrayLike" = None,
check_input_simplices: bool=True,
heights: "ArrayLike" = None,
check_heights: bool = True,
backend: str = "cgal",
verbosity: int = 1) -> Triangulation:
"""
Expand Down Expand Up @@ -2147,13 +2149,14 @@ def triangulate(self,
points = tuple(sorted(set(points)))
else:
points = self._triang_labels(use_pts_in_facets)
points = sorted(points)

# if simplices are provided, check if they span the relevant points
if simplices is not None:
simps_labels = tuple(sorted({i for simp in simplices for i in simp}))

# index mismatch... Raise error
if len( set(simps_labels).difference(set(range(len(self.labels)))) ) > 0:
if any([l not in points for l in simps_labels]):
error_msg = f"Simplices spanned {simps_labels}, which differs " +\
f"from labels of relevant points, {points}. " +\
"Check include_points_interior_to_facets... it "+\
Expand Down

0 comments on commit 6cec12a

Please sign in to comment.