From cbd577a421ee03588e9961f771957f47175fdf88 Mon Sep 17 00:00:00 2001 From: Kirill Smelkov Date: Sun, 27 Jan 2008 17:32:06 +0300 Subject: [PATCH] functions: there is no need for taylor_term to be classmethod -- it's staticmethod! Yes, say why cos.taylor_term needs its class or instance? It just simply computes cos taylor terms with direct formula. And also, since taylor_term is cached, less cache space is used (actually I spot this when working on caching) --- sympy/functions/elementary/exponential.py | 8 ++++---- sympy/functions/elementary/hyperbolic.py | 32 ++++++++++++++--------------- sympy/functions/elementary/trigonometric.py | 27 ++++++++++++++---------- sympy/functions/special/error_functions.py | 4 ++-- 4 files changed, 38 insertions(+), 33 deletions(-) diff --git a/sympy/functions/elementary/exponential.py b/sympy/functions/elementary/exponential.py index 6822cf6..11b08d5 100644 --- a/sympy/functions/elementary/exponential.py +++ b/sympy/functions/elementary/exponential.py @@ -87,9 +87,9 @@ class exp(Function): if excluded: return Basic.Mul(*(excluded+[cls(Basic.Add(*included))])) - @classmethod + @staticmethod @cache_it_immutable - def taylor_term(self, n, x, *previous_terms): + def taylor_term(n, x, *previous_terms): if n<0: return S.Zero if n==0: return S.One x = Basic.sympify(x) @@ -317,9 +317,9 @@ class log(Function): def _calc_apply_unbounded(self, x): return x.is_unbounded - @classmethod + @staticmethod @cache_it_immutable - def taylor_term(self, n, x, *previous_terms): # of log(1+x) + def taylor_term(n, x, *previous_terms): # of log(1+x) if n<0: return S.Zero x = Basic.sympify(x) if n==0: return x diff --git a/sympy/functions/elementary/hyperbolic.py b/sympy/functions/elementary/hyperbolic.py index d519620..9022447 100644 --- a/sympy/functions/elementary/hyperbolic.py +++ b/sympy/functions/elementary/hyperbolic.py @@ -50,9 +50,9 @@ class sinh(Function): if coeff.is_negative: return -cls(-arg) - @classmethod + @staticmethod @cache_it_immutable - def taylor_term(self, n, x, *previous_terms): + def taylor_term(n, x, *previous_terms): if n < 0 or n % 2 == 0: return S.Zero else: @@ -146,9 +146,9 @@ class cosh(Function): if coeff.is_negative: return cls(-arg) - @classmethod + @staticmethod @cache_it_immutable - def taylor_term(self, n, x, *previous_terms): + def taylor_term(n, x, *previous_terms): if n < 0 or n % 2 == 1: return S.Zero else: @@ -242,9 +242,9 @@ class tanh(Function): if coeff.is_negative: return -cls(-arg) - @classmethod + @staticmethod @cache_it_immutable - def taylor_term(self, n, x, *previous_terms): + def taylor_term(n, x, *previous_terms): if n < 0 or n % 2 == 0: return S.Zero else: @@ -340,9 +340,9 @@ class coth(Function): if coeff.is_negative: return -cls(-arg) - @classmethod + @staticmethod @cache_it_immutable - def taylor_term(self, n, x, *previous_terms): + def taylor_term(n, x, *previous_terms): if n == 0: return 1 / Basic.sympify(x) elif n < 0 or n % 2 == 0: @@ -436,9 +436,9 @@ class asinh(Function): if coeff.is_negative: return -cls(-arg) - @classmethod + @staticmethod @cache_it_immutable - def taylor_term(self, n, x, *previous_terms): + def taylor_term(n, x, *previous_terms): if n < 0 or n % 2 == 0: return S.Zero else: @@ -509,9 +509,9 @@ class acosh(Function): if arg in cst_table: return cst_table[arg]*S.ImaginaryUnit - @classmethod + @staticmethod @cache_it_immutable - def taylor_term(self, n, x, *previous_terms): + def taylor_term(n, x, *previous_terms): if n == 0: return S.Pi*S.ImaginaryUnit / 2 elif n < 0 or n % 2 == 0: @@ -578,9 +578,9 @@ class atanh(Function): if coeff.is_negative: return -cls(-arg) - @classmethod + @staticmethod @cache_it_immutable - def taylor_term(self, n, x, *previous_terms): + def taylor_term(n, x, *previous_terms): if n < 0 or n % 2 == 0: return S.Zero else: @@ -639,9 +639,9 @@ class acoth(Function): if coeff.is_negative: return -cls(-arg) - @classmethod + @staticmethod @cache_it_immutable - def taylor_term(self, n, x, *previous_terms): + def taylor_term(n, x, *previous_terms): if n == 0: return S.Pi*S.ImaginaryUnit / 2 elif n < 0 or n % 2 == 0: diff --git a/sympy/functions/elementary/trigonometric.py b/sympy/functions/elementary/trigonometric.py index f85451d..e7bd45f 100644 --- a/sympy/functions/elementary/trigonometric.py +++ b/sympy/functions/elementary/trigonometric.py @@ -71,9 +71,9 @@ class sin(Function): return -cls(-arg) - @classmethod + @staticmethod @cache_it_immutable - def taylor_term(self, n, x, *previous_terms): + def taylor_term(n, x, *previous_terms): if n < 0 or n % 2 == 0: return S.Zero else: @@ -206,9 +206,9 @@ class cos(Function): return cls(-arg) - @classmethod + @staticmethod @cache_it_immutable - def taylor_term(self, n, x, *previous_terms): + def taylor_term(n, x, *previous_terms): if n < 0 or n % 2 == 1: return S.Zero else: @@ -343,9 +343,9 @@ class tan(Function): return -cls(-arg) - @classmethod + @staticmethod @cache_it_immutable - def taylor_term(self, n, x, *previous_terms): + def taylor_term(n, x, *previous_terms): if n < 0 or n % 2 == 0: return S.Zero else: @@ -466,8 +466,9 @@ class cot(Function): return -cls(-arg) + @staticmethod @cache_it_immutable - def taylor_term(self, n, x, *previous_terms): + def taylor_term(n, x, *previous_terms): if n == 0: return 1 / Basic.sympify(x) elif n < 0 or n % 2 == 0: @@ -580,8 +581,9 @@ class asin(Function): return -cls(-arg) + @staticmethod @cache_it_immutable - def taylor_term(self, n, x, *previous_terms): + def taylor_term(n, x, *previous_terms): if n < 0 or n % 2 == 0: return S.Zero else: @@ -656,8 +658,9 @@ class acos(Function): return cst_table[arg] + @staticmethod @cache_it_immutable - def taylor_term(self, n, x, *previous_terms): + def taylor_term(n, x, *previous_terms): if n == 0: return S.Pi / 2 elif n < 0 or n % 2 == 0: @@ -744,8 +747,9 @@ class atan(Function): return -cls(-arg) + @staticmethod @cache_it_immutable - def taylor_term(self, n, x, *previous_terms): + def taylor_term(n, x, *previous_terms): if n < 0 or n % 2 == 0: return S.Zero else: @@ -816,8 +820,9 @@ class acot(Function): return -cls(-arg) + @staticmethod @cache_it_immutable - def taylor_term(self, n, x, *previous_terms): + def taylor_term(n, x, *previous_terms): if n == 0: return S.Pi / 2 # FIX THIS elif n < 0 or n % 2 == 0: diff --git a/sympy/functions/special/error_functions.py b/sympy/functions/special/error_functions.py index 72eb0be..7c4d231 100644 --- a/sympy/functions/special/error_functions.py +++ b/sympy/functions/special/error_functions.py @@ -43,9 +43,9 @@ class erf(Function): if coeff.is_negative: return -cls(-arg) - @classmethod + @staticmethod @cache_it_immutable - def taylor_term(self, n, x, *previous_terms): + def taylor_term(n, x, *previous_terms): if n < 0 or n % 2 == 0: return S.Zero else: -- 2.11.4.GIT