Skip to content

Commit 6407963

Browse files
committed
ENH: implement Function.reset method
1 parent 69ffc01 commit 6407963

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

rocketpy/Function.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,44 @@ def setDiscreteBasedOnModel(self, modelFunction, oneByOne=True):
521521
self.setExtrapolation(modelFunction.__extrapolation__)
522522
return self
523523

524+
def reset(
525+
self,
526+
inputs=None,
527+
outputs=None,
528+
interpolation=None,
529+
extrapolation=None,
530+
):
531+
"""This method resets the Function object to its initial state, with the
532+
possibility of resetting all of its initialization arguments besides the
533+
source.
534+
535+
Parameters
536+
----------
537+
inputs : string, sequence of strings, optional
538+
List of input variable names. If None, the original inputs are kept.
539+
outputs : string, sequence of strings, optional
540+
List of output variable names. If None, the original outputs are kept.
541+
interpolation : string, optional
542+
Interpolation method to be used if source type is ndarray.
543+
For 1-D functions, linear, polynomial, akima and spline is
544+
supported. For N-D functions, only shepard is supported.
545+
If None, the original interpolation method is kept.
546+
extrapolation : string, optional
547+
Extrapolation method to be used if source type is ndarray.
548+
Options are 'natural', which keeps interpolation, 'constant',
549+
which returns the value of the function at the edge of the interval,
550+
and 'zero', which returns zero for all points outside of source
551+
range. If None, the original extrapolation method is kept.
552+
"""
553+
if inputs is not None:
554+
self.setInputs(inputs)
555+
if outputs is not None:
556+
self.setOutputs(outputs)
557+
if interpolation is not None and interpolation != self.__interpolation__:
558+
self.setInterpolation(interpolation)
559+
if extrapolation is not None and extrapolation != self.__extrapolation__:
560+
self.setExtrapolation(extrapolation)
561+
524562
# Define all get methods
525563
def getInputs(self):
526564
"Return tuple of inputs of the function."

0 commit comments

Comments
 (0)