You should catch a `KeyError` here in case the type is not in the allowed list.  E.g. complex is not supported, and there can be other custom dtypes that don't show up.