Skip to content

Commit

Permalink
generalize contains function
Browse files Browse the repository at this point in the history
allow cone-cone containment checking
  • Loading branch information
natemacfadden committed Aug 19, 2024
1 parent 6cec12a commit d60bf18
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/cytools/cone.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,21 +606,27 @@ def hyperplanes(self):

return np.array(self._hyperplanes)

def contains(self, pt: "list-like", eps: float = 0) -> bool:
def contains(self, other, eps: float = 0) -> bool:
"""
**Description:**
Checks if a point is in the (strict) interior.
**Arguments:**
- `pt`: The point(s) of interest.
- `other`: The object to check containment of. Can be a 1D array, which
is treated as a point. Can be a 2D array, which is treated as a
list of points. Can be a Cone.
- `eps`: Check H@pt >= eps.
**Returns:**
Whether pt is in the (strict) interior.
"""
H = self.hyperplanes()
if isinstance(other, Cone):
# just check if we contain all of other's rays...
return all(self.contains(other.rays(), eps=eps))

pt = np.array(pt)
# other was a point(s)
H = self.hyperplanes()
pt = np.array(other)

# cast to 2D array, transpose
if len(pt.shape) == 1:
Expand Down

0 comments on commit d60bf18

Please sign in to comment.