Skip to content

Commit b12d8d3

Browse files
author
Release Manager
committed
gh-35924: some pep8 fixes in functions/ <!-- ^^^^^ Please provide a concise, informative and self-explanatory title. Don't put issue numbers in there, do this in the PR body below. For example, instead of "Fixes #1234" use "Introduce new method to calculate 1+1" --> <!-- Describe your changes here in detail --> fixes some pycodestyle warnings in `functions` <!-- Why is this change required? What problem does it solve? --> <!-- If this PR resolves an open issue, please link to it here. For example "Fixes #12345". --> <!-- If your change requires a documentation PR, please link it appropriately. --> ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - #12345: short description why this is a dependency - #34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: #35924 Reported by: Frédéric Chapoton Reviewer(s): David Coudert
2 parents 6098e73 + efcd9d1 commit b12d8d3

File tree

6 files changed

+101
-46
lines changed

6 files changed

+101
-46
lines changed

src/sage/functions/error.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ def _derivative_(self, x, diff_param=None):
297297
"""
298298
return 2*exp(-x**2)/sqrt(pi)
299299

300+
300301
erf = Function_erf()
301302

302303

@@ -375,8 +376,10 @@ def _derivative_(self, x, diff_param=None):
375376
"""
376377
return 2*exp(x**2)/sqrt(pi)
377378

379+
378380
erfi = Function_erfi()
379381

382+
380383
class Function_erfc(BuiltinFunction):
381384
r"""
382385
The complementary error function.
@@ -477,6 +480,7 @@ def _derivative_(self, x, diff_param=None):
477480
"""
478481
return -2*exp(-x**2)/sqrt(pi)
479482

483+
480484
erfc = Function_erfc()
481485

482486

@@ -564,11 +568,14 @@ def _derivative_(self, x, diff_param=None):
564568
"""
565569
return sqrt(pi)*exp(erfinv(x)**2)/2
566570

571+
567572
erfinv = Function_erfinv()
568573

574+
569575
from sage.misc.persist import register_unpickle_override
570576
register_unpickle_override('sage.functions.other', 'Function_erf', Function_erf)
571577

578+
572579
############################
573580
# Fresnel integrals #
574581
############################
@@ -632,11 +639,11 @@ def _eval_(self, x):
632639
return x
633640
if x.is_infinity():
634641
if x.is_positive_infinity():
635-
return Rational((1,2))
642+
return Rational((1, 2))
636643
elif x.imag_part().is_positive_infinity():
637-
return -I*Rational((1,2))
644+
return -I*Rational((1, 2))
638645
elif x.imag_part().is_negative_infinity():
639-
return I*Rational((1,2))
646+
return I*Rational((1, 2))
640647
elif x < 0:
641648
return -fresnel_sin(-x)
642649
elif not x:
@@ -668,8 +675,10 @@ def _derivative_(self, x, diff_param=None):
668675
from sage.functions.trig import sin
669676
return sin(pi*x**2/2)
670677

678+
671679
fresnel_sin = Function_Fresnel_sin()
672680

681+
673682
class Function_Fresnel_cos(BuiltinFunction):
674683
def __init__(self):
675684
r"""
@@ -730,11 +739,11 @@ def _eval_(self, x):
730739
return x
731740
if x.is_infinity():
732741
if x.is_positive_infinity():
733-
return Rational((1,2))
742+
return Rational((1, 2))
734743
elif x.imag_part().is_positive_infinity():
735-
return I*Rational((1,2))
744+
return I*Rational((1, 2))
736745
elif x.imag_part().is_negative_infinity():
737-
return -I*Rational((1,2))
746+
return -I*Rational((1, 2))
738747
elif x < 0:
739748
return -fresnel_cos(-x)
740749
elif not x:
@@ -766,4 +775,5 @@ def _derivative_(self, x, diff_param=None):
766775
from sage.functions.trig import cos
767776
return cos(pi*x**2/2)
768777

778+
769779
fresnel_cos = Function_Fresnel_cos()

src/sage/functions/exp_integral.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@
3636
3737
"""
3838

39-
#*****************************************************************************
39+
# ****************************************************************************
4040
# Copyright (C) 2011 Benjamin Jones <[email protected]>
4141
#
4242
# This program is free software: you can redistribute it and/or modify
4343
# it under the terms of the GNU General Public License as published by
4444
# the Free Software Foundation, either version 2 of the License, or
4545
# (at your option) any later version.
46-
# http://www.gnu.org/licenses/
47-
#*****************************************************************************
46+
# https://www.gnu.org/licenses/
47+
# ****************************************************************************
4848

4949

5050
from sage.symbolic.function import BuiltinFunction
@@ -182,7 +182,7 @@ def _eval_(self, n, z):
182182
# special case: z == 0 and n > 1
183183
if isinstance(z, Expression):
184184
if z.is_trivial_zero():
185-
z_zero = True # for later
185+
z_zero = True # for later
186186
if n > 1:
187187
return 1/(n-1)
188188
else:
@@ -205,7 +205,7 @@ def _eval_(self, n, z):
205205
else:
206206
return exp(-z)/z
207207

208-
return None # leaves the expression unevaluated
208+
return None # leaves the expression unevaluated
209209

210210
def _evalf_(self, n, z, parent=None, algorithm=None):
211211
"""
@@ -217,7 +217,6 @@ def _evalf_(self, n, z, parent=None, algorithm=None):
217217
0.000281624451981418 - 0.179324535039359*I
218218
sage: exp_integral_e(1, RealField(100)(1))
219219
0.21938393439552027367716377546
220-
221220
"""
222221
import mpmath
223222
return mpmath_utils.call(mpmath.expint, n, z, parent=parent)
@@ -249,12 +248,11 @@ def _derivative_(self, n, z, diff_param=None):
249248
sage: f = exp_integral_e(2,sqrt(x))
250249
sage: f.diff(x)
251250
-1/2*exp_integral_e(1, sqrt(x))/sqrt(x)
252-
253251
"""
254252
if n in ZZ and n > 0:
255-
return -1*exp_integral_e(n-1,z)
256-
else:
257-
raise NotImplementedError("The derivative of this function is only implemented for n = 1, 2, 3, ...")
253+
return -1*exp_integral_e(n-1, z)
254+
raise NotImplementedError("The derivative of this function is only implemented for n = 1, 2, 3, ...")
255+
258256

259257
exp_integral_e = Function_exp_integral_e()
260258

@@ -367,6 +365,7 @@ def _derivative_(self, z, diff_param=None):
367365
"""
368366
return -exp(-z)/z
369367

368+
370369
exp_integral_e1 = Function_exp_integral_e1()
371370

372371

@@ -501,8 +500,10 @@ def _derivative_(self, z, diff_param=None):
501500
"""
502501
return 1/log(z)
503502

503+
504504
li = log_integral = Function_log_integral()
505505

506+
506507
class Function_log_integral_offset(BuiltinFunction):
507508
r"""
508509
The offset logarithmic integral, or Eulerian logarithmic integral,
@@ -642,7 +643,7 @@ def __init__(self):
642643
latex_name=r'\operatorname{log\_integral\_offset}',
643644
conversions=dict(sympy='Li'))
644645

645-
def _eval_(self,z):
646+
def _eval_(self, z):
646647
"""
647648
EXAMPLES::
648649
@@ -694,8 +695,10 @@ def _derivative_(self, z, diff_param=None):
694695
"""
695696
return 1/log(z)
696697

698+
697699
Li = log_integral_offset = Function_log_integral_offset()
698700

701+
699702
class Function_sin_integral(BuiltinFunction):
700703
r"""
701704
The trigonometric integral `\operatorname{Si}(z)` defined by
@@ -886,6 +889,7 @@ def _derivative_(self, z, diff_param=None):
886889
"""
887890
return sin(z)/z
888891

892+
889893
Si = sin_integral = Function_sin_integral()
890894

891895

@@ -1026,6 +1030,7 @@ def _derivative_(self, z, diff_param=None):
10261030
"""
10271031
return cos(z)/z
10281032

1033+
10291034
Ci = cos_integral = Function_cos_integral()
10301035

10311036

@@ -1178,6 +1183,7 @@ def _derivative_(self, z, diff_param=None):
11781183
"""
11791184
return sinh(z)/z
11801185

1186+
11811187
Shi = sinh_integral = Function_sinh_integral()
11821188

11831189

@@ -1306,6 +1312,7 @@ def _derivative_(self, z, diff_param=None):
13061312
"""
13071313
return cosh(z)/z
13081314

1315+
13091316
Chi = cosh_integral = Function_cosh_integral()
13101317

13111318

@@ -1420,6 +1427,7 @@ def _derivative_(self, x, diff_param=None):
14201427
"""
14211428
return exp(x)/x
14221429

1430+
14231431
Ei = exp_integral_ei = Function_exp_integral()
14241432

14251433

src/sage/functions/jacobi.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,7 @@ def _print_latex_(self, x, m):
515515
latex(x),
516516
latex(m))
517517

518+
518519
jacobi_nd = Jacobi('nd')
519520
jacobi_ns = Jacobi('ns')
520521
jacobi_nc = Jacobi('nc')
@@ -905,6 +906,7 @@ def _print_latex_(self, x, m):
905906
latex(x),
906907
latex(m))
907908

909+
908910
inverse_jacobi_nd = InverseJacobi('nd')
909911
inverse_jacobi_ns = InverseJacobi('ns')
910912
inverse_jacobi_nc = InverseJacobi('nc')
@@ -1050,6 +1052,7 @@ def inverse_jacobi(kind, x, m, **kwargs):
10501052
raise ValueError("kind must be one of 'nd', 'ns', 'nc', 'dn', "
10511053
"'ds', 'dc', 'sn', 'sd', 'sc', 'cn', 'cd', 'cs'.")
10521054

1055+
10531056
class JacobiAmplitude(BuiltinFunction):
10541057
r"""
10551058
The Jacobi amplitude function

0 commit comments

Comments
 (0)