Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#248)
Browse files Browse the repository at this point in the history
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/psf/black: 21.12b0 → 22.1.0](psf/black@21.12b0...22.1.0)
- [github.com/dfm/black_nbconvert: v0.3.0 → v0.4.0](dfm/black_nbconvert@v0.3.0...v0.4.0)
- [github.com/mwouts/jupytext: v1.13.6 → v1.13.7](mwouts/jupytext@v1.13.6...v1.13.7)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
pre-commit-ci[bot] committed Feb 16, 2022
1 parent 48bf5d8 commit 6bbc23b
Show file tree
Hide file tree
Showing 22 changed files with 70 additions and 70 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ repos:
exclude: docs/tutorials

- repo: https://github.com/psf/black
rev: "21.12b0"
rev: "22.1.0"
hooks:
- id: black

- repo: https://github.com/dfm/black_nbconvert
rev: v0.3.0
rev: v0.4.0
hooks:
- id: black_nbconvert

- repo: https://github.com/mwouts/jupytext
rev: v1.13.6
rev: v1.13.7
hooks:
- id: jupytext
files: |
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jupytext:
extension: .md
format_name: myst
format_version: 0.13
jupytext_version: 1.13.6
jupytext_version: 1.13.7
kernelspec:
display_name: Python 3
language: python
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/autodiff.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jupytext:
extension: .md
format_name: myst
format_version: 0.13
jupytext_version: 1.13.6
jupytext_version: 1.13.7
kernelspec:
display_name: Python 3
language: python
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/citation.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jupytext:
extension: .md
format_name: myst
format_version: 0.13
jupytext_version: 1.13.6
jupytext_version: 1.13.7
kernelspec:
display_name: Python 3
language: python
Expand Down
6 changes: 3 additions & 3 deletions docs/tutorials/data-and-models.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jupytext:
extension: .md
format_name: myst
format_version: 0.13
jupytext_version: 1.13.6
jupytext_version: 1.13.7
kernelspec:
display_name: Python 3
language: python
Expand Down Expand Up @@ -236,7 +236,7 @@ t_plot = np.linspace(0, 50, 500)
t = np.sort(random.uniform(0, 50, 20))
rv_err = 0.5 + np.zeros_like(t)
rv_obs = 5.0 * np.sin(2 * np.pi * t / 10.0) + np.sqrt(
0.05 ** 2 + rv_err ** 2
0.05**2 + rv_err**2
) * random.normal(size=len(t))
with pm.Model():
Expand Down Expand Up @@ -277,7 +277,7 @@ with pm.Model():
rv_model = zero_point + orbit.get_radial_velocity(t, K=semiamp)
# Finally add in the observation model
err = tt.sqrt(rv_err ** 2 + tt.exp(2 * log_jitter))
err = tt.sqrt(rv_err**2 + tt.exp(2 * log_jitter))
pm.Normal("obs", mu=rv_model, sigma=rv_err, observed=rv_obs)
# We'll also track the model just for plotting purposes
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/intro-to-pymc3.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jupytext:
extension: .md
format_name: myst
format_version: 0.13
jupytext_version: 1.13.6
jupytext_version: 1.13.7
kernelspec:
display_name: Python 3
language: python
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/light-delay.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jupytext:
extension: .md
format_name: myst
format_version: 0.13
jupytext_version: 1.13.6
jupytext_version: 1.13.7
kernelspec:
display_name: Python 3
language: python
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/reparameterization.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jupytext:
extension: .md
format_name: myst
format_version: 0.13
jupytext_version: 1.13.6
jupytext_version: 1.13.7
kernelspec:
display_name: Python 3
language: python
Expand Down
4 changes: 2 additions & 2 deletions src/exoplanet/distributions/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ def backward(self, y):

def forward(self, x):
usum = tt.sum(x, axis=0)
q = tt.stack([usum ** 2, 0.5 * x[0] / usum])
q = tt.stack([usum**2, 0.5 * x[0] / usum])
return tt.log(q) - tt.log(1 - q)

def forward_val(self, x, point=None):
usum = np.sum(x, axis=0)
q = np.array([usum ** 2, 0.5 * x[0] / usum])
q = np.array([usum**2, 0.5 * x[0] / usum])
return np.log(q) - np.log(1 - q)

def jacobian_det(self, y):
Expand Down
6 changes: 3 additions & 3 deletions src/exoplanet/estimators.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def estimate_semi_amplitude(periods, x, y, yerr=None, t0s=None):
if yerr is None:
ivar = np.ones_like(y)
else:
ivar = 1.0 / yerr ** 2
ivar = 1.0 / yerr**2

periods = u.Quantity(np.atleast_1d(periods), unit=u.day)
if t0s is not None:
Expand Down Expand Up @@ -149,9 +149,9 @@ def find_peaks(freq, power, max_peaks=0):
peaks.append(
dict(
index=i + 1,
log_power=w[2] + 0.5 * freq0 ** 2 / sigma2,
log_power=w[2] + 0.5 * freq0**2 / sigma2,
period=1.0 / freq0,
period_uncert=np.sqrt(sigma2 / freq0 ** 4),
period_uncert=np.sqrt(sigma2 / freq0**4),
)
)
if max_peaks:
Expand Down
2 changes: 1 addition & 1 deletion src/exoplanet/light_curves/interpolated.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def interp(n, x, xmin, xmax, dx, func):

inds = tt.cast(tt.floor((x - xmin) / dx), "int64")
x0 = (x - xp[inds + 1]) / dx
return a0[inds] + a1[inds] * x0 + a2[inds] * x0 ** 2 + a3[inds] * x0 ** 3
return a0[inds] + a1[inds] * x0 + a2[inds] * x0**2 + a3[inds] * x0**3


class InterpolatedLightCurve:
Expand Down
4 changes: 2 additions & 2 deletions src/exoplanet/light_curves/limb_dark.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ def get_ror_from_approx_transit_depth(self, delta, b, jac=False):
b = as_tensor_variable(b)
delta = as_tensor_variable(delta)
f0 = 1 - 2 * self.u1 / 6.0 - 2 * self.u2 / 12.0
arg = 1 - tt.sqrt(1 - b ** 2)
f = 1 - self.u1 * arg - self.u2 * arg ** 2
arg = 1 - tt.sqrt(1 - b**2)
f = 1 - self.u1 * arg - self.u2 * arg**2
factor = f0 / f
ror = tt.sqrt(delta * factor)
if not jac:
Expand Down
2 changes: 1 addition & 1 deletion src/exoplanet/light_curves/secondary_eclipse.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ def get_light_curve(
)

k = r / orbit.r_star
flux_ratio = self.surface_brightness_ratio * k ** 2
flux_ratio = self.surface_brightness_ratio * k**2

return (lc1 + flux_ratio * lc2) / (1 + flux_ratio)
6 changes: 3 additions & 3 deletions src/exoplanet/orbits/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
import numpy as np

try:
G_grav = c.G.to(u.R_sun ** 3 / u.M_sun / u.day ** 2).value
gcc_per_sun = (u.M_sun / u.R_sun ** 3).to(u.g / u.cm ** 3)
G_grav = c.G.to(u.R_sun**3 / u.M_sun / u.day**2).value
gcc_per_sun = (u.M_sun / u.R_sun**3).to(u.g / u.cm**3)
au_per_R_sun = u.R_sun.to(u.au)
c_light = c.c.to(u.R_sun / u.day).value

day_per_yr_over_2pi = (
(1.0 * u.au) ** (3 / 2)
/ (
np.sqrt(
c.G.to(u.au ** 3 / (u.M_sun * u.day ** 2)) * (1.0 * u.M_sun)
c.G.to(u.au**3 / (u.M_sun * u.day**2)) * (1.0 * u.M_sun)
)
)
).value
Expand Down
10 changes: 5 additions & 5 deletions src/exoplanet/orbits/dur_to_ecc.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ def duration_to_eccentricity(
a, period, rho_star, r_star, m_star, m_planet = inputs
b = kwargs.get("b", 0.0)
s = tt.sin(kwargs["omega"])
umax_inv = tt.switch(tt.lt(s, 0), tt.sqrt(1 - s ** 2), 1.0)
umax_inv = tt.switch(tt.lt(s, 0), tt.sqrt(1 - s**2), 1.0)

const = (
period * tt.shape_padright(r_star) * tt.sqrt((1 + ror) ** 2 - b ** 2)
period * tt.shape_padright(r_star) * tt.sqrt((1 + ror) ** 2 - b**2)
)
const /= np.pi * a

u = duration / const

e1 = -s * u ** 2 / ((s * u) ** 2 + 1)
e2 = tt.sqrt((s ** 2 - 1) * u ** 2 + 1) / ((s * u) ** 2 + 1)
e1 = -s * u**2 / ((s * u) ** 2 + 1)
e2 = tt.sqrt((s**2 - 1) * u**2 + 1) / ((s * u) ** 2 + 1)

models = []
logjacs = []
Expand All @@ -63,7 +63,7 @@ def duration_to_eccentricity(
logjac = tt.switch(
tt.all(valid_ecc),
tt.sum(
0.5 * tt.log(1 - ecc ** 2)
0.5 * tt.log(1 - ecc**2)
+ 2 * tt.log(s * ecc + 1)
- tt.log(tt.abs_(s + ecc))
- tt.log(const)
Expand Down
50 changes: 25 additions & 25 deletions src/exoplanet/orbits/keplerian.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def __init__(
* (self.a / self.r_star) ** 2
* daordtau
* gcc_per_sun
/ (G_grav * self.period ** 2)
/ (G_grav * self.period**2)
)

self.K0 = self.n * self.a / self.m_total
Expand Down Expand Up @@ -207,7 +207,7 @@ def __init__(
)
self.M0 = E0 - self.ecc * tt.sin(E0)

ome2 = 1 - self.ecc ** 2
ome2 = 1 - self.ecc**2
self.K0 /= tt.sqrt(ome2)
incl_factor = (1 + self.ecc * self.sin_omega) / ome2

Expand Down Expand Up @@ -243,17 +243,17 @@ def __init__(
aor = self.a_planet / self.r_star
esinw = self.ecc * self.sin_omega
self.b = tt.sqrt(
(aor ** 2 * c2 - 1)
(aor**2 * c2 - 1)
/ (
c2 * esinw ** 2
c2 * esinw**2
+ 2 * c2 * esinw
+ c2
- self.ecc ** 4
+ 2 * self.ecc ** 2
- self.ecc**4
+ 2 * self.ecc**2
- 1
)
)
self.b *= 1 - self.ecc ** 2
self.b *= 1 - self.ecc**2
self.cos_incl = self.dcosidb * self.b
self.incl = tt.arccos(self.cos_incl)
else:
Expand Down Expand Up @@ -338,7 +338,7 @@ def _get_position_and_velocity(self, t, parallax=None):
r = 1.0
vx, vy, vz = self._rotate_vector(-self.K0 * sinf, self.K0 * cosf)
else:
r = (1.0 - self.ecc ** 2) / (1 + self.ecc * cosf)
r = (1.0 - self.ecc**2) / (1 + self.ecc * cosf)
vx, vy, vz = self._rotate_vector(
-self.K0 * sinf, self.K0 * (cosf + self.ecc)
)
Expand Down Expand Up @@ -398,7 +398,7 @@ def _get_position(self, a, t, parallax=None, light_delay=False, _pad=True):
if self.ecc is None:
r = a
else:
r = a * (1.0 - self.ecc ** 2) / (1 + self.ecc * cosf)
r = a * (1.0 - self.ecc**2) / (1 + self.ecc * cosf)

if parallax is not None:
# convert r into arcseconds
Expand Down Expand Up @@ -432,16 +432,16 @@ def _get_retarded_position(self, a, t, parallax=None, z0=0.0, _pad=True):
vamp = angvel * a
vz = vamp * self.sin_incl * cosf
else:
r = a * (1.0 - self.ecc ** 2) / (1 + self.ecc * cosf)
vamp = angvel * a / tt.sqrt(1 - self.ecc ** 2)
r = a * (1.0 - self.ecc**2) / (1 + self.ecc * cosf)
vamp = angvel * a / tt.sqrt(1 - self.ecc**2)
cwf = self.cos_omega * cosf - self.sin_omega * sinf
vz = vamp * self.sin_incl * (self.ecc * self.cos_omega + cwf)

# True position of the body
x, y, z = self._rotate_vector(r * cosf, r * sinf)

# Component of the acceleration in the z direction
az = -(angvel ** 2) * (a / r) ** 3 * z
az = -(angvel**2) * (a / r) ** 3 * z

# Compute the time delay at the **retarded** position, accounting
# for the instantaneous velocity and acceleration of the body.
Expand All @@ -454,7 +454,7 @@ def _get_retarded_position(self, a, t, parallax=None, z0=0.0, _pad=True):
(1 + vz / c_light)
- tt.sqrt(
(1 + vz / c_light) * (1 + vz / c_light)
- 2 * az * (z0 - z) / c_light ** 2
- 2 * az * (z0 - z) / c_light**2
)
),
)
Expand Down Expand Up @@ -562,7 +562,7 @@ def get_relative_angles(self, t, parallax=None, light_delay=False):
)

# calculate rho and theta
rho = tt.squeeze(tt.sqrt(X ** 2 + Y ** 2)) # arcsec
rho = tt.squeeze(tt.sqrt(X**2 + Y**2)) # arcsec
theta = tt.squeeze(tt.arctan2(Y, X)) # radians between [-pi, pi]

return (rho, theta)
Expand Down Expand Up @@ -678,10 +678,10 @@ def _get_acceleration(self, a, m, t):
sinf, cosf = self._get_true_anomaly(t)
K = self.K0 * m
if self.ecc is None:
factor = -(K ** 2) / a
factor = -(K**2) / a
else:
factor = (
K ** 2 * (self.ecc * cosf + 1) ** 2 / (a * (self.ecc ** 2 - 1))
K**2 * (self.ecc * cosf + 1) ** 2 / (a * (self.ecc**2 - 1))
)
return self._rotate_vector(factor * cosf, factor * sinf)

Expand Down Expand Up @@ -833,14 +833,14 @@ def get_aor_from_transit_duration(duration, period, b, ror=None):
"""
if ror is None:
ror = as_tensor_variable(0.0)
b2 = b ** 2
b2 = b**2
opk2 = (1 + ror) ** 2
phi = np.pi * duration / period
sinp = tt.sin(phi)
cosp = tt.cos(phi)
num = tt.sqrt(opk2 - b2 * cosp ** 2)
num = tt.sqrt(opk2 - b2 * cosp**2)
aor = num / sinp
grad = np.pi * cosp * (b2 - opk2) / (num * period * sinp ** 2)
grad = np.pi * cosp * (b2 - opk2) / (num * period * sinp**2)
return aor, grad


Expand Down Expand Up @@ -878,11 +878,11 @@ def _get_consistent_inputs(a, period, rho_star, r_star, m_star, m_planet):
r_star = as_tensor_variable(to_unit(r_star, u.R_sun))

# Compute the implied mass via Kepler's 3rd law
m_tot = 4 * np.pi * np.pi * a ** 3 / (G_grav * period ** 2)
m_tot = 4 * np.pi * np.pi * a**3 / (G_grav * period**2)

# Compute the implied density
m_star = m_tot - m_planet
vol_star = 4 * np.pi * r_star ** 3 / 3.0
vol_star = 4 * np.pi * r_star**3 / 3.0
rho_star = m_star / vol_star
implied_rho_star = True

Expand All @@ -902,7 +902,7 @@ def _get_consistent_inputs(a, period, rho_star, r_star, m_star, m_planet):
if rho_star is not None and not implied_rho_star:
if has_unit(rho_star):
rho_star = as_tensor_variable(
to_unit(rho_star, u.M_sun / u.R_sun ** 3)
to_unit(rho_star, u.M_sun / u.R_sun**3)
)
else:
rho_star = as_tensor_variable(rho_star) / gcc_per_sun
Expand All @@ -913,16 +913,16 @@ def _get_consistent_inputs(a, period, rho_star, r_star, m_star, m_planet):

# Work out the stellar parameters
if rho_star is None:
rho_star = 3 * m_star / (4 * np.pi * r_star ** 3)
rho_star = 3 * m_star / (4 * np.pi * r_star**3)
elif r_star is None:
r_star = (3 * m_star / (4 * np.pi * rho_star)) ** (1 / 3)
elif m_star is None:
m_star = 4 * np.pi * r_star ** 3 * rho_star / 3.0
m_star = 4 * np.pi * r_star**3 * rho_star / 3.0

# Work out the planet parameters
if a is None:
a = (
G_grav * (m_star + m_planet) * period ** 2 / (4 * np.pi ** 2)
G_grav * (m_star + m_planet) * period**2 / (4 * np.pi**2)
) ** (1.0 / 3)
elif period is None:
period = (
Expand Down

0 comments on commit 6bbc23b

Please sign in to comment.