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

Commit e064ff3

Browse files
author
Frédéric Chapoton
committed
trac #10074 review commit
1 parent 16323a3 commit e064ff3

File tree

1 file changed

+32
-21
lines changed

1 file changed

+32
-21
lines changed

src/sage/functions/hyperbolic.py

+32-21
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import math
1111

12+
1213
class HyperbolicFunction(BuiltinFunction):
1314
r"""
1415
Abstract base class for the functions defined in this file.
@@ -37,8 +38,8 @@ def __init__(self, name, latex_name=None, conversions=None,
3738
3839
sage: from sage.functions.hyperbolic import HyperbolicFunction
3940
sage: class Barh(HyperbolicFunction):
40-
... def __init__(self):
41-
... HyperbolicFunction.__init__(self, 'barh')
41+
....: def __init__(self):
42+
....: HyperbolicFunction.__init__(self, 'barh')
4243
sage: barh = Barh()
4344
sage: barh(x)
4445
barh(x)
@@ -53,8 +54,8 @@ def _evalf_(self, x, parent=None, algorithm=None):
5354
5455
sage: from sage.functions.hyperbolic import HyperbolicFunction
5556
sage: class Fooh(HyperbolicFunction):
56-
... def __init__(self):
57-
... HyperbolicFunction.__init__(self, 'fooh',evalf_float=lambda x: 2*x)
57+
....: def __init__(self):
58+
....: HyperbolicFunction.__init__(self, 'fooh',evalf_float=lambda x: 2*x)
5859
sage: fooh = Fooh()
5960
sage: fooh(float(5))
6061
10.0
@@ -71,6 +72,7 @@ def _evalf_(self, x, parent=None, algorithm=None):
7172
return self._evalf_float(x)
7273
return getattr(x, self.name())()
7374

75+
7476
class Function_sinh(GinacFunction):
7577
def __init__(self):
7678
r"""
@@ -106,6 +108,7 @@ def __init__(self):
106108

107109
sinh = Function_sinh()
108110

111+
109112
class Function_cosh(GinacFunction):
110113
def __init__(self):
111114
r"""
@@ -191,6 +194,7 @@ def __init__(self):
191194

192195
tanh = Function_tanh()
193196

197+
194198
class Function_coth(HyperbolicFunction):
195199
def __init__(self):
196200
r"""
@@ -213,10 +217,10 @@ def __init__(self):
213217
HyperbolicFunction.__init__(self, "coth", latex_name=r"\coth",
214218
evalf_float=lambda x: 1/math.tanh(x))
215219

216-
def _eval_ (self, x):
220+
def _eval_(self, x):
217221
"""
218222
EXAMPLES::
219-
223+
220224
sage: coth(0)
221225
+Infinity
222226
sage: coth(pi*I)
@@ -233,9 +237,9 @@ def _eval_ (self, x):
233237
if x.is_zero():
234238
return Infinity
235239
if isinstance(x, Expression):
236-
x = 2*x/pi/I
237-
if x.is_integer():
238-
if ZZ(x)%2 == 1:
240+
y = 2 * x / pi / I
241+
if y.is_integer():
242+
if ZZ(y) % 2 == 1:
239243
return 0
240244
else:
241245
return Infinity
@@ -265,6 +269,7 @@ def _derivative_(self, *args, **kwds):
265269

266270
coth = Function_coth()
267271

272+
268273
class Function_sech(HyperbolicFunction):
269274
def __init__(self):
270275
r"""
@@ -287,10 +292,10 @@ def __init__(self):
287292
HyperbolicFunction.__init__(self, "sech", latex_name=r"{\rm sech}",
288293
evalf_float=lambda x: 1/math.cosh(x))
289294

290-
def _eval_ (self, x):
295+
def _eval_(self, x):
291296
"""
292297
EXAMPLES::
293-
298+
294299
sage: sech(0)
295300
1
296301
sage: sech(pi*I)
@@ -307,12 +312,12 @@ def _eval_ (self, x):
307312
if x.is_zero():
308313
return 1
309314
if isinstance(x, Expression):
310-
x = 2*x/pi/I
311-
if x.is_integer():
312-
if ZZ(x)%2 == 1:
315+
y = 2 * x / pi / I
316+
if y.is_integer():
317+
if ZZ(y) % 2 == 1:
313318
return Infinity
314319
else:
315-
return ZZ(-1)**ZZ(x/2)
320+
return ZZ(-1) ** ZZ(y / 2)
316321

317322
def _eval_numpy_(self, x):
318323
"""
@@ -362,10 +367,10 @@ def __init__(self):
362367
HyperbolicFunction.__init__(self, "csch", latex_name=r"{\rm csch}",
363368
evalf_float=lambda x: 1/math.sinh(x))
364369

365-
def _eval_ (self, x):
370+
def _eval_(self, x):
366371
"""
367372
EXAMPLES::
368-
373+
369374
sage: csch(0)
370375
+Infinity
371376
sage: csch(pi*I)
@@ -380,10 +385,10 @@ def _eval_ (self, x):
380385
if x.is_zero():
381386
return Infinity
382387
if isinstance(x, Expression):
383-
x = 2*x/pi/I
384-
if x.is_integer():
385-
if ZZ(x)%2 == 1:
386-
return ZZ(-1)**ZZ((x+1)/2)*I
388+
y = 2 * x / pi / I
389+
if y.is_integer():
390+
if ZZ(y) % 2 == 1:
391+
return ZZ(-1) ** ZZ((y + 1) / 2) * I
387392
else:
388393
return Infinity
389394

@@ -417,6 +422,7 @@ def _derivative_(self, *args, **kwds):
417422
# Inverse hyperbolic functions #
418423
################################
419424

425+
420426
class Function_arcsinh(GinacFunction):
421427
def __init__(self):
422428
r"""
@@ -474,6 +480,7 @@ def __init__(self):
474480

475481
arcsinh = asinh = Function_arcsinh()
476482

483+
477484
class Function_arccosh(GinacFunction):
478485
def __init__(self):
479486
r"""
@@ -553,6 +560,7 @@ def __init__(self):
553560

554561
arccosh = acosh = Function_arccosh()
555562

563+
556564
class Function_arctanh(GinacFunction):
557565
def __init__(self):
558566
r"""
@@ -608,6 +616,7 @@ def __init__(self):
608616

609617
arctanh = atanh = Function_arctanh()
610618

619+
611620
class Function_arccoth(HyperbolicFunction):
612621
def __init__(self):
613622
r"""
@@ -668,6 +677,7 @@ def _derivative_(self, *args, **kwds):
668677

669678
arccoth = acoth = Function_arccoth()
670679

680+
671681
class Function_arcsech(HyperbolicFunction):
672682
def __init__(self):
673683
r"""
@@ -718,6 +728,7 @@ def _derivative_(self, *args, **kwds):
718728

719729
arcsech = asech = Function_arcsech()
720730

731+
721732
class Function_arccsch(HyperbolicFunction):
722733
def __init__(self):
723734
r"""

0 commit comments

Comments
 (0)