Find a matching library signature. Returns (matchType, libSig, extraInLib, extraInSpec).
(specSig, libSigs)
| 699 | return differences |
| 700 | |
| 701 | def findLibraryMatch(specSig, libSigs): |
| 702 | '''Find a matching library signature. Returns (matchType, libSig, extraInLib, extraInSpec).''' |
| 703 | specInputs = set(specSig.inputs) |
| 704 | specOutputs = set(specSig.outputs) |
| 705 | |
| 706 | for libSig in libSigs: |
| 707 | libInputs = set(libSig.inputs) |
| 708 | libOutputs = set(libSig.outputs) |
| 709 | |
| 710 | # Check for exact match |
| 711 | if specInputs == libInputs and specOutputs == libOutputs: |
| 712 | return MatchType.EXACT, libSig, None, None |
| 713 | |
| 714 | # Check for different input sets (same outputs, different inputs) |
| 715 | if specOutputs == libOutputs and specInputs != libInputs: |
| 716 | # If there are common inputs, verify they have the same types |
| 717 | commonInputNames = {name for name, _ in specInputs} & {name for name, _ in libInputs} |
| 718 | if commonInputNames: |
| 719 | specInputDict = dict(specSig.inputs) |
| 720 | libInputDict = dict(libSig.inputs) |
| 721 | typesMatch = all(specInputDict[n] == libInputDict[n] for n in commonInputNames) |
| 722 | if not typesMatch: |
| 723 | continue # Common inputs have different types - not a match |
| 724 | |
| 725 | extraInLib = tuple(sorted(libInputs - specInputs)) |
| 726 | extraInSpec = tuple(sorted(specInputs - libInputs)) |
| 727 | return MatchType.DIFFERENT_INPUTS, libSig, extraInLib, extraInSpec |
| 728 | |
| 729 | return None, None, None, None |
| 730 | |
| 731 | def compareNodes(specNodes, libNodes, libDefaults, geompropNames, compareDefaults=False): |
| 732 | '''Compare nodes between spec and library. Returns list of Differences.''' |
no test coverage detected