serpentTools.BranchingReader

class serpentTools.BranchingReader(filePath)

Parser responsible for reading and working with automated branching files.

Parameters

filePath (str) – path to the depletion file

branches

Dictionary of branch names and their corresponding BranchContainer objects

Type

dict

__contains__(key)

Check if a branch is stored on the reader

Parameters

key (str or iterable of str) – Name of the branch as defined in the Serpent input file

Returns

Flag indicating the presence of key

Return type

bool

__getitem__(key)

Return a specific branch from branches

Parameters

key (str or iterable of str) – Branch name as defined in Serpent input

Returns

Branch corresponding to key

Return type

serpentTools.objects.BranchContainer

__iter__()

Iterate over all branch names

__len__()

Number of branches stored on the reader

compare(other, lower=0, upper=10, sigma=2, verbosity=None)

Compare the results of this reader to another.

For values without uncertainties, the upper and lower arguments control what passes and what messages get raised. If a quantity in other is less than lower percent different that the same quantity on this object, consider this allowable and make no messages. Quantities that are greater than upper percent different will have a error messages printed and the comparison will return False, but continue. Quantities with difference between these ranges will have warning messages printed.

Parameters
  • other – Other reader instance against which to compare. Must be a similar class as this one.

  • lower (float or int) – Lower limit for relative tolerances in percent Differences below this will be considered allowable

  • upper (float or int) – Upper limit for relative tolerances in percent. Differences above this will be considered failure and errors messages will be raised

  • sigma (int) – Size of confidence interval to apply to quantities with uncertainties. Quantities that do not have overlapping confidence intervals will fail

  • verbosity (None or str) – If given, update the verbosity just for this comparison.

Returns

True if the objects are in agreement with each other according to the parameters specified

Return type

bool

Raises
  • TypeError – If other is not of the same class as this class nor a subclass of this class

  • ValueError – If upper > lower, If sigma, lower, or upper are negative

get(key, default=None)

Return a branch that may or may not exist in branches

Parameters
  • key (str or iterable of str) – Branch name as defined in Serpent input

  • default (object, optional) – Item to return if key is not found

Returns

BranchContainer if key is found. default if not

Return type

object

property hasUncs

boolean if uncertainties are present in the file

items()

Iterate over key, branch pairs from branches

iterBranches()

Iterate over branches yielding paired branch IDs and containers

Deprecated since version 0.9.3: Use items() instead

read()

The main method for reading that not only parses data, but also runs pre and post checks.