From a761efe28e404000b6f344a7884c755f5943b0d1 Mon Sep 17 00:00:00 2001 From: Jonathan Rampersad Date: Tue, 17 Jun 2025 13:45:51 -0400 Subject: [PATCH] fix: Renamed differential function to derivitive --- src/polysolve/__init__.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/polysolve/__init__.py b/src/polysolve/__init__.py index 5ef267d..ef9c9b1 100644 --- a/src/polysolve/__init__.py +++ b/src/polysolve/__init__.py @@ -129,15 +129,36 @@ class Function: Returns: Function: A new Function object representing the derivative. """ + warnings.warn( + "The 'differential' function has been renamed. Please use 'derivitive' instead.", + DeprecationWarning, + stacklevel=2 + ) + self._check_initialized() if self._largest_exponent == 0: raise ValueError("Cannot differentiate a constant (Function of degree 0).") + return self.derivitive() + + + def derivitive(self) -> 'Function': + """ + Calculates the derivative of the function. + + Returns: + Function: A new Function object representing the derivative. + """ + self._check_initialized() + if self._largest_exponent == 0: + raise ValueError("Cannot differentiate a constant (Function of degree 0).") + derivative_coefficients = np.polyder(self.coefficients) diff_func = Function(self._largest_exponent - 1) diff_func.set_coeffs(derivative_coefficients.tolist()) return diff_func + def get_real_roots(self, options: GA_Options = GA_Options(), use_cuda: bool = False) -> np.ndarray: """