Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit cc22a9b

Browse files
committed
16587: roll back previous commit, less the small fixes
1 parent 44ca3ad commit cc22a9b

File tree

1 file changed

+20
-24
lines changed

1 file changed

+20
-24
lines changed

src/sage/functions/generalized.py

+20-24
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,7 @@
5454
from sage.symbolic.function import BuiltinFunction
5555
from sage.rings.all import ComplexIntervalField, ZZ
5656

57-
class GeneralizedFunction(BuiltinFunction):
58-
def _evalf_(self, *args, **kwds):
59-
return self.gen_eval(*args)
60-
61-
class FunctionDiracDelta(GeneralizedFunction):
57+
class FunctionDiracDelta(BuiltinFunction):
6258
r"""
6359
The Dirac delta (generalized) function, `\delta(x)` (``dirac_delta(x)``).
6460
@@ -145,9 +141,6 @@ def _eval_(self, x):
145141
sage: dirac_delta(x).subs(x=1)
146142
0
147143
"""
148-
return self.gen_eval(x)
149-
150-
def gen_eval(self, x):
151144
try:
152145
approx_x = ComplexIntervalField()(x)
153146
if bool(approx_x.imag() == 0): # x is real
@@ -157,10 +150,13 @@ def gen_eval(self, x):
157150
return ZZ(0)
158151
except TypeError: # x is symbolic
159152
pass
153+
154+
def _evalf_(self, *args, **kwds):
155+
return self._eval_(*args, **kwds)
160156

161157
dirac_delta = FunctionDiracDelta()
162158

163-
class FunctionHeaviside(GeneralizedFunction):
159+
class FunctionHeaviside(BuiltinFunction):
164160
r"""
165161
The Heaviside step function, `H(x)` (``heaviside(x)``).
166162
@@ -250,9 +246,6 @@ def _eval_(self, x):
250246
sage: t.subs(x=1)
251247
2
252248
"""
253-
return self.gen_eval(x)
254-
255-
def gen_eval(self, x):
256249
try:
257250
approx_x = ComplexIntervalField()(x)
258251
if bool(approx_x.imag() == 0): # x is real
@@ -266,6 +259,9 @@ def gen_eval(self, x):
266259
except TypeError: # x is symbolic
267260
pass
268261

262+
def _evalf_(self, *args, **kwds):
263+
return self._eval_(*args, **kwds)
264+
269265
def _derivative_(self, x, diff_param=None):
270266
"""
271267
Derivative of Heaviside step function
@@ -279,7 +275,7 @@ def _derivative_(self, x, diff_param=None):
279275

280276
heaviside = FunctionHeaviside()
281277

282-
class FunctionUnitStep(GeneralizedFunction):
278+
class FunctionUnitStep(BuiltinFunction):
283279
r"""
284280
The unit step function, `\mathrm{u}(x)` (``unit_step(x)``).
285281
@@ -361,9 +357,6 @@ def _eval_(self, x):
361357
sage: unit_step(x).subs(x=0)
362358
1
363359
"""
364-
return self.gen_eval(x)
365-
366-
def gen_eval(self, x):
367360
try:
368361
approx_x = ComplexIntervalField()(x)
369362
if bool(approx_x.imag() == 0): # x is real
@@ -377,6 +370,9 @@ def gen_eval(self, x):
377370
except TypeError: # x is symbolic
378371
pass
379372

373+
def _evalf_(self, *args, **kwds):
374+
return self._eval_(*args, **kwds)
375+
380376
def _derivative_(self, x, diff_param=None):
381377
"""
382378
Derivative of unit step function
@@ -390,7 +386,7 @@ def _derivative_(self, x, diff_param=None):
390386

391387
unit_step = FunctionUnitStep()
392388

393-
class FunctionSignum(GeneralizedFunction):
389+
class FunctionSignum(BuiltinFunction):
394390
r"""
395391
The signum or sgn function `\mathrm{sgn}(x)` (``sgn(x)``).
396392
@@ -499,9 +495,6 @@ def _eval_(self, x):
499495
return x.sign()
500496
if hasattr(x,'sgn'): # or a sgn method
501497
return x.sgn()
502-
return self.gen_eval(x)
503-
504-
def gen_eval(self, x):
505498
try:
506499
approx_x = ComplexIntervalField()(x)
507500
if bool(approx_x.imag() == 0): # x is real
@@ -515,6 +508,9 @@ def gen_eval(self, x):
515508
except TypeError: # x is symbolic
516509
pass
517510

511+
def _evalf_(self, *args, **kwds):
512+
return self._eval_(*args, **kwds)
513+
518514
def _derivative_(self, x, diff_param=None):
519515
"""
520516
Derivative of sgn function
@@ -530,7 +526,7 @@ def _derivative_(self, x, diff_param=None):
530526
sgn = FunctionSignum()
531527
sign = sgn
532528

533-
class FunctionKroneckerDelta(GeneralizedFunction):
529+
class FunctionKroneckerDelta(BuiltinFunction):
534530
r"""
535531
The Kronecker delta function `\delta_{m,n}` (``kronecker_delta(m, n)``).
536532
@@ -610,9 +606,6 @@ def _eval_(self, m, n):
610606
if bool(repr(m) > repr(n)):
611607
return kronecker_delta(n, m)
612608

613-
return self.gen_eval(m, n)
614-
615-
def gen_eval(self, m, n):
616609
x = m - n
617610
try:
618611
approx_x = ComplexIntervalField()(x)
@@ -626,6 +619,9 @@ def gen_eval(self, m, n):
626619
except TypeError: # x is symbolic
627620
pass
628621

622+
def _evalf_(self, *args, **kwds):
623+
return self._eval_(*args, **kwds)
624+
629625
def _derivative_(self, *args, **kwds):
630626
"""
631627
Derivative of Kronecker delta

0 commit comments

Comments
 (0)