Skip to main content

is_annotations

FunctionSource

flag: TypeGuard[Annotations] = is_annotations(data: Any)

Implementation of isinstance(data, Annotations).

Aliases

This function can be acquired by

import dash_picture_annotation as dpa


dpa.is_annotations
dpa.typehints.is_annotations

Arguments

Requires

ArgumentTypeRequired
Description
dataAnyThe value to be verified.

Returns

ArgumentType
Description
flagboolIf this value is True, data an instance of Annotations, vice versa.

Examples

Check whether an object is an Annotations

check_is_annotations.py
import dash_picture_annotation as dpa


anno_item: dpa.AnnoItem = {
"id": "test",
"mark": {"x": 1, "y": 2, "width": 1, "height": 1, "type": "RECT"},
}

print(dpa.is_annotations({}))
print(dpa.is_annotations({"data": anno_item}))
print(dpa.is_annotations({"data": [anno_item]}))
print(dpa.is_annotations({"data": (anno_item,)}))
print(dpa.is_annotations([anno_item]))
print(dpa.is_annotations({"timestamp": 0, "data": [anno_item]}))
print(dpa.is_annotations({"timestamp": "0", "data": [anno_item]}))