ENH: use isinstance instead