diff --git a/drudge/drs.py b/drudge/drs.py index d9c465b..eb976f3 100644 --- a/drudge/drs.py +++ b/drudge/drs.py @@ -347,13 +347,13 @@ def __missing__(self, key: str): if key.startswith('__') and key.endswith('__'): raise KeyError(key) - for entry, excl in self._path: - if hasattr(entry, key) and key not in excl: - resolv = getattr(entry, key) + for entry, excl in self._path: #For every module/variable in the environment + if hasattr(entry, key) and key not in excl: # check if our key is defined in it + resolv = getattr(entry, key) # if found, pull it from the environment break else: continue - else: + else: # if we didn't find earlier and break, default to defining it instead resolv = DrsSymbol(self._drudge, key) return resolv diff --git a/tests/nuclear_test.py b/tests/nuclear_test.py index fd9610f..6e5ccc2 100644 --- a/tests/nuclear_test.py +++ b/tests/nuclear_test.py @@ -209,7 +209,7 @@ def test_wigner3j_sum_to_wigner6j(nuclear: NuclearBogoliubovDrudge): ((-1) ** (j3 - m3) / (2 * j3 + 1)) * KroneckerDelta(j3, jprm3) * KroneckerDelta(m3, mprm3) * Wigner6j(j1, j2, j3, j4, j5, j6) - ).expand().simplify() + ).expand().simplify(doit=False) # For performance reason, just test a random arrangement of the summations. random.shuffle(sums)