graphid.core.mixin_helpers module

class graphid.core.mixin_helpers.AttrAccess[source]

Bases: object

Contains non-core helper functions

gen_node_attrs(key, nodes=None, default=NoParam)[source]
gen_edge_attrs(key, edges=None, default=NoParam, on_missing=None)[source]

maybe change to gen edge items

gen_node_values(key, nodes, default=NoParam)[source]
gen_edge_values(key, edges=None, default=NoParam, on_missing='error', on_keyerr='default')[source]
get_node_attrs(key, nodes=None, default=NoParam)[source]

Networkx node getter helper

get_edge_attrs(key, edges=None, default=NoParam, on_missing=None)[source]

Networkx edge getter helper

_get_edges_where(key, op, val, edges=None, default=NoParam, on_missing=None)[source]
get_edges_where_eq(key, val, edges=None, default=NoParam, on_missing=None)[source]
get_edges_where_ne(key, val, edges=None, default=NoParam, on_missing=None)[source]
set_node_attrs(key, node_to_prop)[source]

Networkx node setter helper

set_edge_attrs(key, edge_to_prop)[source]

Networkx edge setter helper

get_edge_attr(edge, key, default=NoParam, on_missing='error')[source]

single edge getter helper

set_edge_attr(edge, attr)[source]

single edge setter helper

get_annot_attrs(key, aids)[source]

Wrapper around get_node_attrs specific to annotation nodes

edges(data=False)[source]
has_edge(edge)[source]
get_edge_data(edge)[source]
get_nonvisual_edge_data(edge, on_missing='filter')[source]
get_edge_dataframe(edges=None, all=False)[source]
get_edge_df_text(edges=None, highlight=True)[source]
class graphid.core.mixin_helpers.Convenience[source]

Bases: object

static e_(u, v)[source]
property pos_graph
property neg_graph
property incomp_graph
property unreviewed_graph
property unknown_graph
print_graph_info()[source]
print_graph_connections(label='orig_name_label')[source]

label = ‘orig_name_label’

print_within_connection_info(edge=None, cc=None, aid=None, nid=None)[source]
pair_connection_info(aid1, aid2)[source]

Helps debugging when ibs.nids has info that annotmatch/staging do not Note: the relevant ibs parts were removed. Perhaps this is not useful now or should be moved to the ibeis plugin?

Example

>>> from graphid import demo
>>> infr = demo.demodata_infr(num_pccs=3, size=4)
>>> aid1, aid2 = 1, 2
>>> print(infr.pair_connection_info(aid1, aid2))
node_tag_hist()[source]
edge_tag_hist()[source]
match_state_df(index)[source]

Returns the current matching state of a list of edges.

PERHAPS WE SHOULD DEPRICATE THIS FUNCTION?

Note

This does NOT use the IBEIS database state, where as the original version of this function did.

CommandLine

python -m graphid.core.mixin_helpers Convenience.match_state_df

Example

>>> from graphid import demo
>>> infr = demo.demodata_infr(num_pccs=2, p_incomp=.8, size=4)
>>> index = list(infr.edges())
>>> print(infr.match_state_df(index))
           NEGTV  POSTV  INCMP
aid1 aid2
1    3     False  False   True
     4     False  False   True
     2     False   True  False
2    3     False  False   True
     4     False  False   True
3    4     False   True  False
     5     False  False   True
5    8     False  False   True
     7     False  False   True
     6     False  False   True
6    8     False  False   True
     7     False  False   True
7    8     False  False   True
class graphid.core.mixin_helpers.DummyEdges[source]

Bases: object

ensure_mst(label='name_label', meta_decision='same')[source]

Ensures that all names are names are connected.

Parameters:
  • label (str) – node attribute to use as the group id to form the mst.

  • meta_decision (str) – if specified adds clique edges as feedback items with this decision. Otherwise the edges are only explicitly added to the graph. This makes feedback items with user_id=algo:mst and with a confidence of guessing.

Example

>>> from graphid import demo
>>> infr = demo.demodata_infr(num_pccs=3, size=4)
>>> assert infr.status()['nCCs'] == 3
>>> infr.clear_edges()
>>> assert infr.status()['nCCs'] == 12
>>> infr.ensure_mst()
>>> assert infr.status()['nCCs'] == 3
ensure_cliques(label='name_label', meta_decision=None)[source]

Force each name label to be a clique.

Parameters:
  • label (str) – node attribute to use as the group id to form the cliques.

  • meta_decision (str) – if specified adds clique edges as feedback items with this decision. Otherwise the edges are only explicitly added to the graph.

Parameters:
  • label (str) – defaults to ‘name_label’

  • meta_decision (str) – if specified, the feedback edges added are added this meta decision and with the user_id=algo:clique.

CommandLine

python -m graphid.core.mixin_helpers ensure_cliques

Example

>>> from graphid import demo
>>> label = 'name_label'
>>> infr = demo.demodata_infr(num_pccs=3, size=5)
>>> print(ub.urepr(infr.status()))
>>> assert infr.status()['nEdges'] < 33
>>> infr.ensure_cliques()
>>> print(ub.urepr(infr.status()))
>>> assert infr.status()['nEdges'] == 31
>>> assert infr.status()['nUnrevEdges'] == 12
>>> assert len(list(infr.find_clique_edges(label))) > 0
>>> infr.ensure_cliques(meta_decision=SAME)
>>> assert infr.status()['nUnrevEdges'] == 0
>>> assert len(list(infr.find_clique_edges(label))) == 0
ensure_full()[source]

Explicitly places all edges, but does not make any feedback items

find_clique_edges(label='name_label')[source]

Augmenting edges that would complete each the specified cliques. (based on the group inferred from label)

Parameters:

label (str) – node attribute to use as the group id to form the cliques.

find_mst_edges(label='name_label')[source]

Returns edges to augment existing PCCs (by label) in order to ensure they are connected with positive edges.

Example

>>> # DISABLE_DOCTEST
>>> from graphid.core.mixin_helpers import *  # NOQA
>>> import ibeis
>>> ibs = ibeis.opendb(defaultdb='PZ_MTEST')
>>> infr = ibeis.AnnotInference(ibs, 'all', autoinit=True)
>>> label = 'orig_name_label'
>>> label = 'name_label'
>>> infr.find_mst_edges()
>>> infr.ensure_mst()
find_connecting_edges()[source]

Searches for a small set of edges, which if reviewed as positive would ensure that each PCC is k-connected. Note that in somes cases this is not possible