graphid.core.mixin_callbacks module

class graphid.core.mixin_callbacks.InfrCallbacks[source]

Bases: object

Methods relating to callbacks that must be registered with the inference object for it to work properly.

set_ranker(ranker)[source]

ranker should be a function that accepts a list of annotation ids and return a list of the top K ranked annotations.

set_verifier(verifier, task='match_state')[source]

verifier should be a function that accepts a list of annotation pairs and produces the 3-state match_state probabilities.

refresh_candidate_edges()[source]

CommandLine

python -m graphid.core.mixin_callbacks InfrCallbacks.refresh_candidate_edges

Example

>>> from graphid import demo
>>> kwargs = dict(num_pccs=40, size=2)
>>> infr = demo.demodata_infr(**kwargs)
>>> infr.refresh_candidate_edges()
class graphid.core.mixin_callbacks.InfrCandidates[source]

Bases: object

Methods that should be used by callbacks to add new edges to be considered as candidates in the priority queue.

add_candidate_edges(candidate_edges)[source]
ensure_task_probs(edges)[source]

Ensures that probabilities are assigned to the edges. This gaurentees that infr.task_probs contains data for edges. (Currently only the primary task is actually ensured)

CommandLine

python -m graphid.core.mixin_callbacks InfrCandidates.ensure_task_probs

Doctest

>>> from graphid import demo
>>> infr = demo.demodata_infr(num_pccs=6, p_incon=.5, size_std=2)
>>> edges = list(infr.edges())
>>> infr.ensure_task_probs(edges)
>>> assert all([np.isclose(sum(p.values()), 1)
>>>             for p in infr.task_probs['match_state'].values()])
ensure_priority_scores(priority_edges)[source]

Ensures that priority attributes are assigned to the edges. This does not change the state of the queue.

Doctest

>>> from graphid import demo
>>> infr = demo.demodata_infr(num_pccs=6, p_incon=.5, size_std=2)
>>> edges = list(infr.edges())
>>> infr.ensure_priority_scores(edges)