Skip to content

Commit c2d3303

Browse files
pre-commit-ci[bot]jobovy
authored andcommitted
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent a6e3f10 commit c2d3303

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+305
-702
lines changed

galpy/actionAngle/actionAngleSpherical.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -807,9 +807,7 @@ def _calc_anglez(
807807

808808
def _JrSphericalIntegrand(r, E, L, pot):
809809
"""The J_r integrand"""
810-
return numpy.sqrt(
811-
2.0 * (E - _evaluateplanarPotentials(pot, r)) - L**2.0 / r**2.0
812-
)
810+
return numpy.sqrt(2.0 * (E - _evaluateplanarPotentials(pot, r)) - L**2.0 / r**2.0)
813811

814812

815813
def _TrSphericalIntegrandSmall(t, E, L, pot, rperi):

galpy/actionAngle/actionAngleStaeckel.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -1237,10 +1237,7 @@ def calcELStaeckel(R, vR, vT, z, vz, pot, vc=1.0, ro=1.0):
12371237
12381238
"""
12391239
return (
1240-
_evaluatePotentials(pot, R, z)
1241-
+ vR**2.0 / 2.0
1242-
+ vT**2.0 / 2.0
1243-
+ vz**2.0 / 2.0,
1240+
_evaluatePotentials(pot, R, z) + vR**2.0 / 2.0 + vT**2.0 / 2.0 + vz**2.0 / 2.0,
12441241
R * vT,
12451242
)
12461243

@@ -1552,9 +1549,7 @@ def estimateDeltaStaeckel(pot, R, z, no_median=False, delta0=1e-6):
15521549
for ii in range(len(R))
15531550
]
15541551
)
1555-
indx = (delta2 < delta0**2.0) * (
1556-
(delta2 > -(10.0**-10.0)) + pot_includes_scf
1557-
)
1552+
indx = (delta2 < delta0**2.0) * ((delta2 > -(10.0**-10.0)) + pot_includes_scf)
15581553
delta2[indx] = delta0**2.0
15591554
if not no_median:
15601555
delta2 = numpy.median(delta2[True ^ numpy.isnan(delta2)])

galpy/actionAngle/actionAngleTorus.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
from .actionAngleTorus_c import _ext_loaded as ext_loaded
1919

2020
_autofit_errvals = {}
21-
_autofit_errvals[
22-
-1
23-
] = "something wrong with input, usually bad starting values for the parameters"
21+
_autofit_errvals[-1] = (
22+
"something wrong with input, usually bad starting values for the parameters"
23+
)
2424
_autofit_errvals[-2] = "Fit failed the goal by a factor <= 2"
2525
_autofit_errvals[-3] = "Fit failed the goal by more than 2"
2626
_autofit_errvals[-4] = "Fit aborted: serious problems occurred"

galpy/df/constantbetadf.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -384,9 +384,9 @@ def _fEintegrand_raw(r, pot, E, dmp1nudrmp1, alpha):
384384
out = numpy.zeros_like(r) # Avoid JAX item assignment issues
385385
# print("r",r,dmp1nudrmp1(r),(_evaluatePotentials(pot,r,0)-E))
386386
out[:] = dmp1nudrmp1(r) / (_evaluatePotentials(pot, r, 0) - E) ** alpha
387-
out[
388-
True ^ numpy.isfinite(out)
389-
] = 0.0 # assume these are where denom is slightly neg.
387+
out[True ^ numpy.isfinite(out)] = (
388+
0.0 # assume these are where denom is slightly neg.
389+
)
390390
return out
391391

392392

galpy/df/diskdf.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1782,9 +1782,7 @@ def _estimateSigmaT2(self, R, phi=0.0, log=False):
17821782
self._gamma
17831783
)
17841784
else:
1785-
return (
1786-
self.targetSigma2(R, log=log, use_physical=False) / self._gamma**2.0
1787-
)
1785+
return self.targetSigma2(R, log=log, use_physical=False) / self._gamma**2.0
17881786

17891787

17901788
class dehnendf(diskdf):

galpy/df/evolveddiskdf.py

+7-9
Original file line numberDiff line numberDiff line change
@@ -2910,9 +2910,9 @@ def _buildvgrid(
29102910
deriv=deriv,
29112911
use_physical=False,
29122912
)
2913-
out.df[
2914-
ii, jj, numpy.isnan(out.df[ii, jj, :])
2915-
] = 0.0 # BOVY: for now
2913+
out.df[ii, jj, numpy.isnan(out.df[ii, jj, :])] = (
2914+
0.0 # BOVY: for now
2915+
)
29162916
if print_progress:
29172917
sys.stdout.write("\n") # pragma: no cover
29182918
else:
@@ -3278,9 +3278,9 @@ def __init__(
32783278
self.df[ii, jj, :] = edf(
32793279
thiso, numpy.array(t).flatten(), deriv=deriv
32803280
)
3281-
self.df[
3282-
ii, jj, numpy.isnan(self.df[ii, jj, :])
3283-
] = 0.0 # BOVY: for now
3281+
self.df[ii, jj, numpy.isnan(self.df[ii, jj, :])] = (
3282+
0.0 # BOVY: for now
3283+
)
32843284
# Multiply in area, somewhat tricky for edge objects
32853285
if upperdxdy is None or (
32863286
ii != 0
@@ -3401,9 +3401,7 @@ def __call__(self, n, m):
34013401
return numpy.array(out) + self.subgrid(n, m)
34023402
else:
34033403
# We already multiplied in the area
3404-
thislevel = numpy.dot(
3405-
self.vRgrid**n, numpy.dot(self.df, self.vTgrid**m)
3406-
)
3404+
thislevel = numpy.dot(self.vRgrid**n, numpy.dot(self.df, self.vTgrid**m))
34073405
if self.subgrid is None:
34083406
return thislevel
34093407
else:

galpy/df/isotropicPlummerdf.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,7 @@ def __init__(self, pot=None, ro=None, vo=None):
4040
self._Etildemax = pot._amp / pot._b
4141
# /amp^4 instead of /amp^5 to make the DF that of mass density
4242
self._fEnorm = (
43-
24.0
44-
* numpy.sqrt(2.0)
45-
/ 7.0
46-
/ numpy.pi**3.0
47-
* pot._b**2.0
48-
/ pot._amp**4.0
43+
24.0 * numpy.sqrt(2.0) / 7.0 / numpy.pi**3.0 * pot._b**2.0 / pot._amp**4.0
4944
)
5045

5146
def fE(self, E):

galpy/df/osipkovmerrittNFWdf.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ def __init__(self, pot=None, ra=1.4, rmax=1e4, ro=None, vo=None):
5959
self._Qtildemax = pot._amp / pot.a
6060
self._Qtildemin = -pot(self._rmax, 0, use_physical=False) / self._Qtildemax
6161
self._a2overra2 = self._pot.a**2.0 / self._ra2
62-
self._fQnorm = (
63-
self._a2overra2 / (4.0 * numpy.pi) / pot.a**1.5 / pot._amp**0.5
64-
)
62+
self._fQnorm = self._a2overra2 / (4.0 * numpy.pi) / pot.a**1.5 / pot._amp**0.5
6563
# Initialize isotropic version to use as part of fQ
6664
self._idf = isotropicNFWdf(pot=pot, rmax=rmax, ro=ro, vo=vo)
6765

galpy/df/osipkovmerrittdf.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,7 @@ def _p_v_at_r(self, v, r):
160160
)
161161
else:
162162
return (
163-
self.fQ(-_evaluatePotentials(self._pot, r, 0) - 0.5 * v**2.0)
164-
* v**2.0
163+
self.fQ(-_evaluatePotentials(self._pot, r, 0) - 0.5 * v**2.0) * v**2.0
165164
)
166165

167166
def _sample_v(self, r, eta, n=1):

galpy/df/sphericaldf.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -732,10 +732,7 @@ def _p_v_at_r(self, v, r):
732732
* v**2.0
733733
)
734734
else:
735-
return (
736-
self.fE(_evaluatePotentials(self._pot, r, 0) + 0.5 * v**2.0)
737-
* v**2.0
738-
)
735+
return self.fE(_evaluatePotentials(self._pot, r, 0) + 0.5 * v**2.0) * v**2.0
739736

740737

741738
class anisotropicsphericaldf(sphericaldf):

galpy/df/streamdf.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -2650,9 +2650,7 @@ def sigangledAngle(self, dangle, assumeZeroMean=True, smallest=False, simple=Fal
26502650
eigIndx = 1
26512651
if simple:
26522652
dt = self.meantdAngle(dangle, use_physical=False)
2653-
return numpy.sqrt(
2654-
self._sigangle2 + self._sortedSigOEig[eigIndx] * dt**2.0
2655-
)
2653+
return numpy.sqrt(self._sigangle2 + self._sortedSigOEig[eigIndx] * dt**2.0)
26562654
aplow = numpy.amax(
26572655
[
26582656
numpy.sqrt(self._sortedSigOEig[eigIndx]) * self._tdisrupt * 5.0,

galpy/df/streamgapdf.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -382,9 +382,7 @@ def _densMoments_approx_higherorder_gaussxpolyInts(self, ll, ul, maxj):
382382
in the higher-order terms, recursively"""
383383
gaussxpolyInt = numpy.zeros((maxj, len(ul)))
384384
gaussxpolyInt[-1] = (
385-
1.0
386-
/ numpy.sqrt(numpy.pi)
387-
* (numpy.exp(-(ll**2.0)) - numpy.exp(-(ul**2.0)))
385+
1.0 / numpy.sqrt(numpy.pi) * (numpy.exp(-(ll**2.0)) - numpy.exp(-(ul**2.0)))
388386
)
389387
gaussxpolyInt[-2] = 1.0 / numpy.sqrt(numpy.pi) * (
390388
numpy.exp(-(ll**2.0)) * ll - numpy.exp(-(ul**2.0)) * ul

galpy/orbit/Orbits.py

+12-17
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,9 @@ def _update_keys_named_objects():
219219
# Format the keys of the known objects dictionary, first collections
220220
old_keys = list(_known_objects["_collections"].keys())
221221
for old_key in old_keys:
222-
_known_objects["_collections"][
223-
_named_objects_key_formatting(old_key)
224-
] = _known_objects["_collections"].pop(old_key)
222+
_known_objects["_collections"][_named_objects_key_formatting(old_key)] = (
223+
_known_objects["_collections"].pop(old_key)
224+
)
225225
# Then the objects themselves
226226
old_keys = list(_known_objects.keys())
227227
old_keys.remove("_collections")
@@ -488,9 +488,7 @@ def _setup_parse_coordtransform(self, vxvv, ro, vo, zo, solarmotion, radec, lb):
488488
elif (
489489
not vxvv.galcen_distance is None
490490
and numpy.fabs(
491-
ro**2.0
492-
+ zo**2.0
493-
- vxvv.galcen_distance.to(units.kpc).value ** 2.0
491+
ro**2.0 + zo**2.0 - vxvv.galcen_distance.to(units.kpc).value ** 2.0
494492
)
495493
> 1e-10
496494
):
@@ -643,8 +641,7 @@ def _setup_parse_vxvv(self, vxvv, radec, lb, uvw):
643641
/ units.s
644642
)
645643
gc_frame = coordinates.Galactocentric(
646-
galcen_distance=numpy.sqrt(self._ro**2.0 + self._zo**2.0)
647-
* units.kpc,
644+
galcen_distance=numpy.sqrt(self._ro**2.0 + self._zo**2.0) * units.kpc,
648645
z_sun=self._zo * units.kpc,
649646
galcen_v_sun=galcen_v_sun,
650647
)
@@ -2148,9 +2145,7 @@ def E(self, *args, **kwargs):
21482145
for jj in range(self.size)
21492146
]
21502147
)
2151-
+ (
2152-
thiso[1] ** 2.0 / 2.0 + thiso[2] ** 2.0 / 2.0 + vz**2.0 / 2.0
2153-
).T
2148+
+ (thiso[1] ** 2.0 / 2.0 + thiso[2] ** 2.0 / 2.0 + vz**2.0 / 2.0).T
21542149
)
21552150
elif self.phasedim() == 6:
21562151
z = kwargs.get("_z", 1.0) * thiso[3] # For ER and Ez
@@ -2187,9 +2182,7 @@ def E(self, *args, **kwargs):
21872182
for jj in range(self.size)
21882183
]
21892184
)
2190-
+ (
2191-
thiso[1] ** 2.0 / 2.0 + thiso[2] ** 2.0 / 2.0 + vz**2.0 / 2.0
2192-
).T
2185+
+ (thiso[1] ** 2.0 / 2.0 + thiso[2] ** 2.0 / 2.0 + vz**2.0 / 2.0).T
21932186
)
21942187
if onet:
21952188
return out[:, 0]
@@ -8056,9 +8049,11 @@ def _parse_radec_kwargs(orb, kwargs, vel=False, dontpop=False, thiso=None):
80568049
if isinstance(obs, list) and not thiso is None and thiso.shape[1] > orb.size:
80578050
nt = thiso.shape[1] // orb.size
80588051
obs = [
8059-
numpy.tile(obs[ii], nt)
8060-
if isinstance(obs[ii], numpy.ndarray) and obs[ii].ndim > 0
8061-
else obs[ii]
8052+
(
8053+
numpy.tile(obs[ii], nt)
8054+
if isinstance(obs[ii], numpy.ndarray) and obs[ii].ndim > 0
8055+
else obs[ii]
8056+
)
80628057
for ii in range(len(obs))
80638058
]
80648059
ro = numpy.tile(ro, nt) if isinstance(ro, numpy.ndarray) and ro.ndim > 0 else ro

galpy/potential/BurkertPotential.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ def _revaluate(self, r, t=0.0):
6565
* (
6666
-numpy.pi / x
6767
+ 2.0 * (1.0 / x + 1) * numpy.arctan(1 / x)
68-
+ (1.0 / x + 1)
69-
* numpy.log((1.0 + 1.0 / x) ** 2.0 / (1.0 + 1 / x**2.0))
68+
+ (1.0 / x + 1) * numpy.log((1.0 + 1.0 / x) ** 2.0 / (1.0 + 1 / x**2.0))
7069
+ special.xlogy(2.0 / x, 1.0 + x**2.0)
7170
)
7271
)

galpy/potential/DehnenBarPotential.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,7 @@ def _smooth(self, t):
163163
deltat = t - self._tform
164164
xi = 2.0 * deltat / (self._tsteady - self._tform) - 1.0
165165
smooth = (
166-
3.0 / 16.0 * xi**5.0
167-
- 5.0 / 8 * xi**3.0
168-
+ 15.0 / 16.0 * xi
169-
+ 0.5
166+
3.0 / 16.0 * xi**5.0 - 5.0 / 8 * xi**3.0 + 15.0 / 16.0 * xi + 0.5
170167
)
171168
else: # bar is fully on
172169
smooth = 1.0

galpy/potential/DehnenSmoothWrapperPotential.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,7 @@ def _smooth(self, t):
7272
elif t < self._tsteady:
7373
deltat = t - self._tform
7474
xi = 2.0 * deltat / (self._tsteady - self._tform) - 1.0
75-
smooth = (
76-
3.0 / 16.0 * xi**5.0 - 5.0 / 8 * xi**3.0 + 15.0 / 16.0 * xi + 0.5
77-
)
75+
smooth = 3.0 / 16.0 * xi**5.0 - 5.0 / 8 * xi**3.0 + 15.0 / 16.0 * xi + 0.5
7876
else: # bar is fully on
7977
smooth = 1.0
8078
return smooth if self._grow else 1.0 - smooth

galpy/potential/DiskSCFPotential.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -392,10 +392,7 @@ def _Rzderiv(self, R, z, phi=0.0, t=0.0):
392392
4.0
393393
* numpy.pi
394394
* a
395-
* (
396-
H(z) * R * z / r**2.0 * (d2s(r) - ds(r) / r)
397-
+ ds(r) * dH(z) * R / r
398-
)
395+
* (H(z) * R * z / r**2.0 * (d2s(r) - ds(r) / r) + ds(r) * dH(z) * R / r)
399396
)
400397
return out
401398

galpy/potential/EllipsoidalPotential.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -430,11 +430,7 @@ def _forceInt(x, y, z, dens, b2, c2, i, glx=None, glw=None):
430430
def integrand(s):
431431
t = 1 / s**2.0 - 1.0
432432
return (
433-
dens(
434-
numpy.sqrt(
435-
x**2.0 / (1.0 + t) + y**2.0 / (b2 + t) + z**2.0 / (c2 + t)
436-
)
437-
)
433+
dens(numpy.sqrt(x**2.0 / (1.0 + t) + y**2.0 / (b2 + t) + z**2.0 / (c2 + t)))
438434
* (
439435
x / (1.0 + t) * (i == 0)
440436
+ y / (b2 + t) * (i == 1)

galpy/potential/EllipticalDiskPotential.py

+7-27
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,7 @@ def _evaluate(self, R, phi=0.0, t=0.0):
109109
deltat = t - self._tform
110110
xi = 2.0 * deltat / (self._tsteady - self._tform) - 1.0
111111
smooth = (
112-
3.0 / 16.0 * xi**5.0
113-
- 5.0 / 8 * xi**3.0
114-
+ 15.0 / 16.0 * xi
115-
+ 0.5
112+
3.0 / 16.0 * xi**5.0 - 5.0 / 8 * xi**3.0 + 15.0 / 16.0 * xi + 0.5
116113
)
117114
else: # fully on
118115
smooth = 1.0
@@ -135,10 +132,7 @@ def _Rforce(self, R, phi=0.0, t=0.0):
135132
deltat = t - self._tform
136133
xi = 2.0 * deltat / (self._tsteady - self._tform) - 1.0
137134
smooth = (
138-
3.0 / 16.0 * xi**5.0
139-
- 5.0 / 8 * xi**3.0
140-
+ 15.0 / 16.0 * xi
141-
+ 0.5
135+
3.0 / 16.0 * xi**5.0 - 5.0 / 8 * xi**3.0 + 15.0 / 16.0 * xi + 0.5
142136
)
143137
else: # fully on
144138
smooth = 1.0
@@ -162,18 +156,13 @@ def _phitorque(self, R, phi=0.0, t=0.0):
162156
deltat = t - self._tform
163157
xi = 2.0 * deltat / (self._tsteady - self._tform) - 1.0
164158
smooth = (
165-
3.0 / 16.0 * xi**5.0
166-
- 5.0 / 8 * xi**3.0
167-
+ 15.0 / 16.0 * xi
168-
+ 0.5
159+
3.0 / 16.0 * xi**5.0 - 5.0 / 8 * xi**3.0 + 15.0 / 16.0 * xi + 0.5
169160
)
170161
else: # fully on
171162
smooth = 1.0
172163
else:
173164
smooth = 1.0
174-
return (
175-
smooth * self._twophio * R**self._p * numpy.sin(2.0 * (phi - self._phib))
176-
)
165+
return smooth * self._twophio * R**self._p * numpy.sin(2.0 * (phi - self._phib))
177166

178167
def _R2deriv(self, R, phi=0.0, t=0.0):
179168
# Calculate relevant time
@@ -184,10 +173,7 @@ def _R2deriv(self, R, phi=0.0, t=0.0):
184173
deltat = t - self._tform
185174
xi = 2.0 * deltat / (self._tsteady - self._tform) - 1.0
186175
smooth = (
187-
3.0 / 16.0 * xi**5.0
188-
- 5.0 / 8 * xi**3.0
189-
+ 15.0 / 16.0 * xi
190-
+ 0.5
176+
3.0 / 16.0 * xi**5.0 - 5.0 / 8 * xi**3.0 + 15.0 / 16.0 * xi + 0.5
191177
)
192178
else: # fully on
193179
smooth = 1.0
@@ -212,10 +198,7 @@ def _phi2deriv(self, R, phi=0.0, t=0.0):
212198
deltat = t - self._tform
213199
xi = 2.0 * deltat / (self._tsteady - self._tform) - 1.0
214200
smooth = (
215-
3.0 / 16.0 * xi**5.0
216-
- 5.0 / 8 * xi**3.0
217-
+ 15.0 / 16.0 * xi
218-
+ 0.5
201+
3.0 / 16.0 * xi**5.0 - 5.0 / 8 * xi**3.0 + 15.0 / 16.0 * xi + 0.5
219202
)
220203
else: # perturbation is fully on
221204
smooth = 1.0
@@ -238,10 +221,7 @@ def _Rphideriv(self, R, phi=0.0, t=0.0):
238221
deltat = t - self._tform
239222
xi = 2.0 * deltat / (self._tsteady - self._tform) - 1.0
240223
smooth = (
241-
3.0 / 16.0 * xi**5.0
242-
- 5.0 / 8 * xi**3.0
243-
+ 15.0 / 16.0 * xi
244-
+ 0.5
224+
3.0 / 16.0 * xi**5.0 - 5.0 / 8 * xi**3.0 + 15.0 / 16.0 * xi + 0.5
245225
)
246226
else: # perturbation is fully on
247227
smooth = 1.0

galpy/potential/FerrersPotential.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -439,9 +439,7 @@ def _FracInt(x, y, z, a, b, c, tau, n):
439439
sqrt(tau+a)(tau+b)(tau+c)) tau+a tau+b tau+c
440440
"""
441441
denom = numpy.sqrt((a + tau) * (b + tau) * (c + tau))
442-
return (
443-
1.0 - x**2 / (a + tau) - y**2 / (b + tau) - z**2 / (c + tau)
444-
) ** n / denom
442+
return (1.0 - x**2 / (a + tau) - y**2 / (b + tau) - z**2 / (c + tau)) ** n / denom
445443

446444

447445
def lowerlim(x, y, z, a, b, c):

0 commit comments

Comments
 (0)