Skip to content

renumics.spotlight.dtypes

dtypes

Spotlight data types.

The most dtypes are non-customazable and can be used through simple importing the respective module variables (e.g. float_dtype, image_dtype).

Some dtypes are customazable and only their default versions can be defined through the respective module variables (e.g. category_dtype, embedding_dtype). For more info, see the module classes.

In the most usage cases string or object aliases can be used instead of the default dtypes. For more info, see the module classes.

The main usage of the dtypes is customizing the spotlight.show.

bool_dtype module-attribute

bool_dtype = DType('bool')

Bool dtype. Aliases: "bool", bool.

int_dtype module-attribute

int_dtype = DType('int')

Integer dtype. Aliases: "int", int.

float_dtype module-attribute

float_dtype = DType('float')

Float dtype. Aliases: "float", float.

bytes_dtype module-attribute

bytes_dtype = DType('bytes')

Bytes dtype. Aliases: "bytes", bytes.

str_dtype module-attribute

str_dtype = DType('str')

String dtype. Aliases: "str", str.

datetime_dtype module-attribute

datetime_dtype = DType('datetime')

Datetime dtype. Aliases: "datetime", datetime.datetime.

category_dtype module-attribute

category_dtype = CategoryDType()

Categorical dtype with arbitraty categories. Aliases: "Category".

window_dtype module-attribute

window_dtype = DType('Window')

A single window. Aliases: "Window".

A single window is represented by an array-like with two timestamps in seconds as float values.

Single NaN, infinity and out-of-bound values will be clipped by the audio/time series bounds. In case of both non-valid values no window will be showed. Descending values will be visually highlighted.

bounding_box_dtype module-attribute

bounding_box_dtype = DType('BoundingBox')

Single or multiple bounding boxes. Aliases: "BoundingBox".

A single bounding box is represented by an array-like with its relative coordinates [x_min, y_min, x_max, y_max] (float values scaled onto 0 to 1). Top-left image corner is assumed to be (0, 0).

bounding_boxes_dtype module-attribute

bounding_boxes_dtype = SequenceDType(bounding_box_dtype)

Multiple bounding boxes.

Multiple bounding boxes for the same image are represented by an array-like of floats with shape (n, 4) (preferred) or (4, n).

embedding_dtype module-attribute

embedding_dtype = EmbeddingDType()

Embedding dtype. Aliases: "Embedding", renumics.spotlight.media.Embedding.

array_dtype module-attribute

array_dtype = ArrayDType()

numpy array dtype. Aliases: "array", np.ndarray.

image_dtype module-attribute

image_dtype = DType('Image')

Image dtype. Aliases: "Image", renumics.spotlight.media.Image.

audio_dtype module-attribute

audio_dtype = DType('Audio')

Audio dtype. Aliases: "Audio", renumics.spotlight.media.Audio.

mesh_dtype module-attribute

mesh_dtype = DType('Mesh')

Mesh dtype. Aliases: "Mesh", renumics.spotlight.media.Mesh.

sequence_1d_dtype module-attribute

sequence_1d_dtype = Sequence1DDType()

1D-sequence dtype with arbitraty axis labels. Aliases: "Sequence1D", renumics.spotlight.media.Sequence1D.

video_dtype module-attribute

video_dtype = DType('Video')

Video dtype. Aliases: "video", renumics.spotlight.media.Video.

unknown_dtype module-attribute

unknown_dtype = DType('unknown')

Unknown dtype. Aliases: "unknown".

any_dtype module-attribute

any_dtype = DType('any')

Unknown dtype which accepts any value. Aliases: "any".

file_dtype module-attribute

file_dtype = DType('file')

File Dtype (bytes or str(path)). Aliases: "file".

DType

dict

dict() -> dict

Serialize dtype as dict.

CategoryDType

Bases: DType

Categorical dtype with predefined categories.

Category names and codes are assured to be unique. Empty categories mean to be defined later (in this case, equivalent to the category_dtype module variable).

Using with category names

from renumics.spotlight import dtypes dtype = dtypes.CategoryDType(["cat", "dog"]) str(dtype) 'Category' dtype.categories {'cat': 0, 'dog': 1} dtype.inverted_categories

Example of usage with category mapping

from renumics.spotlight import dtypes dtype = dtypes.CategoryDType({"four": 4, "two": 2}) dtype.categories

Example of usage with empty categories

from renumics.spotlight import dtypes dtype = dtypes.CategoryDType() dtype == dtypes.category_dtype True

categories property

categories: Optional[Dict[str, int]]

Category mapping (string category -> integer code).

inverted_categories property

inverted_categories: Optional[Dict[int, str]]

Inverted Category mapping (integer code -> string category).

ArrayDType

Bases: DType

Array dtype with optional shape.

Attributes:

Name Type Description
shape Optional[Tuple[Optional[int], ...]]

Array dimensions. Can be fully or partially defined. No shape means to be defined later.

Example of usage with defined shape

from renumics.spotlight import dtypes dtype = dtypes.ArrayDType((10, None, 4)) str(dtype) 'array' dtype.shape (10, None, 4) dtype.ndim 3

Example of usage with empty shape

from renumics.spotlight import dtypes dtype = dtypes.ArrayDType() dtype.ndim 0 dtype == dtypes.array_dtype True

ndim property

ndim: int

Number of array dimensions.

EmbeddingDType

Bases: DType

Embedding dtype with optional length.

Attributes:

Name Type Description
length Optional[int]

Embedding length. No length means to be defined later.

Example of usage with defined length

from renumics.spotlight import dtypes dtype = dtypes.EmbeddingDType(8) str(dtype) 'Embedding' dtype.length 8

Example of usage with empty length

from renumics.spotlight import dtypes dtype = dtypes.EmbeddingDType() dtype == dtypes.embedding_dtype True

Sequence1DDType

Bases: DType

1D-sequence dtype with optional axis names.

Attributes:

Name Type Description
x_label str

Optional name of the x axis.

y_label str

Optional name of the y axis.

Example of usage with defined labels

from renumics.spotlight import dtypes dtype = dtypes.Sequence1DDType("time", "acceleration") str(dtype) 'Sequence1D' dtype.x_label 'time' dtype.y_label 'acceleration'

Example of usage with empty labels

from renumics.spotlight import dtypes dtype = dtypes.Sequence1DDType() dtype == dtypes.sequence_1d_dtype True

SequenceDType

Bases: DType

Sequence of values with the same dtype.