changed all == None and != None to is None and is not None (this is related to the following FutureWarning:  comparison to  will result in an elementwise object comparison in the future.