Skip to content

Commit

Permalink
Merge bdbb5df into eab6e6d
Browse files Browse the repository at this point in the history
  • Loading branch information
enadeau committed Aug 10, 2019
2 parents eab6e6d + bdbb5df commit 74ff2ca
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## Unreleased
### Added
- The ascii_plot, and to_tikz method in MeshPatt
- is_subclass method in Av
### Removed
- The broken latex method in MeshPatt
### Fixed
Expand Down
4 changes: 4 additions & 0 deletions permuta/_perm_set/unbounded/described/avoiding/avoiding.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ def __contains__(self, perm):
else:
raise TypeError

def is_subclass(self, other):
""" Check if the `self` is a subclass of `other`. """
return all(p1 not in self for p1 in other.basis)


class AvoidingGenericSpecificLength(PermSetFiniteSpecificLength):
"""Class for iterating through all perms of a specific length avoiding a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,23 @@ def test_avoiding_generic_finite_class():
cnt[len(perm)] += 1

assert enum == cnt


def test_is_subclass():
av1 = AvoidingGeneric((Perm((0,)),))
av12_21 = AvoidingGeneric((Perm((0,1)), Perm((1,0))))
av123 = AvoidingGeneric((Perm((0,1,2)),))
av1234 = AvoidingGeneric((Perm((0,1,2,3)),))
assert av1.is_subclass(av123)
assert not av123.is_subclass(av1)
assert av123.is_subclass(av1234)
assert not av1234.is_subclass(av12_21)
assert av12_21.is_subclass(av1234)
assert av123.is_subclass(av123)
av1324_1423_12345 = AvoidingGeneric((Perm((0,2,1,3)), Perm((0,3,1,2)),
Perm((0,1,2,3,4,5))))
av1324_1234 = AvoidingGeneric((Perm((0,2,1,3)), Perm((0,1,2,3))))
av1234_132 = AvoidingGeneric((Perm((0,1,2,3)), Perm((0,2,1))))
assert av123.is_subclass(av1324_1423_12345)
assert not av1324_1234.is_subclass(av1324_1423_12345)
assert av1234_132.is_subclass(av1324_1423_12345)

0 comments on commit 74ff2ca

Please sign in to comment.