Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pre-commit.ci] pre-commit autoupdate #631

Merged
merged 2 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ repos:
args: ["-L", "thisE,thise,mye,tE,te,hist,ro,sav,ccompiler,aas",
"-x","doc/source/_static/try-galpy.js"]
- repo: https://github.com/psf/black
rev: 23.12.1
rev: 24.1.1
hooks:
- id: black
4 changes: 1 addition & 3 deletions galpy/actionAngle/actionAngleSpherical.py
Original file line number Diff line number Diff line change
Expand Up @@ -807,9 +807,7 @@ def _calc_anglez(

def _JrSphericalIntegrand(r, E, L, pot):
"""The J_r integrand"""
return numpy.sqrt(
2.0 * (E - _evaluateplanarPotentials(pot, r)) - L**2.0 / r**2.0
)
return numpy.sqrt(2.0 * (E - _evaluateplanarPotentials(pot, r)) - L**2.0 / r**2.0)


def _TrSphericalIntegrandSmall(t, E, L, pot, rperi):
Expand Down
9 changes: 2 additions & 7 deletions galpy/actionAngle/actionAngleStaeckel.py
Original file line number Diff line number Diff line change
Expand Up @@ -1237,10 +1237,7 @@ def calcELStaeckel(R, vR, vT, z, vz, pot, vc=1.0, ro=1.0):

"""
return (
_evaluatePotentials(pot, R, z)
+ vR**2.0 / 2.0
+ vT**2.0 / 2.0
+ vz**2.0 / 2.0,
_evaluatePotentials(pot, R, z) + vR**2.0 / 2.0 + vT**2.0 / 2.0 + vz**2.0 / 2.0,
R * vT,
)

Expand Down Expand Up @@ -1552,9 +1549,7 @@ def estimateDeltaStaeckel(pot, R, z, no_median=False, delta0=1e-6):
for ii in range(len(R))
]
)
indx = (delta2 < delta0**2.0) * (
(delta2 > -(10.0**-10.0)) + pot_includes_scf
)
indx = (delta2 < delta0**2.0) * ((delta2 > -(10.0**-10.0)) + pot_includes_scf)
delta2[indx] = delta0**2.0
if not no_median:
delta2 = numpy.median(delta2[True ^ numpy.isnan(delta2)])
Expand Down
6 changes: 3 additions & 3 deletions galpy/actionAngle/actionAngleTorus.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
from .actionAngleTorus_c import _ext_loaded as ext_loaded

_autofit_errvals = {}
_autofit_errvals[
-1
] = "something wrong with input, usually bad starting values for the parameters"
_autofit_errvals[-1] = (
"something wrong with input, usually bad starting values for the parameters"
)
_autofit_errvals[-2] = "Fit failed the goal by a factor <= 2"
_autofit_errvals[-3] = "Fit failed the goal by more than 2"
_autofit_errvals[-4] = "Fit aborted: serious problems occurred"
Expand Down
6 changes: 3 additions & 3 deletions galpy/df/constantbetadf.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,9 @@
out = numpy.zeros_like(r) # Avoid JAX item assignment issues
# print("r",r,dmp1nudrmp1(r),(_evaluatePotentials(pot,r,0)-E))
out[:] = dmp1nudrmp1(r) / (_evaluatePotentials(pot, r, 0) - E) ** alpha
out[
True ^ numpy.isfinite(out)
] = 0.0 # assume these are where denom is slightly neg.
out[True ^ numpy.isfinite(out)] = (

Check warning on line 387 in galpy/df/constantbetadf.py

View check run for this annotation

Codecov / codecov/patch

galpy/df/constantbetadf.py#L387

Added line #L387 was not covered by tests
0.0 # assume these are where denom is slightly neg.
)
return out


Expand Down
4 changes: 1 addition & 3 deletions galpy/df/diskdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1782,9 +1782,7 @@ def _estimateSigmaT2(self, R, phi=0.0, log=False):
self._gamma
)
else:
return (
self.targetSigma2(R, log=log, use_physical=False) / self._gamma**2.0
)
return self.targetSigma2(R, log=log, use_physical=False) / self._gamma**2.0


class dehnendf(diskdf):
Expand Down
16 changes: 7 additions & 9 deletions galpy/df/evolveddiskdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2910,9 +2910,9 @@ def _buildvgrid(
deriv=deriv,
use_physical=False,
)
out.df[
ii, jj, numpy.isnan(out.df[ii, jj, :])
] = 0.0 # BOVY: for now
out.df[ii, jj, numpy.isnan(out.df[ii, jj, :])] = (
0.0 # BOVY: for now
)
if print_progress:
sys.stdout.write("\n") # pragma: no cover
else:
Expand Down Expand Up @@ -3278,9 +3278,9 @@ def __init__(
self.df[ii, jj, :] = edf(
thiso, numpy.array(t).flatten(), deriv=deriv
)
self.df[
ii, jj, numpy.isnan(self.df[ii, jj, :])
] = 0.0 # BOVY: for now
self.df[ii, jj, numpy.isnan(self.df[ii, jj, :])] = (
0.0 # BOVY: for now
)
# Multiply in area, somewhat tricky for edge objects
if upperdxdy is None or (
ii != 0
Expand Down Expand Up @@ -3401,9 +3401,7 @@ def __call__(self, n, m):
return numpy.array(out) + self.subgrid(n, m)
else:
# We already multiplied in the area
thislevel = numpy.dot(
self.vRgrid**n, numpy.dot(self.df, self.vTgrid**m)
)
thislevel = numpy.dot(self.vRgrid**n, numpy.dot(self.df, self.vTgrid**m))
if self.subgrid is None:
return thislevel
else:
Expand Down
7 changes: 1 addition & 6 deletions galpy/df/isotropicPlummerdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,7 @@ def __init__(self, pot=None, ro=None, vo=None):
self._Etildemax = pot._amp / pot._b
# /amp^4 instead of /amp^5 to make the DF that of mass density
self._fEnorm = (
24.0
* numpy.sqrt(2.0)
/ 7.0
/ numpy.pi**3.0
* pot._b**2.0
/ pot._amp**4.0
24.0 * numpy.sqrt(2.0) / 7.0 / numpy.pi**3.0 * pot._b**2.0 / pot._amp**4.0
)

def fE(self, E):
Expand Down
4 changes: 1 addition & 3 deletions galpy/df/osipkovmerrittNFWdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@
self._Qtildemax = pot._amp / pot.a
self._Qtildemin = -pot(self._rmax, 0, use_physical=False) / self._Qtildemax
self._a2overra2 = self._pot.a**2.0 / self._ra2
self._fQnorm = (
self._a2overra2 / (4.0 * numpy.pi) / pot.a**1.5 / pot._amp**0.5
)
self._fQnorm = self._a2overra2 / (4.0 * numpy.pi) / pot.a**1.5 / pot._amp**0.5

Check warning on line 62 in galpy/df/osipkovmerrittNFWdf.py

View check run for this annotation

Codecov / codecov/patch

galpy/df/osipkovmerrittNFWdf.py#L62

Added line #L62 was not covered by tests
# Initialize isotropic version to use as part of fQ
self._idf = isotropicNFWdf(pot=pot, rmax=rmax, ro=ro, vo=vo)

Expand Down
3 changes: 1 addition & 2 deletions galpy/df/osipkovmerrittdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,7 @@ def _p_v_at_r(self, v, r):
)
else:
return (
self.fQ(-_evaluatePotentials(self._pot, r, 0) - 0.5 * v**2.0)
* v**2.0
self.fQ(-_evaluatePotentials(self._pot, r, 0) - 0.5 * v**2.0) * v**2.0
)

def _sample_v(self, r, eta, n=1):
Expand Down
5 changes: 1 addition & 4 deletions galpy/df/sphericaldf.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,10 +732,7 @@ def _p_v_at_r(self, v, r):
* v**2.0
)
else:
return (
self.fE(_evaluatePotentials(self._pot, r, 0) + 0.5 * v**2.0)
* v**2.0
)
return self.fE(_evaluatePotentials(self._pot, r, 0) + 0.5 * v**2.0) * v**2.0


class anisotropicsphericaldf(sphericaldf):
Expand Down
4 changes: 1 addition & 3 deletions galpy/df/streamdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2650,9 +2650,7 @@ def sigangledAngle(self, dangle, assumeZeroMean=True, smallest=False, simple=Fal
eigIndx = 1
if simple:
dt = self.meantdAngle(dangle, use_physical=False)
return numpy.sqrt(
self._sigangle2 + self._sortedSigOEig[eigIndx] * dt**2.0
)
return numpy.sqrt(self._sigangle2 + self._sortedSigOEig[eigIndx] * dt**2.0)
aplow = numpy.amax(
[
numpy.sqrt(self._sortedSigOEig[eigIndx]) * self._tdisrupt * 5.0,
Expand Down
4 changes: 1 addition & 3 deletions galpy/df/streamgapdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,7 @@ def _densMoments_approx_higherorder_gaussxpolyInts(self, ll, ul, maxj):
in the higher-order terms, recursively"""
gaussxpolyInt = numpy.zeros((maxj, len(ul)))
gaussxpolyInt[-1] = (
1.0
/ numpy.sqrt(numpy.pi)
* (numpy.exp(-(ll**2.0)) - numpy.exp(-(ul**2.0)))
1.0 / numpy.sqrt(numpy.pi) * (numpy.exp(-(ll**2.0)) - numpy.exp(-(ul**2.0)))
)
gaussxpolyInt[-2] = 1.0 / numpy.sqrt(numpy.pi) * (
numpy.exp(-(ll**2.0)) * ll - numpy.exp(-(ul**2.0)) * ul
Expand Down
29 changes: 12 additions & 17 deletions galpy/orbit/Orbits.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,9 @@ def _update_keys_named_objects():
# Format the keys of the known objects dictionary, first collections
old_keys = list(_known_objects["_collections"].keys())
for old_key in old_keys:
_known_objects["_collections"][
_named_objects_key_formatting(old_key)
] = _known_objects["_collections"].pop(old_key)
_known_objects["_collections"][_named_objects_key_formatting(old_key)] = (
_known_objects["_collections"].pop(old_key)
)
# Then the objects themselves
old_keys = list(_known_objects.keys())
old_keys.remove("_collections")
Expand Down Expand Up @@ -488,9 +488,7 @@ def _setup_parse_coordtransform(self, vxvv, ro, vo, zo, solarmotion, radec, lb):
elif (
not vxvv.galcen_distance is None
and numpy.fabs(
ro**2.0
+ zo**2.0
- vxvv.galcen_distance.to(units.kpc).value ** 2.0
ro**2.0 + zo**2.0 - vxvv.galcen_distance.to(units.kpc).value ** 2.0
)
> 1e-10
):
Expand Down Expand Up @@ -643,8 +641,7 @@ def _setup_parse_vxvv(self, vxvv, radec, lb, uvw):
/ units.s
)
gc_frame = coordinates.Galactocentric(
galcen_distance=numpy.sqrt(self._ro**2.0 + self._zo**2.0)
* units.kpc,
galcen_distance=numpy.sqrt(self._ro**2.0 + self._zo**2.0) * units.kpc,
z_sun=self._zo * units.kpc,
galcen_v_sun=galcen_v_sun,
)
Expand Down Expand Up @@ -2148,9 +2145,7 @@ def E(self, *args, **kwargs):
for jj in range(self.size)
]
)
+ (
thiso[1] ** 2.0 / 2.0 + thiso[2] ** 2.0 / 2.0 + vz**2.0 / 2.0
).T
+ (thiso[1] ** 2.0 / 2.0 + thiso[2] ** 2.0 / 2.0 + vz**2.0 / 2.0).T
)
elif self.phasedim() == 6:
z = kwargs.get("_z", 1.0) * thiso[3] # For ER and Ez
Expand Down Expand Up @@ -2187,9 +2182,7 @@ def E(self, *args, **kwargs):
for jj in range(self.size)
]
)
+ (
thiso[1] ** 2.0 / 2.0 + thiso[2] ** 2.0 / 2.0 + vz**2.0 / 2.0
).T
+ (thiso[1] ** 2.0 / 2.0 + thiso[2] ** 2.0 / 2.0 + vz**2.0 / 2.0).T
)
if onet:
return out[:, 0]
Expand Down Expand Up @@ -8056,9 +8049,11 @@ def _parse_radec_kwargs(orb, kwargs, vel=False, dontpop=False, thiso=None):
if isinstance(obs, list) and not thiso is None and thiso.shape[1] > orb.size:
nt = thiso.shape[1] // orb.size
obs = [
numpy.tile(obs[ii], nt)
if isinstance(obs[ii], numpy.ndarray) and obs[ii].ndim > 0
else obs[ii]
(
numpy.tile(obs[ii], nt)
if isinstance(obs[ii], numpy.ndarray) and obs[ii].ndim > 0
else obs[ii]
)
for ii in range(len(obs))
]
ro = numpy.tile(ro, nt) if isinstance(ro, numpy.ndarray) and ro.ndim > 0 else ro
Expand Down
3 changes: 1 addition & 2 deletions galpy/potential/BurkertPotential.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ def _revaluate(self, r, t=0.0):
* (
-numpy.pi / x
+ 2.0 * (1.0 / x + 1) * numpy.arctan(1 / x)
+ (1.0 / x + 1)
* numpy.log((1.0 + 1.0 / x) ** 2.0 / (1.0 + 1 / x**2.0))
+ (1.0 / x + 1) * numpy.log((1.0 + 1.0 / x) ** 2.0 / (1.0 + 1 / x**2.0))
+ special.xlogy(2.0 / x, 1.0 + x**2.0)
)
)
Expand Down
5 changes: 1 addition & 4 deletions galpy/potential/DehnenBarPotential.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,7 @@ def _smooth(self, t):
deltat = t - self._tform
xi = 2.0 * deltat / (self._tsteady - self._tform) - 1.0
smooth = (
3.0 / 16.0 * xi**5.0
- 5.0 / 8 * xi**3.0
+ 15.0 / 16.0 * xi
+ 0.5
3.0 / 16.0 * xi**5.0 - 5.0 / 8 * xi**3.0 + 15.0 / 16.0 * xi + 0.5
)
else: # bar is fully on
smooth = 1.0
Expand Down
4 changes: 1 addition & 3 deletions galpy/potential/DehnenSmoothWrapperPotential.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ def _smooth(self, t):
elif t < self._tsteady:
deltat = t - self._tform
xi = 2.0 * deltat / (self._tsteady - self._tform) - 1.0
smooth = (
3.0 / 16.0 * xi**5.0 - 5.0 / 8 * xi**3.0 + 15.0 / 16.0 * xi + 0.5
)
smooth = 3.0 / 16.0 * xi**5.0 - 5.0 / 8 * xi**3.0 + 15.0 / 16.0 * xi + 0.5
else: # bar is fully on
smooth = 1.0
return smooth if self._grow else 1.0 - smooth
Expand Down
5 changes: 1 addition & 4 deletions galpy/potential/DiskSCFPotential.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,10 +392,7 @@ def _Rzderiv(self, R, z, phi=0.0, t=0.0):
4.0
* numpy.pi
* a
* (
H(z) * R * z / r**2.0 * (d2s(r) - ds(r) / r)
+ ds(r) * dH(z) * R / r
)
* (H(z) * R * z / r**2.0 * (d2s(r) - ds(r) / r) + ds(r) * dH(z) * R / r)
)
return out

Expand Down
6 changes: 1 addition & 5 deletions galpy/potential/EllipsoidalPotential.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,11 +430,7 @@ def _forceInt(x, y, z, dens, b2, c2, i, glx=None, glw=None):
def integrand(s):
t = 1 / s**2.0 - 1.0
return (
dens(
numpy.sqrt(
x**2.0 / (1.0 + t) + y**2.0 / (b2 + t) + z**2.0 / (c2 + t)
)
)
dens(numpy.sqrt(x**2.0 / (1.0 + t) + y**2.0 / (b2 + t) + z**2.0 / (c2 + t)))
* (
x / (1.0 + t) * (i == 0)
+ y / (b2 + t) * (i == 1)
Expand Down
34 changes: 7 additions & 27 deletions galpy/potential/EllipticalDiskPotential.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,7 @@ def _evaluate(self, R, phi=0.0, t=0.0):
deltat = t - self._tform
xi = 2.0 * deltat / (self._tsteady - self._tform) - 1.0
smooth = (
3.0 / 16.0 * xi**5.0
- 5.0 / 8 * xi**3.0
+ 15.0 / 16.0 * xi
+ 0.5
3.0 / 16.0 * xi**5.0 - 5.0 / 8 * xi**3.0 + 15.0 / 16.0 * xi + 0.5
)
else: # fully on
smooth = 1.0
Expand All @@ -135,10 +132,7 @@ def _Rforce(self, R, phi=0.0, t=0.0):
deltat = t - self._tform
xi = 2.0 * deltat / (self._tsteady - self._tform) - 1.0
smooth = (
3.0 / 16.0 * xi**5.0
- 5.0 / 8 * xi**3.0
+ 15.0 / 16.0 * xi
+ 0.5
3.0 / 16.0 * xi**5.0 - 5.0 / 8 * xi**3.0 + 15.0 / 16.0 * xi + 0.5
)
else: # fully on
smooth = 1.0
Expand All @@ -162,18 +156,13 @@ def _phitorque(self, R, phi=0.0, t=0.0):
deltat = t - self._tform
xi = 2.0 * deltat / (self._tsteady - self._tform) - 1.0
smooth = (
3.0 / 16.0 * xi**5.0
- 5.0 / 8 * xi**3.0
+ 15.0 / 16.0 * xi
+ 0.5
3.0 / 16.0 * xi**5.0 - 5.0 / 8 * xi**3.0 + 15.0 / 16.0 * xi + 0.5
)
else: # fully on
smooth = 1.0
else:
smooth = 1.0
return (
smooth * self._twophio * R**self._p * numpy.sin(2.0 * (phi - self._phib))
)
return smooth * self._twophio * R**self._p * numpy.sin(2.0 * (phi - self._phib))

def _R2deriv(self, R, phi=0.0, t=0.0):
# Calculate relevant time
Expand All @@ -184,10 +173,7 @@ def _R2deriv(self, R, phi=0.0, t=0.0):
deltat = t - self._tform
xi = 2.0 * deltat / (self._tsteady - self._tform) - 1.0
smooth = (
3.0 / 16.0 * xi**5.0
- 5.0 / 8 * xi**3.0
+ 15.0 / 16.0 * xi
+ 0.5
3.0 / 16.0 * xi**5.0 - 5.0 / 8 * xi**3.0 + 15.0 / 16.0 * xi + 0.5
)
else: # fully on
smooth = 1.0
Expand All @@ -212,10 +198,7 @@ def _phi2deriv(self, R, phi=0.0, t=0.0):
deltat = t - self._tform
xi = 2.0 * deltat / (self._tsteady - self._tform) - 1.0
smooth = (
3.0 / 16.0 * xi**5.0
- 5.0 / 8 * xi**3.0
+ 15.0 / 16.0 * xi
+ 0.5
3.0 / 16.0 * xi**5.0 - 5.0 / 8 * xi**3.0 + 15.0 / 16.0 * xi + 0.5
)
else: # perturbation is fully on
smooth = 1.0
Expand All @@ -238,10 +221,7 @@ def _Rphideriv(self, R, phi=0.0, t=0.0):
deltat = t - self._tform
xi = 2.0 * deltat / (self._tsteady - self._tform) - 1.0
smooth = (
3.0 / 16.0 * xi**5.0
- 5.0 / 8 * xi**3.0
+ 15.0 / 16.0 * xi
+ 0.5
3.0 / 16.0 * xi**5.0 - 5.0 / 8 * xi**3.0 + 15.0 / 16.0 * xi + 0.5
)
else: # perturbation is fully on
smooth = 1.0
Expand Down
Loading