specialize numpy scalars by type (fixes issue #344)