resolved @paulromano comments

This commit is contained in:
Adam Nelson 2016-11-08 18:45:17 -05:00
parent fb512fb1ef
commit cdae8f70f7
2 changed files with 23 additions and 8 deletions

View file

@ -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
----------

View file

@ -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()