def typeof_np_dtype()

in torcharrow/dtypes.py [0:0]


def typeof_np_dtype(t: np.dtype) -> DType:
    # only suppport the following non-structured columns,...
    if t == np.bool8:
        return boolean
    if t == np.int8:
        return int8
    if t == np.int16:
        return int16
    if t == np.int32:
        return int32
    if t == np.int64:
        return int64
    # any float array can have nan -- all nan(s) will be masked
    # -> so result type is FloatXX(True)
    if t == np.float32:
        return Float32(nullable=True)
    if t == np.float64:
        return Float64(nullable=True)
    # can't test nicely for strings so we use the kind test
    if t.kind == "U":  # unicode like
        return string
    # any object array can have non-strings: all non strings will be masked.
    # -> so result type is String(True)
    if t == object:
        return String(nullable=True)

    raise AssertionError(
        f"translation of numpy type {type(t).__name__} to dtype unsupported"
    )