Skip to content

Commit

Permalink
DEV Respect user ordering of sensitivity plot perturbations
Browse files Browse the repository at this point in the history
By converting to a set, the ordering of the perturbations,
like zai=["total", 922380] was not guarunteed to be consistent.
  • Loading branch information
drewejohnson committed Mar 22, 2021
1 parent d2a4b46 commit da0ef0a
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions serpentTools/parsers/sensitivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,18 +497,22 @@ def _gather_matlab(self, reconvert):
out[eneSensFmt.format(key)] = self.energyIntegratedSens[key]
return out

def _getCleanedPertOpt(self, key, value):
"""Return a set of all or some of the requested perturbations."""
assert hasattr(self, key), key
opts = getattr(self, key).keys()
def _getCleanedPertOpt(self, attrName, value):
"""Return a list of all or some of the requested perturbations."""
opts = getattr(self, attrName, None)
assert isinstance(opts, OrderedDict)
if value is None:
return list(opts)
requested = set([value, ]) if isinstance(value, str) else set(value)
missing = {str(xx) for xx in requested.difference(set(opts))}
if missing:
raise KeyError("Could not find the following perturbations: "
"{}".format(', '.join(missing)))
return requested
elif isinstance(value, str):
value = [value]
available = set(opts)
if available.issuperset(value):
return value
missing = available.intersection(value).symmetric_difference(value)
raise KeyError(
"Could not find the following {} perturbations: "
"{}".format(attrName, missing)
)


def reshapePermuteSensMat(vec, newShape):
Expand Down

0 comments on commit da0ef0a

Please sign in to comment.