def singleBlockTrue(array):
    if len(array) == 0:
        return False
transitions = (array[1:] != array[:-1]).sum()
transitions = transitions + array[0] + array[-1]
return transitions == 2
How can I tell whether a numpy boolean array contains only a single block of `True`s?