def findIndex_TensorFactorList(tfl): freeIndex = set() dummyIndex = set() tooMany = set() other = set() for factor in tfl: for ind in factor['indexList']: if not tensor.isAllowedDummyIndex(ind): other.add(ind) elif ind in dummyIndex: tooMany.add(ind) elif ind in freeIndex: freeIndex.remove(ind) dummyIndex.add(ind) else: freeIndex.add(ind) return {'free':freeIndex, 'dummy':dummyIndex, 'tooMany':tooMany, 'other':other}