Figured it out from here:
Earlier in the script I filter by slope to remove any that have a non computed slope (horizontal is 0, vertical is Not Computed).