diff --git a/openmc/data/function.py b/openmc/data/function.py index e87f0a9c42..4a1f9d7a38 100644 --- a/openmc/data/function.py +++ b/openmc/data/function.py @@ -428,8 +428,8 @@ class Combination(EqualityMixin): def __call__(self, x): ans = np.zeros_like(x) - for i, operation in enumerate(self.operations): - ans = operation(ans, self.functions[i](x)) + for op, func in zip(self.operations, self.functions): + ans = op(ans, func(x)) return ans @property @@ -488,7 +488,7 @@ class Sum(EqualityMixin): self._functions = functions -class Piecewise(EqualityMixin): +class Regions1D(EqualityMixin): """Piecewise composition of multiple functions. This class allows you to create a callable object which is composed @@ -499,9 +499,9 @@ class Piecewise(EqualityMixin): functions : Iterable of Callable Functions which are to be combined in a piecewise fashion breakpoints : Iterable of float - The breakpoints between each function. The functions - in the functions attribute must be provided in order of - increasing intervals. + The values of the dependent variable that define the domain of + each function. The *i*th and *(i+1)*th values are the limits of the + domain of the *i*th function. Values must be monotonically increasing. Attributes ---------- diff --git a/openmc/data/library.py b/openmc/data/library.py index 3e01c24643..0363de4fc5 100644 --- a/openmc/data/library.py +++ b/openmc/data/library.py @@ -22,9 +22,19 @@ class DataLibrary(EqualityMixin): def __init__(self): self.libraries = [] - def __getitem__(self, material): + def get_by_materials(self, value): + """Access a library entry by passing a value of the 'materials' + attribute of the library entry. + + Returns + ------- + library : dict + Dictionary summarizing cross section data from a single file; + the dictionary has keys 'path', 'type', and 'materials'. + + """ for library in self.libraries: - if material in library['materials']: + if value in library['materials']: return library return None @@ -94,6 +104,11 @@ class DataLibrary(EqualityMixin): path : str Path to XML file to read. + Returns + ------- + data : openmc.data.DataLibrary + openmc.data.DataLibrary object initialized from the provided XML + """ data = cls()