-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCompareCorrespondences.py
41 lines (31 loc) · 1.55 KB
/
CompareCorrespondences.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# INPUT: correspondences1: A dictionary of correspondences between A and B
# header1: Header string for first correspondences
# correspondences2: A dictionary of correspondences between A and B
# header2: Header string for second correspondences
# OUTPUT: identical: A dictionary of correspondences that are identical
# in1not2: A dictionary of correspondences that are in 1 but not in 2
# in2not1: A dictionary of correspondences that are in 2 but not in 1
# AUTHOR:
def CompareCorrespondences(correspondences1,header1,correspondences2,header2):
identical = {} # empty dictionary
in1not2 = {} # empty dictionary
in2not1 = {} # empty dictionary
# first, iterate through all key, value pairs in correspondences1.
# If the same key, value pair is in correspondences2, add this correspondence
# to identical. If not, add it to in1not2.
for key, value in correspondences1.iteritems():
if key in correspondences2:
if value==correspondences2[key]:
identical[key]= value
else:
in1not2[key] = value
for key, value in correspondences2.iteritems():
if key in correspondences1:
if value!=correspondences1[key]:
in2not1[key] = value
else:
in2not1[key] = value
# next, iterate through all key, value pairs in correspondences2.
# Only look for ones that are not in correspondences1, and add them to
# in2not1
return identical, in1not2, in2not1