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
Argument | Type | Required | |
---|---|---|---|
data | Any | The value to be verified. |
Returns
Argument | Type | |
---|---|---|
flag | bool | If this value is True , data an instance of Annotations , vice versa. |
Examples
Check whether an object is an Annotations
- Codes
- Results
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]}))
False
False
True
False
False
True
False