holonote.annotate Package#


annotate Package#

class holonote.annotate.AnnotationTable[source]#

Bases: object

Class that stores and manipulates annotation data, including methods to declare annotations and commit edits back to the original data source such as a database.

add_annotation(regions: dict[str, Any], spec: SpecDict, **fields)[source]#

Takes a list of regions or the special value ‘annotation-regions’ to use attached annotators

clear_edits(edit_type=None)[source]#

Clear edit state and index mapping

load(connector=None, fields_df=None, primary_key_name=None, fields=None, spec=None)[source]#

Load the AnnotationTable from a connector or a fields DataFrame.

load_annotation_table(conn: Connector, fields: list[str], spec: SpecDict) None[source]#

Load the AnnotationTable region and field DataFrame from a connector.

Parameters:
  • conn (Connector) – Database connection

  • fields (list[str]) – List of field columns to load from the connector

  • spec (SpecDict) – Dictionary of region specifications

revert_to_snapshot()[source]#

Clears outstanding changes and used to implement an basic undo system.

snapshot()[source]#

Saves a snapshot. Expected to only be used after a syncing commit

class holonote.annotate.Annotator(spec: dict, **params)[source]#

Bases: AnnotatorInterface

An annotator displays the contents of an AnnotationTable and provides the means to manipulate view the corresponding contents, add new annotations and update existing annotations.

Parameters inherited from:

holonote.annotate.annotator.AnnotatorInterface: selected_indices, spec, fields, static_fields, default_region, connector, event, commit_event

groupby = param.Selector(allow_refs=True, label=’Groupby’, names={}, nested_refs=False, objects=[], rx=<param.reactive.reactive_ops object at 0x7f908d29ef90>)

Groupby dimension

visible = param.ListSelector(allow_refs=True, label=’Visible’, names={}, nested_refs=False, objects=[], rx=<param.reactive.reactive_ops object at 0x7f908c788d90>)

Visible dimensions, needs groupby enabled

style = param.ClassSelector(allow_refs=False, class_=<class ‘holonote.annotate.display.Style’>, default=Style(alpha=0.2, color=None, edit_alpha=0.4, edit_color=’blue’, edit_line_opts={}, edit_opts={‘line_color’: ‘black’}, edit_points_opts={}, edit_rectangle_opts={}, edit_span_opts={}, line_opts={}, name=’Style00221’, opts={}, points_opts={}, rectangle_opts={}, selection_alpha=0.7, selection_color=None, span_opts={}), label=’Style’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908da9b390>)

Style parameters

property all_fields: list#

Return a list of all fields including static fields

connector_class[source]#

alias of SQLiteDB

classmethod normalize_spec(input_spec: dict[str, Any], default_region=None) SpecDict[source]#

Normalize the spec to conform to SpecDict format

Accepted input spec formats: spec = {

# Range (two values) “A1”: (np.float64, “range”), “A2”: {“type”: np.float64, “region”: “range”}, “A3”: np.float64, # Special case # Point “B1”: (np.float64, “point”), “B2”: {“type”: np.float64, “region”: “point”}, # Geometry (“C1”, “D1”): {“type”: np.float64, “region”: “geometry”}, (“C2”, “D2”): (np.float64, “geometry”),

}

on_commit(callback) None[source]#

Register a callback to be called when an annotation commit is triggered.

This is a wrapper around param.bind with watch=True.

Parameters:

callback (function) – function to be called when an commit is triggered

on_event(callback) None[source]#

Register a callback to be called when an annotation event is triggered this can be either when an annotation is created, updated, or deleted.

This is a wrapper around param.bind with watch=True.

Parameters:

callback (function) – function to be called when an annotation event is triggered

refresh(clear=False) None[source]#

Method to update display state of the annotator and optionally clear stale visual state

select_by_index(*inds) None[source]#

Set the selection state by the indices i.e. primary key values

property selected_index#

Convenience property returning a single selected index (the first one) or None

class holonote.annotate.AutoIncrementKey(*, connector_class, field_name, policy, schema, name)[source]#

Bases: PrimaryKey

AUTOINCREMENT needed to prevent reuse of ids from deleted rows: https://www.sqlite.org/autoinc.html

Parameters inherited from:

field_name = param.String(allow_refs=False, default=’id’, label=’Field name’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908d33da50>)

policy = param.ObjectSelector(allow_refs=False, default=’ignore-mismatch’, label=’Policy’, names={}, nested_refs=False, objects=[‘insert’, ‘ignore-mismatch’, ‘warn-mismatch’, ‘error-mismatch’], rx=<param.reactive.reactive_ops object at 0x7f908ea1ead0>)

schema = param.String(allow_refs=False, constant=True, default=’INTEGER PRIMARY KEY AUTOINCREMENT’, label=’Schema’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908d36c290>)

cast(value)[source]#

Cast a user supplied value to a known supported type

class holonote.annotate.Connector(*, commit_hook, fields, primary_key, transforms, name)[source]#

Bases: Parameterized

Base class that support the auto-generated default schema

primary_key = param.Parameter(allow_refs=False, default=UUIDHexStringKey(connector_class=’SQLiteDB’, field_name=’uuid’, length=32, name=’UUIDHexStringKey00220’, policy=’insert’, schema=’TEXT PRIMARY KEY’), label=’Primary key’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908d321190>)

commit_hook = param.Parameter(allow_None=True, allow_refs=False, label=’Commit hook’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908d322990>)

Callback, applies default schema if None

fields = param.List(allow_None=True, allow_refs=False, bounds=(0, None), label=’Fields’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908d322ad0>)

List of column names for domain-specific fields

transforms = param.Dict(allow_refs=False, class_=<class ‘dict’>, default={‘insert’: <function Connector.<lambda> at 0x7f908ef222a0>, ‘update’: <function Connector.<lambda> at 0x7f908ef22340>, ‘delete’: <function Connector.<lambda> at 0x7f908ef223e0>, ‘save’: <function Connector.<lambda> at 0x7f908ef22480>, ‘load’: <function Connector.<lambda> at 0x7f908ef22520>}, label=’Transforms’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908dd69f50>)

classmethod schema_from_field_types(fields)[source]#

Given a dictionary of fields fields and values return the field schemas

classmethod schema_from_field_values(fields)[source]#

Given a dictionary of fields fields and values return the field schemas

class holonote.annotate.SQLiteDB(column_schema=None, connect=True, **params)[source]#

Bases: _SQLiteDB

Parameters inherited from:

holonote.annotate.connector.Connector: primary_key, commit_hook, fields, transforms

holonote.annotate.connector._SQLiteDB: filename, table_name, column_schema

delete_all_rows()[source]#

Obviously a destructive operation!

classmethod schema_from_field_types(fields)[source]#

Given a dictionary of fields fields and values return the field schemas

classmethod schema_from_field_values(fields)[source]#

Given a dictionary of fields fields and values return the field schemas

class holonote.annotate.Style(*, alpha, color, edit_alpha, edit_color, edit_line_opts, edit_opts, edit_points_opts, edit_rectangle_opts, edit_span_opts, line_opts, opts, points_opts, rectangle_opts, selection_alpha, selection_color, span_opts, name)[source]#

Bases: Parameterized

Style class for controlling the appearance of the annotations indicator and editor.

This can be accessed as an accessor on an annotator object, the following will set the annotation color to red:

>>> from holonote.annotate import Annotator
>>> annotator = Annotator(...)
>>> annotator.style.color = "red"

This will update existing annotation displays and any new displays with the new style.

The style object can also be used to control the appearance of the editor and selected indicator:

>>> annotator.style.edit_color = "blue"
>>> annotator.style.edit_alpha = 0.5
>>> annotator.style.selection_color = "green"
>>> annotator.style.selection_alpha = 0.5

See the [styling notebook](../../examples/styling.ipynb) for more examples of how to use the style object.

alpha = param.Number(allow_refs=True, bounds=(0, 1), default=0.2, inclusive_bounds=(True, True), label=’Alpha’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908d3a1290>)

Alpha value for non-selected regions

selection_alpha = param.Number(allow_refs=True, bounds=(0, 1), default=0.7, inclusive_bounds=(True, True), label=’Selection alpha’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908cec0ad0>)

Alpha value for selected regions

edit_alpha = param.Number(allow_refs=True, bounds=(0, 1), default=0.4, inclusive_bounds=(True, True), label=’Edit alpha’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908d3a1290>)

Alpha value for editing regions

color = param.Parameter(allow_None=True, allow_refs=True, label=’Color’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908cec0750>)

Color of the indicator

edit_color = param.Parameter(allow_refs=True, default=’blue’, label=’Edit color’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908d3a23d0>)

Color of the editor

selection_color = param.Parameter(allow_None=True, allow_refs=True, label=’Selection color’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908cec2a90>)

Color of selection, by the default the same as color

opts = param._StyleOpts(allow_refs=False, class_=<class ‘dict’>, default={}, label=’Opts’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908d32ad50>)

line_opts = param._StyleOpts(allow_refs=False, class_=<class ‘dict’>, default={}, label=’Line opts’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908cec2a90>)

span_opts = param._StyleOpts(allow_refs=False, class_=<class ‘dict’>, default={}, label=’Span opts’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908d3a0810>)

rectangle_opts = param._StyleOpts(allow_refs=False, class_=<class ‘dict’>, default={}, label=’Rectangle opts’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908cec2a90>)

points_opts = param._StyleOpts(allow_refs=False, class_=<class ‘dict’>, default={}, label=’Points opts’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908d3a23d0>)

edit_opts = param._StyleOpts(allow_refs=False, class_=<class ‘dict’>, default={‘line_color’: ‘black’}, label=’Edit opts’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908cec2a90>)

edit_line_opts = param._StyleOpts(allow_refs=False, class_=<class ‘dict’>, default={}, label=’Edit line opts’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908d3a1d90>)

edit_span_opts = param._StyleOpts(allow_refs=False, class_=<class ‘dict’>, default={}, label=’Edit span opts’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908cec2a90>)

edit_rectangle_opts = param._StyleOpts(allow_refs=False, class_=<class ‘dict’>, default={}, label=’Edit rectangle opts’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908d3a1d90>)

edit_points_opts = param._StyleOpts(allow_refs=False, class_=<class ‘dict’>, default={}, label=’Edit points opts’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908cec2a90>)

class holonote.annotate.UUIDBinaryKey(*, connector_class, field_name, policy, schema, name)[source]#

Bases: PrimaryKey

Example of ‘insert’ policy where the generated primary key value can be inserted in the database as uuids are independent and not expected to clash.

Parameters inherited from:

field_name = param.String(allow_refs=False, default=’uuid’, label=’Field name’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908d2c7a50>)

policy = param.ObjectSelector(allow_refs=False, default=’insert’, label=’Policy’, names={}, nested_refs=False, objects=[‘insert’, ‘ignore-mismatch’, ‘warn-mismatch’, ‘error-mismatch’], rx=<param.reactive.reactive_ops object at 0x7f908d3a5710>)

schema = param.String(allow_refs=False, constant=True, default=’BINARY PRIMARY KEY’, label=’Schema’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908d3a5590>)

cast(value)[source]#

Cast a user supplied value to a known supported type

class holonote.annotate.UUIDHexStringKey(*, length, connector_class, field_name, policy, schema, name)[source]#

Bases: PrimaryKey

Example of ‘insert’ policy where the generated primary key value can be inserted in the database as uuids are independent and not expected to clash.

Parameters inherited from:

field_name = param.String(allow_refs=False, default=’uuid’, label=’Field name’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908d2be7d0>)

policy = param.ObjectSelector(allow_refs=False, default=’insert’, label=’Policy’, names={}, nested_refs=False, objects=[‘insert’, ‘ignore-mismatch’, ‘warn-mismatch’, ‘error-mismatch’], rx=<param.reactive.reactive_ops object at 0x7f908d2bffd0>)

schema = param.String(allow_refs=False, constant=True, default=’TEXT PRIMARY KEY’, label=’Schema’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908d2be7d0>)

length = param.Integer(allow_refs=False, bounds=(4, 32), default=32, inclusive_bounds=(True, True), label=’Length’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908d2bf4d0>)

cast(value)[source]#

Cast a user supplied value to a known supported type


annotator Module#

digraph inheritancef02de287fc { bgcolor=transparent; fontsize=18; rankdir=LR; size="12.0, 12.0"; "holonote.annotate.annotator.AnnotationEvent" [URL="#holonote.annotate.annotator.AnnotationEvent",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="An Event Parameter is one whose value is intimately linked to the"]; "param.parameters.Event" -> "holonote.annotate.annotator.AnnotationEvent" [arrowsize=0.5,style="setlinewidth(0.5)"]; "holonote.annotate.annotator.Annotator" [URL="#holonote.annotate.annotator.Annotator",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="An annotator displays the contents of an AnnotationTable and"]; "holonote.annotate.annotator.AnnotatorInterface" -> "holonote.annotate.annotator.Annotator" [arrowsize=0.5,style="setlinewidth(0.5)"]; "holonote.annotate.annotator.AnnotatorInterface" [URL="#holonote.annotate.annotator.AnnotatorInterface",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Baseclass that expresses the Python interface of an Annotator"]; "param.parameterized.Parameterized" -> "holonote.annotate.annotator.AnnotatorInterface" [arrowsize=0.5,style="setlinewidth(0.5)"]; "holonote.annotate.annotator.event_info" [URL="#holonote.annotate.annotator.event_info",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="event_info(type, index, region, fields)"]; "param.parameterized.Parameter" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="An attribute descriptor for declaring parameters."]; "param.parameterized.Parameterized" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Base class for named objects that support Parameters and message"]; "param.parameters.Boolean" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Binary or tristate Boolean Parameter."]; "param.parameterized.Parameter" -> "param.parameters.Boolean" [arrowsize=0.5,style="setlinewidth(0.5)"]; "param.parameters.Event" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="An Event Parameter is one whose value is intimately linked to the"]; "param.parameters.Boolean" -> "param.parameters.Event" [arrowsize=0.5,style="setlinewidth(0.5)"]; }
class holonote.annotate.annotator.AnnotationEvent(default=False, *, doc=None, label=None, precedence=None, instantiate=False, constant=False, readonly=False, pickle_default_value=True, allow_None=False, per_instance=True, allow_refs=False, nested_refs=False)[source]#

Bases: Event

An Event Parameter is one whose value is intimately linked to the triggering of events for watchers to consume. Event has a Boolean value, which when set to True triggers the associated watchers (as any Parameter does) and then is automatically set back to False. Conversely, if events are triggered directly via .trigger, the value is transiently set to True (so that it’s clear which of many parameters being watched may have changed), then restored to False when the triggering completes. An Event parameter is thus like a momentary switch or pushbutton with a transient True value that serves only to launch some other action (e.g. via a param.depends decorator), rather than encapsulating the action itself as param.Action does.

classmethod deserialize(value)[source]#

Given a serializable Python value, return a value that the parameter can be set to

classmethod serialize(value)[source]#

Given the parameter value, return a Python value suitable for serialization

class holonote.annotate.annotator.Annotator(spec: dict, **params)[source]#

Bases: AnnotatorInterface

An annotator displays the contents of an AnnotationTable and provides the means to manipulate view the corresponding contents, add new annotations and update existing annotations.

Parameters inherited from:

holonote.annotate.annotator.AnnotatorInterface: selected_indices, spec, fields, static_fields, default_region, connector, event, commit_event

groupby = param.Selector(allow_refs=True, label=’Groupby’, names={}, nested_refs=False, objects=[], rx=<param.reactive.reactive_ops object at 0x7f908d3789d0>)

Groupby dimension

visible = param.ListSelector(allow_refs=True, label=’Visible’, names={}, nested_refs=False, objects=[], rx=<param.reactive.reactive_ops object at 0x7f908ce950d0>)

Visible dimensions, needs groupby enabled

style = param.ClassSelector(allow_refs=False, class_=<class ‘holonote.annotate.display.Style’>, default=Style(alpha=0.2, color=None, edit_alpha=0.4, edit_color=’blue’, edit_line_opts={}, edit_opts={‘line_color’: ‘black’}, edit_points_opts={}, edit_rectangle_opts={}, edit_span_opts={}, line_opts={}, name=’Style00221’, opts={}, points_opts={}, rectangle_opts={}, selection_alpha=0.7, selection_color=None, span_opts={}), label=’Style’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908cd568d0>)

Style parameters

property all_fields: list#

Return a list of all fields including static fields

connector_class[source]#

alias of SQLiteDB

classmethod normalize_spec(input_spec: dict[str, Any], default_region=None) SpecDict[source]#

Normalize the spec to conform to SpecDict format

Accepted input spec formats: spec = {

# Range (two values) “A1”: (np.float64, “range”), “A2”: {“type”: np.float64, “region”: “range”}, “A3”: np.float64, # Special case # Point “B1”: (np.float64, “point”), “B2”: {“type”: np.float64, “region”: “point”}, # Geometry (“C1”, “D1”): {“type”: np.float64, “region”: “geometry”}, (“C2”, “D2”): (np.float64, “geometry”),

}

on_commit(callback) None[source]#

Register a callback to be called when an annotation commit is triggered.

This is a wrapper around param.bind with watch=True.

Parameters:

callback (function) – function to be called when an commit is triggered

on_event(callback) None[source]#

Register a callback to be called when an annotation event is triggered this can be either when an annotation is created, updated, or deleted.

This is a wrapper around param.bind with watch=True.

Parameters:

callback (function) – function to be called when an annotation event is triggered

refresh(clear=False) None[source]#

Method to update display state of the annotator and optionally clear stale visual state

select_by_index(*inds) None[source]#

Set the selection state by the indices i.e. primary key values

property selected_index#

Convenience property returning a single selected index (the first one) or None

class holonote.annotate.annotator.AnnotatorInterface(spec, **params)[source]#

Bases: Parameterized

Baseclass that expresses the Python interface of an Annotator without using any holoviews components and without requiring display. Most of this API centers around how the Annotator interacts with the AnnotationTable.

selected_indices = param.List(allow_refs=False, bounds=(0, None), default=[], label=’Selected indices’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908cd642d0>)

Indices of selected annotations

spec = param.Dict(allow_refs=False, class_=<class ‘dict’>, default={}, label=’Spec’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908cd63ad0>)

Specification of annotation types

fields = param.List(allow_refs=False, bounds=(0, None), constant=True, default=[‘description’], label=’Fields’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908cd64190>)

List of fields

static_fields = param.Dict(allow_refs=False, class_=<class ‘dict’>, constant=True, default={}, label=’Static fields’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908cd63810>)

Dictionary with key and value which will be added to each commit

default_region = param.Selector(allow_refs=False, default=’range’, label=’Default region’, names={}, nested_refs=False, objects=[‘range’, ‘point’], rx=<param.reactive.reactive_ops object at 0x7f908cd64150>)

Default region, if nothing is provided

connector = param.ClassSelector(allow_None=True, allow_refs=False, class_=<class ‘holonote.annotate.connector.Connector’>, label=’Connector’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908cd63b90>)

event = param.AnnotationEvent(allow_refs=False, default=False, label=’Event’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908cd642d0>)

Event that is triggered when an annotation is created, updated, or deleted

commit_event = param.Event(allow_refs=False, default=False, label=’Commit event’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908cd63c90>)

Event that is triggered when an annotation is committed

property all_fields: list#

Return a list of all fields including static fields

connector_class[source]#

alias of SQLiteDB

classmethod normalize_spec(input_spec: dict[str, Any], default_region=None) SpecDict[source]#

Normalize the spec to conform to SpecDict format

Accepted input spec formats: spec = {

# Range (two values) “A1”: (np.float64, “range”), “A2”: {“type”: np.float64, “region”: “range”}, “A3”: np.float64, # Special case # Point “B1”: (np.float64, “point”), “B2”: {“type”: np.float64, “region”: “point”}, # Geometry (“C1”, “D1”): {“type”: np.float64, “region”: “geometry”}, (“C2”, “D2”): (np.float64, “geometry”),

}

on_commit(callback) None[source]#

Register a callback to be called when an annotation commit is triggered.

This is a wrapper around param.bind with watch=True.

Parameters:

callback (function) – function to be called when an commit is triggered

on_event(callback) None[source]#

Register a callback to be called when an annotation event is triggered this can be either when an annotation is created, updated, or deleted.

This is a wrapper around param.bind with watch=True.

Parameters:

callback (function) – function to be called when an annotation event is triggered

refresh(clear=False)[source]#

Method to update display state of the annotator and optionally clear stale visual state

select_by_index(*inds) None[source]#

Set the selection state by the indices i.e. primary key values

property selected_index#

Convenience property returning a single selected index (the first one) or None

class holonote.annotate.annotator.event_info(type, index, region, fields)#

Bases: tuple

count(value, /)#

Return number of occurrences of value.

fields#

Alias for field number 3

index#

Alias for field number 1

region#

Alias for field number 2

type#

Alias for field number 0


connector Module#

digraph inheritancebd6c52ac3c { bgcolor=transparent; fontsize=18; rankdir=LR; size="12.0, 12.0"; "holonote.annotate.connector.AutoIncrementKey" [URL="#holonote.annotate.connector.AutoIncrementKey",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="AUTOINCREMENT needed to prevent reuse of ids from deleted rows:"]; "holonote.annotate.connector.PrimaryKey" -> "holonote.annotate.connector.AutoIncrementKey" [arrowsize=0.5,style="setlinewidth(0.5)"]; "holonote.annotate.connector.Connector" [URL="#holonote.annotate.connector.Connector",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Base class that support the auto-generated default schema"]; "param.parameterized.Parameterized" -> "holonote.annotate.connector.Connector" [arrowsize=0.5,style="setlinewidth(0.5)"]; "holonote.annotate.connector.PrimaryKey" [URL="#holonote.annotate.connector.PrimaryKey",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Generator of the primary key used to keep track of annotations in"]; "param.parameterized.Parameterized" -> "holonote.annotate.connector.PrimaryKey" [arrowsize=0.5,style="setlinewidth(0.5)"]; "holonote.annotate.connector.SQLiteDB" [URL="#holonote.annotate.connector.SQLiteDB",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "holonote.annotate.connector.UUIDBinaryKey" [URL="#holonote.annotate.connector.UUIDBinaryKey",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Example of 'insert' policy where the generated primary key value can"]; "holonote.annotate.connector.PrimaryKey" -> "holonote.annotate.connector.UUIDBinaryKey" [arrowsize=0.5,style="setlinewidth(0.5)"]; "holonote.annotate.connector.UUIDHexStringKey" [URL="#holonote.annotate.connector.UUIDHexStringKey",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Example of 'insert' policy where the generated primary key value can"]; "holonote.annotate.connector.PrimaryKey" -> "holonote.annotate.connector.UUIDHexStringKey" [arrowsize=0.5,style="setlinewidth(0.5)"]; "holonote.annotate.connector.WidgetKey" [URL="#holonote.annotate.connector.WidgetKey",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Placeholder for a concept where the user can insert a primary key"]; "holonote.annotate.connector.PrimaryKey" -> "holonote.annotate.connector.WidgetKey" [arrowsize=0.5,style="setlinewidth(0.5)"]; "param.parameterized.Parameterized" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Base class for named objects that support Parameters and message"]; }
class holonote.annotate.connector.AutoIncrementKey(*, connector_class, field_name, policy, schema, name)[source]#

Bases: PrimaryKey

AUTOINCREMENT needed to prevent reuse of ids from deleted rows: https://www.sqlite.org/autoinc.html

Parameters inherited from:

field_name = param.String(allow_refs=False, default=’id’, label=’Field name’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908d1c7b90>)

policy = param.ObjectSelector(allow_refs=False, default=’ignore-mismatch’, label=’Policy’, names={}, nested_refs=False, objects=[‘insert’, ‘ignore-mismatch’, ‘warn-mismatch’, ‘error-mismatch’], rx=<param.reactive.reactive_ops object at 0x7f908d1cc2d0>)

schema = param.String(allow_refs=False, constant=True, default=’INTEGER PRIMARY KEY AUTOINCREMENT’, label=’Schema’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908d1c7c90>)

cast(value)[source]#

Cast a user supplied value to a known supported type

class holonote.annotate.connector.Connector(*, commit_hook, fields, primary_key, transforms, name)[source]#

Bases: Parameterized

Base class that support the auto-generated default schema

primary_key = param.Parameter(allow_refs=False, default=UUIDHexStringKey(connector_class=’SQLiteDB’, field_name=’uuid’, length=32, name=’UUIDHexStringKey00220’, policy=’insert’, schema=’TEXT PRIMARY KEY’), label=’Primary key’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908d1c65d0>)

commit_hook = param.Parameter(allow_None=True, allow_refs=False, label=’Commit hook’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908d1c5e50>)

Callback, applies default schema if None

fields = param.List(allow_None=True, allow_refs=False, bounds=(0, None), label=’Fields’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908d1c5910>)

List of column names for domain-specific fields

transforms = param.Dict(allow_refs=False, class_=<class ‘dict’>, default={‘insert’: <function Connector.<lambda> at 0x7f908ef222a0>, ‘update’: <function Connector.<lambda> at 0x7f908ef22340>, ‘delete’: <function Connector.<lambda> at 0x7f908ef223e0>, ‘save’: <function Connector.<lambda> at 0x7f908ef22480>, ‘load’: <function Connector.<lambda> at 0x7f908ef22520>}, label=’Transforms’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908d1c5f10>)

classmethod schema_from_field_types(fields)[source]#

Given a dictionary of fields fields and values return the field schemas

classmethod schema_from_field_values(fields)[source]#

Given a dictionary of fields fields and values return the field schemas

class holonote.annotate.connector.PrimaryKey(*, connector_class, field_name, policy, schema, name)[source]#

Bases: Parameterized

Generator of the primary key used to keep track of annotations in HoloViews.

The generated key is used to reference annotations until they are committed, at which point they may 1) be inserted in the database as the primary key value (policy=’insert’) 2) are checked against the primary key value chosen by the database which is expected to match in most cases.

In real situations where the key is chosen by the database, the key generated will not always match the actual key assigned. The policy parameter decides the resulting behavior in these cases.

field_name = param.String(allow_refs=False, default=’id’, label=’Field name’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908cf09dd0>)

policy = param.ObjectSelector(allow_refs=False, default=’ignore-mismatch’, label=’Policy’, names={}, nested_refs=False, objects=[‘insert’, ‘ignore-mismatch’, ‘warn-mismatch’, ‘error-mismatch’], rx=<param.reactive.reactive_ops object at 0x7f908d1cbd10>)

schema = param.String(allow_refs=False, constant=True, default=’INTEGER PRIMARY KEY’, label=’Schema’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908cd56210>)

connector_class = param.String(allow_refs=False, default=’SQLiteDB’, label=’Connector class’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908d1cbed0>)

cast(value)[source]#

Cast a user supplied value to a known supported type

class holonote.annotate.connector.SQLiteDB(column_schema=None, connect=True, **params)[source]#

Bases: _SQLiteDB

Parameters inherited from:

holonote.annotate.connector.Connector: primary_key, commit_hook, fields, transforms

holonote.annotate.connector._SQLiteDB: filename, table_name, column_schema

delete_all_rows()[source]#

Obviously a destructive operation!

classmethod schema_from_field_types(fields)[source]#

Given a dictionary of fields fields and values return the field schemas

classmethod schema_from_field_values(fields)[source]#

Given a dictionary of fields fields and values return the field schemas

class holonote.annotate.connector.UUIDBinaryKey(*, connector_class, field_name, policy, schema, name)[source]#

Bases: PrimaryKey

Example of ‘insert’ policy where the generated primary key value can be inserted in the database as uuids are independent and not expected to clash.

Parameters inherited from:

field_name = param.String(allow_refs=False, default=’uuid’, label=’Field name’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908d116c10>)

policy = param.ObjectSelector(allow_refs=False, default=’insert’, label=’Policy’, names={}, nested_refs=False, objects=[‘insert’, ‘ignore-mismatch’, ‘warn-mismatch’, ‘error-mismatch’], rx=<param.reactive.reactive_ops object at 0x7f908cf7d710>)

schema = param.String(allow_refs=False, constant=True, default=’BINARY PRIMARY KEY’, label=’Schema’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908d116d10>)

cast(value)[source]#

Cast a user supplied value to a known supported type

class holonote.annotate.connector.UUIDHexStringKey(*, length, connector_class, field_name, policy, schema, name)[source]#

Bases: PrimaryKey

Example of ‘insert’ policy where the generated primary key value can be inserted in the database as uuids are independent and not expected to clash.

Parameters inherited from:

field_name = param.String(allow_refs=False, default=’uuid’, label=’Field name’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908cf7d6d0>)

policy = param.ObjectSelector(allow_refs=False, default=’insert’, label=’Policy’, names={}, nested_refs=False, objects=[‘insert’, ‘ignore-mismatch’, ‘warn-mismatch’, ‘error-mismatch’], rx=<param.reactive.reactive_ops object at 0x7f908d1fef90>)

schema = param.String(allow_refs=False, constant=True, default=’TEXT PRIMARY KEY’, label=’Schema’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908cdc2dd0>)

length = param.Integer(allow_refs=False, bounds=(4, 32), default=32, inclusive_bounds=(True, True), label=’Length’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908d1fd350>)

cast(value)[source]#

Cast a user supplied value to a known supported type

class holonote.annotate.connector.WidgetKey(*, connector_class, field_name, policy, schema, name)[source]#

Bases: PrimaryKey

Placeholder for a concept where the user can insert a primary key value via a widget.

Parameters inherited from:

holonote.annotate.connector.PrimaryKey: field_name, policy, schema, connector_class

cast(value)[source]#

Cast a user supplied value to a known supported type


display Module#

digraph inheritance6fab839558 { bgcolor=transparent; fontsize=18; rankdir=LR; size="12.0, 12.0"; "holonote.annotate.display.AnnotationDisplay" [URL="#holonote.annotate.display.AnnotationDisplay",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "param.parameterized.Parameterized" -> "holonote.annotate.display.AnnotationDisplay" [arrowsize=0.5,style="setlinewidth(0.5)"]; "holonote.annotate.display.Indicator" [URL="#holonote.annotate.display.Indicator",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Collection of class methods that express annotation data as final"]; "holonote.annotate.display.Style" [URL="#holonote.annotate.display.Style",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Style class for controlling the appearance of the annotations"]; "param.parameterized.Parameterized" -> "holonote.annotate.display.Style" [arrowsize=0.5,style="setlinewidth(0.5)"]; "param.parameterized.Parameterized" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Base class for named objects that support Parameters and message"]; }
class holonote.annotate.display.AnnotationDisplay(annotator: Annotator, **params)[source]#

Bases: Parameterized

kdims = param.List(allow_refs=False, bounds=(1, 3), constant=True, default=[‘x’], label=’Kdims’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908cfbef10>)

Dimensions of the element

data = param.DataFrame(allow_None=True, allow_refs=False, class_=<class ‘pandas.core.frame.DataFrame’>, constant=True, label=’Data’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908cfe1850>)

Combined dataframe of annotation data

nearest_2d_point_threshold = param.Number(allow_None=True, allow_refs=False, bounds=(0, None), inclusive_bounds=(True, True), label=’Nearest 2d point threshold’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908cfe2e50>)

Threshold In the distance in data coordinates between the two dimensions; it does not consider the unit and magnitude differences between the dimensions for selecting an existing 2D point; anything over this threshold will create a new point instead. This parameter is experimental and is subject to change.

invert_axis = param.Boolean(allow_refs=False, default=False, label=’Invert axis’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908cf94c10>)

Switch the annotation axis

_count = param.Integer(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’ count’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908cfbf910>)

clear_indicated_region()[source]#

Clear any region currently indicated on the plot by the editor

get_indices_by_position(**inputs) list[Any][source]#

Return primary key values matching given position in data space

class holonote.annotate.display.Indicator[source]#

Bases: object

Collection of class methods that express annotation data as final displayed (vectorized) HoloViews object.

classmethod points_1d(data, region_labels, fields_labels, invert_axes=False, groupby: str | None = None)[source]#

Vectorizes point regions to VLines. Note does not support hover info

classmethod points_2d(data, region_labels, fields_labels, invert_axes=False, groupby: str | None = None)[source]#

Vectorizes point regions to VLines * HLines. Note does not support hover info

classmethod ranges_1d(data, region_labels, fields_labels, invert_axes=False, groupby: str | None = None)[source]#

Vectorizes an nd-overlay of range_1d rectangles.

NOTE: Should use VSpans once available!

classmethod ranges_2d(data, region_labels, fields_labels, invert_axes=False, groupby: str | None = None)[source]#

Vectorizes an nd-overlay of range_2d rectangles.

class holonote.annotate.display.Style(*, alpha, color, edit_alpha, edit_color, edit_line_opts, edit_opts, edit_points_opts, edit_rectangle_opts, edit_span_opts, line_opts, opts, points_opts, rectangle_opts, selection_alpha, selection_color, span_opts, name)[source]#

Bases: Parameterized

Style class for controlling the appearance of the annotations indicator and editor.

This can be accessed as an accessor on an annotator object, the following will set the annotation color to red:

>>> from holonote.annotate import Annotator
>>> annotator = Annotator(...)
>>> annotator.style.color = "red"

This will update existing annotation displays and any new displays with the new style.

The style object can also be used to control the appearance of the editor and selected indicator:

>>> annotator.style.edit_color = "blue"
>>> annotator.style.edit_alpha = 0.5
>>> annotator.style.selection_color = "green"
>>> annotator.style.selection_alpha = 0.5

See the [styling notebook](../../examples/styling.ipynb) for more examples of how to use the style object.

alpha = param.Number(allow_refs=True, bounds=(0, 1), default=0.2, inclusive_bounds=(True, True), label=’Alpha’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908cc2bb90>)

Alpha value for non-selected regions

selection_alpha = param.Number(allow_refs=True, bounds=(0, 1), default=0.7, inclusive_bounds=(True, True), label=’Selection alpha’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908cf8f650>)

Alpha value for selected regions

edit_alpha = param.Number(allow_refs=True, bounds=(0, 1), default=0.4, inclusive_bounds=(True, True), label=’Edit alpha’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908cc2add0>)

Alpha value for editing regions

color = param.Parameter(allow_None=True, allow_refs=True, label=’Color’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908cf8fc10>)

Color of the indicator

edit_color = param.Parameter(allow_refs=True, default=’blue’, label=’Edit color’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908cc283d0>)

Color of the editor

selection_color = param.Parameter(allow_None=True, allow_refs=True, label=’Selection color’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908cf8f850>)

Color of selection, by the default the same as color

opts = param._StyleOpts(allow_refs=False, class_=<class ‘dict’>, default={}, label=’Opts’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908cc28210>)

line_opts = param._StyleOpts(allow_refs=False, class_=<class ‘dict’>, default={}, label=’Line opts’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908cf8f850>)

span_opts = param._StyleOpts(allow_refs=False, class_=<class ‘dict’>, default={}, label=’Span opts’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908cc28210>)

rectangle_opts = param._StyleOpts(allow_refs=False, class_=<class ‘dict’>, default={}, label=’Rectangle opts’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908cf8f850>)

points_opts = param._StyleOpts(allow_refs=False, class_=<class ‘dict’>, default={}, label=’Points opts’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908cc283d0>)

edit_opts = param._StyleOpts(allow_refs=False, class_=<class ‘dict’>, default={‘line_color’: ‘black’}, label=’Edit opts’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908cf8f850>)

edit_line_opts = param._StyleOpts(allow_refs=False, class_=<class ‘dict’>, default={}, label=’Edit line opts’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908cc2bb50>)

edit_span_opts = param._StyleOpts(allow_refs=False, class_=<class ‘dict’>, default={}, label=’Edit span opts’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908cf8f850>)

edit_rectangle_opts = param._StyleOpts(allow_refs=False, class_=<class ‘dict’>, default={}, label=’Edit rectangle opts’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908cc2bb50>)

edit_points_opts = param._StyleOpts(allow_refs=False, class_=<class ‘dict’>, default={}, label=’Edit points opts’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x7f908cf8f850>)


table Module#

digraph inheritancef1e2c5f2fc { bgcolor=transparent; fontsize=18; rankdir=LR; size="12.0, 12.0"; "holonote.annotate.table.AnnotationTable" [URL="#holonote.annotate.table.AnnotationTable",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Class that stores and manipulates annotation data, including methods"]; }
class holonote.annotate.table.AnnotationTable[source]#

Bases: object

Class that stores and manipulates annotation data, including methods to declare annotations and commit edits back to the original data source such as a database.

add_annotation(regions: dict[str, Any], spec: SpecDict, **fields)[source]#

Takes a list of regions or the special value ‘annotation-regions’ to use attached annotators

clear_edits(edit_type=None)[source]#

Clear edit state and index mapping

load(connector=None, fields_df=None, primary_key_name=None, fields=None, spec=None)[source]#

Load the AnnotationTable from a connector or a fields DataFrame.

load_annotation_table(conn: Connector, fields: list[str], spec: SpecDict) None[source]#

Load the AnnotationTable region and field DataFrame from a connector.

Parameters:
  • conn (Connector) – Database connection

  • fields (list[str]) – List of field columns to load from the connector

  • spec (SpecDict) – Dictionary of region specifications

revert_to_snapshot()[source]#

Clears outstanding changes and used to implement an basic undo system.

snapshot()[source]#

Saves a snapshot. Expected to only be used after a syncing commit


typing Module#

digraph inheritance84445dbfe4 { bgcolor=transparent; fontsize=18; rankdir=LR; size="12.0, 12.0"; "holonote.annotate.typing.SpecItem" [URL="#holonote.annotate.typing.SpecItem",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Contains the type and region specification for a region."]; }
class holonote.annotate.typing.SpecItem[source]#

Bases: TypedDict

Contains the type and region specification for a region.

The type is a callable that can be used to convert the data to the correct type. This could be np.datetime64 or float for example.

The region specification is either “range”, “point”, or “geometry”.

clear() None.  Remove all items from D.#
copy() a shallow copy of D#
fromkeys(value=None, /)#

Create a new dictionary with keys from iterable and values set to value.

get(key, default=None, /)#

Return the value for key if key is in the dictionary, else default.

items() a set-like object providing a view on D's items#
keys() a set-like object providing a view on D's keys#
pop(k[, d]) v, remove specified key and return the corresponding value.#

If the key is not found, return the default if given; otherwise, raise a KeyError.

popitem()#

Remove and return a (key, value) pair as a 2-tuple.

Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.

setdefault(key, default=None, /)#

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

update([E, ]**F) None.  Update D from dict/iterable E and F.#

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values() an object providing a view on D's values#