Exporting

Mapping

class qbindiff.mapping.Mapping(mapping: Iterable[tuple[Any, Any, float, int]], unmatched_primary: set[Any], unmatched_secondary: set[Any])[source]

Bases: object

This class represents an interface to access the result of the matching analysis. Its interface is independent of the underlying objects / items manipulated.

add_match(item1: Any, item2: Any, similarity: float | None = None, confidence: float = 0.0, squares: int | None = None) None[source]

Add the given match between the two items.

Parameters:
  • item1 – function address in primary

  • item2 – function address in secondary

  • similarity – similarity metric as float

  • confidence – confidence in the result (0..1)

  • squares – Number of squares being made

Returns:

None

is_match_primary(item: Any) bool[source]

Returns true if the items in primary did match with an item in secondary.

Parameters:

item – item to match in primary

Returns:

whether the item is matched in primary

is_match_secondary(item: Any) bool[source]

Returns true if the item in secondary did match with an item in primary.

Parameters:

item – item to match in secondary

Returns:

whether the item is matched in secondary

match_primary(item: Any) Match | None[source]

Returns the match associated with the given primary item (if any).

Parameters:

item – item to match in primary

Returns:

optional match

match_secondary(item: Any) Match | None[source]

Returns the match associated with the given secondary item (if any).

Parameters:

item – item to match in secondary

Returns:

optional match

property nb_item_primary: int

Total number of items in primary

property nb_item_secondary: int

Total number of items in secondary.

property nb_match: int

Number of matches

property nb_unmatched_primary: int

Number of unmatched items in primary.

property nb_unmatched_secondary: int

Number of unmatched items in secondary.

property normalized_similarity: float

Normalized similarity of the diff (from 0 to 1)

property primary_matched: set[Any]

Set of items matched in primary

property primary_unmatched: set[Any]

Set of items unmatched in primary.

remove_match(match: Match) None[source]

Remove the given matching from the matching.

Parameters:

match – Match object to remove from the matching

Returns:

None

property secondary_matched: set[Any]

Set of items matched in the secondary object.

property secondary_unmatched: set[Any]

Set of items unmatched in the secondary object.

property similarity: float

Sum of similarities of the diff (unbounded value)

property squares: float

Number of matching squares