MAINT: use numpy functions instead of my worse home-made functions

I didn't know about `np.iscomplexobj` or `np.isrealobj` when I originally wrote that code.