This test always fails if `cmty1 != cmty2`, otherwise only one comparison is needed. There are several more occurrences down below.

Also, `sum` treats `True` and `False` as 1 and 0 automatically, so you do not need to handle this yourself.