mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 06:05:58 -04:00
set_interp_data -> set_data for capi.EnergyFunctionFilter
Add doctring to set_data method. Update test_capi.py with this change
This commit is contained in:
parent
9d952c3c58
commit
8d920b792a
3 changed files with 15 additions and 6 deletions
|
|
@ -221,9 +221,18 @@ class EnergyFunctionFilter(Filter):
|
|||
raise AttributeError("Need both energy and y or neither")
|
||||
super().__init__(uid, new, index)
|
||||
if energy is not None:
|
||||
self.set_interp_data(energy, y)
|
||||
self.set_data(energy, y)
|
||||
|
||||
def set_interp_data(self, energy, y):
|
||||
def set_data(self, energy, y):
|
||||
"""Set the interpolation information for the filter
|
||||
|
||||
Parameters
|
||||
----------
|
||||
energy : numpy.ndarray
|
||||
Independent variable for the interpolation
|
||||
y : numpy.ndarray
|
||||
Dependent variable for the interpolation
|
||||
"""
|
||||
energy_array = np.asarray(energy)
|
||||
y_array = np.asarray(y)
|
||||
energy_p = energy_array.ctypes.data_as(POINTER(c_double))
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ EnergyFunctionFilter::text_label(int bin) const
|
|||
// C-API functions
|
||||
//==============================================================================
|
||||
|
||||
extern"C" int
|
||||
extern "C" int
|
||||
openmc_energyfunc_filter_set_data(int32_t index, size_t n, const double* energy,
|
||||
const double* y)
|
||||
{
|
||||
|
|
@ -116,7 +116,7 @@ openmc_energyfunc_filter_set_data(int32_t index, size_t n, const double* energy,
|
|||
return 0;
|
||||
}
|
||||
|
||||
extern"C" int
|
||||
extern "C" int
|
||||
openmc_energyfunc_filter_get_energy(int32_t index, size_t *n, const double** energy)
|
||||
{
|
||||
// ensure this is a valid index to allocated filter
|
||||
|
|
@ -137,7 +137,7 @@ openmc_energyfunc_filter_get_energy(int32_t index, size_t *n, const double** ene
|
|||
return 0;
|
||||
}
|
||||
|
||||
extern"C" int
|
||||
extern "C" int
|
||||
openmc_energyfunc_filter_get_y(int32_t index, size_t *n, const double** y)
|
||||
{
|
||||
// ensure this is a valid index to allocated filter
|
||||
|
|
|
|||
|
|
@ -234,7 +234,7 @@ def test_tally(capi_init):
|
|||
assert isinstance(t3_f, openmc.capi.EnergyFunctionFilter)
|
||||
assert len(t3_f.energy) == 2
|
||||
assert len(t3_f.y) == 2
|
||||
t3_f.set_interp_data([0.0, 1.0, 2.0], [0.0, 1.0, 4.0])
|
||||
t3_f.set_data([0.0, 1.0, 2.0], [0.0, 1.0, 4.0])
|
||||
assert len(t3_f.energy) == 3
|
||||
assert len(t3_f.y) == 3
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue