From 3b00ed3864d2fabff601f31d67994f4828c0af28 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Thu, 8 Sep 2022 22:37:57 -0500 Subject: [PATCH] Adding checks for data size based on interpolation type --- openmc/filter.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/openmc/filter.py b/openmc/filter.py index c1ce573c9a..7a85e2d451 100644 --- a/openmc/filter.py +++ b/openmc/filter.py @@ -2058,6 +2058,13 @@ class EnergyFunctionFilter(Filter): def interpolation(self, val): cv.check_type('interpolation', val, str) cv.check_value('interpolation', val, self.INTERPOLATION_SCHEMES.values()) + + if val == 'quadratic' and len(self.energy) < 3: + raise ValueError('Quadratic interpolation requires 3 or more values.') + + if val == 'cubic' and len(self.energy) < 4: + raise ValueError('Cubic interpolation requires 3 or more values.') + self._interpolation = val def to_xml_element(self):