diff --git a/openmc/capi/filter.py b/openmc/capi/filter.py index f1f0cdc46d..92818a2aa1 100644 --- a/openmc/capi/filter.py +++ b/openmc/capi/filter.py @@ -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)) diff --git a/src/tallies/filter_energyfunc.cpp b/src/tallies/filter_energyfunc.cpp index cf74d9836c..3e3fbd909c 100644 --- a/src/tallies/filter_energyfunc.cpp +++ b/src/tallies/filter_energyfunc.cpp @@ -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 diff --git a/tests/unit_tests/test_capi.py b/tests/unit_tests/test_capi.py index 57978838f7..ed0bfd441d 100644 --- a/tests/unit_tests/test_capi.py +++ b/tests/unit_tests/test_capi.py @@ -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