Skip to content

Commit ee67357

Browse files
committed
add matching using similar types
1 parent c8f5330 commit ee67357

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

app/crossmatch/layered/object_type.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@
55
)
66
from app.crossmatch.models import PendingReason, RecordEvidence
77

8+
SIMILAR_TYPE_MAP = {
9+
"G": {"ext", "?", "QSO"},
10+
"ext": {"G", "?", "QSO"},
11+
}
12+
13+
14+
def _types_match(record_type: str, other_type: str) -> bool:
15+
return record_type == other_type or other_type in SIMILAR_TYPE_MAP.get(record_type, set())
16+
817

918
def object_type_resolver(
1019
evidence: RecordEvidence, previous_result: PreliminaryCrossmatchStatus
@@ -21,15 +30,17 @@ def object_type_resolver(
2130
neighbor = next((n for n in evidence.neighbors if n.pgc == previous_result.pgc), None)
2231
existing_type = neighbor.type_name if neighbor is not None else None
2332

24-
if existing_type is not None and record_type != existing_type:
33+
if existing_type is not None and not _types_match(record_type, existing_type):
2534
return previous_result, PendingReason.TYPE_MISMATCH
2635

2736
return previous_result, None
2837

2938
same_type_neighbors = [
3039
n
3140
for n in evidence.neighbors
32-
if n.pgc in previous_result.pgcs and record_type is not None and n.type_name == record_type
41+
if n.pgc in previous_result.pgcs
42+
and n.type_name is not None
43+
and _types_match(record_type, n.type_name)
3344
]
3445
if len(same_type_neighbors) == 1:
3546
return PreliminaryCrossmatchStatusExisting(same_type_neighbors[0].pgc), None

0 commit comments

Comments
 (0)