get_all_comments
FunctionSource
comments: {str} = get_all_comments(data: Annotations | [AnnoItem])
Get the set of all comments in the annotation data. The returned comments are unordered.
Aliases
This function can be acquired by
import dash_picture_annotation as dpa
dpa.get_all_comments
dpa.utilities.get_all_comments
Arguments
Requires
Argument | Type | Required | |
---|---|---|---|
data | Annotations | [AnnoItem] | The annotation data that is checked. |
Returns
Argument | Type | |
---|---|---|
comments | {str} | The unordered set of comments appearing in the annotation data. If the data does not contain any comment, will return an empty set. |
Examples
Get all comments of the data
- Codes
- Results
get_comments_from_anno.py
import pprint
import dash_picture_annotation as dpa
mark = lambda pos: {"x": pos, "y": pos, "width": 0, "height": 0, "type": "RECT"}
data = [
{"id": "a", "mark": mark(0)},
{"id": "b", "mark": mark(1)},
{"id": "c", "mark": mark(2), "comment": "type-1"},
{"id": "d", "mark": mark(3), "comment": "type-2"},
{"id": "d", "mark": mark(4), "comment": "type-2"},
]
data_wrapped = {"timestamp": 0, "data": data}
pprint.pprint(dpa.get_all_comments(data))
pprint.pprint(dpa.get_all_comments(data_wrapped))
frozenset({'type-1', 'type-2'})
frozenset({'type-1', 'type-2'})