That needs to be `array.dtype.type in not np.object_:` The `is` compares addresses of singleton type objects, whereas the dtype is dynamic and constructed on the fly.