snowflake.ml.model.model_signature.DataType

class snowflake.ml.model.model_signature.DataType(value)

Bases: Enum

An enumeration.

Methods

as_snowpark_type() DataType

Convert to corresponding Snowpark Type.

Returns:

A Snowpark type.

classmethod from_numpy_type(np_type: Union[dtype[Any], None, Type[Any], _SupportsDType[dtype[Any]], str, Tuple[Any, int], Tuple[Any, Union[SupportsIndex, Sequence[SupportsIndex]]], List[Any], _DTypeDict, Tuple[Any, Any]]) DataType

Translate numpy dtype to DataType for signature definition.

Parameters:

np_type – The numpy dtype.

Raises:

SnowflakeMLException – NotImplementedError: Raised when the given numpy type is not supported.

Returns:

Corresponding DataType.

classmethod from_torch_type(torch_type: torch.dtype) DataType
classmethod from_snowpark_type(snowpark_type: DataType) DataType

Translate snowpark type to DataType for signature definition.

Parameters:

snowpark_type – The snowpark type.

Raises:

SnowflakeMLException – NotImplementedError: Raised when the given numpy type is not supported.

Returns:

Corresponding DataType.

Attributes

INT8 = ('int8', <class 'snowflake.snowpark.types.ByteType'>, <class 'numpy.int8'>)
INT16 = ('int16', <class 'snowflake.snowpark.types.ShortType'>, <class 'numpy.int16'>)
INT32 = ('int32', <class 'snowflake.snowpark.types.IntegerType'>, <class 'numpy.int32'>)
INT64 = ('int64', <class 'snowflake.snowpark.types.LongType'>, <class 'numpy.int64'>)
FLOAT = ('float', <class 'snowflake.snowpark.types.FloatType'>, <class 'numpy.float32'>)
DOUBLE = ('double', <class 'snowflake.snowpark.types.DoubleType'>, <class 'numpy.float64'>)
UINT8 = ('uint8', <class 'snowflake.snowpark.types.ByteType'>, <class 'numpy.uint8'>)
UINT16 = ('uint16', <class 'snowflake.snowpark.types.ShortType'>, <class 'numpy.uint16'>)
UINT32 = ('uint32', <class 'snowflake.snowpark.types.IntegerType'>, <class 'numpy.uint32'>)
UINT64 = ('uint64', <class 'snowflake.snowpark.types.LongType'>, <class 'numpy.uint64'>)
BOOL = ('bool', <class 'snowflake.snowpark.types.BooleanType'>, <class 'numpy.bool_'>)
STRING = ('string', <class 'snowflake.snowpark.types.StringType'>, <class 'numpy.str_'>)
BYTES = ('bytes', <class 'snowflake.snowpark.types.BinaryType'>, <class 'numpy.bytes_'>)
TIMESTAMP_NTZ = ('datetime64[ns]', <class 'snowflake.snowpark.types.TimestampType'>, 'datetime64[ns]')