Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
trac #16727: IncidenceStructure.__contains__
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanncohen committed Jul 29, 2014
1 parent 5415a3d commit 1dd244a
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/sage/combinat/designs/incidence_structures.py
Expand Up @@ -374,6 +374,39 @@ def __ne__(self, other):
"""
return not self.__eq__(other)

def __contains__(self, block):
r"""
Tests if a block belongs to the incidence structure
INPUT:
- ``block`` -- a block.
EXAMPLES::
sage: [1,2,3,4] in IncidenceStructure([[1,2,3,4]])
True
sage: [1,2,4,3] in IncidenceStructure([[1,2,3,4]])
True
sage: [1,2,"3",4] in IncidenceStructure([[1,2,3,4]])
False
sage: [1,2,"3",4] in IncidenceStructure([[1,2,"3",4]])
True
"""
try:
iter(block)
except TypeError:
return False

# Relabel to 0,...,n-1 if necessary
if self._point_to_index is not None:
try:
block = [self._point_to_index[x] for x in block]
except KeyError:
return False

return sorted(block) in self._blocks

def ground_set(self, copy=True):
r"""
Return the ground set (i.e the list of points).
Expand Down

0 comments on commit 1dd244a

Please sign in to comment.