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 #416

Merged
merged 4 commits into from
Feb 16, 2022
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
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ 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
2 changes: 1 addition & 1 deletion docs/tutorials/autocorr.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@
"\n",
"\n",
"def log_prob(p):\n",
" return np.logaddexp(-0.5 * np.sum(p ** 2), -0.5 * np.sum((p - 4.0) ** 2))\n",
" return np.logaddexp(-0.5 * np.sum(p**2), -0.5 * np.sum((p - 4.0) ** 2))\n",
"\n",
"\n",
"sampler = emcee.EnsembleSampler(32, 3, log_prob)\n",
Expand Down
6 changes: 3 additions & 3 deletions docs/tutorials/line.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@
"source": [
"A = np.vander(x, 2)\n",
"C = np.diag(yerr * yerr)\n",
"ATA = np.dot(A.T, A / (yerr ** 2)[:, None])\n",
"ATA = np.dot(A.T, A / (yerr**2)[:, None])\n",
"cov = np.linalg.inv(ATA)\n",
"w = np.linalg.solve(ATA, np.dot(A.T, y / yerr ** 2))\n",
"w = np.linalg.solve(ATA, np.dot(A.T, y / yerr**2))\n",
"print(\"Least-squares estimates:\")\n",
"print(\"m = {0:.3f} ± {1:.3f}\".format(w[0], np.sqrt(cov[0, 0])))\n",
"print(\"b = {0:.3f} ± {1:.3f}\".format(w[1], np.sqrt(cov[1, 1])))\n",
Expand Down Expand Up @@ -218,7 +218,7 @@
"def log_likelihood(theta, x, y, yerr):\n",
" m, b, log_f = theta\n",
" model = m * x + b\n",
" sigma2 = yerr ** 2 + model ** 2 * np.exp(2 * log_f)\n",
" sigma2 = yerr**2 + model**2 * np.exp(2 * log_f)\n",
" return -0.5 * np.sum((y - model) ** 2 / sigma2 + np.log(sigma2))"
]
},
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/monitor.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"# We'll also use the \"blobs\" feature to track the \"log prior\" for each step\n",
"def log_prob(theta):\n",
" log_prior = -0.5 * np.sum((theta - 1.0) ** 2 / 100.0)\n",
" log_prob = -0.5 * np.sum(theta ** 2) + log_prior\n",
" log_prob = -0.5 * np.sum(theta**2) + log_prior\n",
" return log_prob, log_prior\n",
"\n",
"\n",
Expand Down Expand Up @@ -341,7 +341,7 @@
"# this time, with a subtly different prior\n",
"def log_prob2(theta):\n",
" log_prior = -0.5 * np.sum((theta - 2.0) ** 2 / 100.0)\n",
" log_prob = -0.5 * np.sum(theta ** 2) + log_prior\n",
" log_prob = -0.5 * np.sum(theta**2) + log_prior\n",
" return log_prob, log_prior\n",
"\n",
"\n",
Expand Down
6 changes: 3 additions & 3 deletions docs/tutorials/parallel.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
" while True:\n",
" if time.time() >= t:\n",
" break\n",
" return -0.5 * np.sum(theta ** 2)"
" return -0.5 * np.sum(theta**2)"
]
},
{
Expand Down Expand Up @@ -348,7 +348,7 @@
" while True:\n",
" if time.time() >= t:\n",
" break\n",
" return -0.5 * np.sum(theta ** 2)\n",
" return -0.5 * np.sum(theta**2)\n",
"\n",
"\n",
"data = np.random.randn(5000, 200)\n",
Expand Down Expand Up @@ -459,7 +459,7 @@
" while True:\n",
" if time.time() >= t:\n",
" break\n",
" return -0.5 * np.sum(theta ** 2)\n",
" return -0.5 * np.sum(theta**2)\n",
"\n",
"\n",
"with Pool() as pool:\n",
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/quickstart.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
"np.random.seed(42)\n",
"means = np.random.rand(ndim)\n",
"\n",
"cov = 0.5 - np.random.rand(ndim ** 2).reshape((ndim, ndim))\n",
"cov = 0.5 - np.random.rand(ndim**2).reshape((ndim, ndim))\n",
"cov = np.triu(cov)\n",
"cov += cov.T - np.diag(cov.diagonal())\n",
"cov = np.dot(cov, cov)"
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ build-backend = "setuptools.build_meta"

[tool.black]
line-length = 79
target-version = ['py35']
exclude = '''
/(
\.eggs
Expand Down
6 changes: 3 additions & 3 deletions src/emcee/ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ def walkers_independent(coords):
if np.any(C_colmax == 0):
return False
C /= C_colmax
C_colsum = np.sqrt(np.sum(C ** 2, axis=0))
C_colsum = np.sqrt(np.sum(C**2, axis=0))
C /= C_colsum
return np.linalg.cond(C.astype(float)) <= 1e8

Expand All @@ -655,11 +655,11 @@ def walkers_independent_cov(coords):


def _scaled_cond(a):
asum = np.sqrt((a ** 2).sum(axis=0))[None, :]
asum = np.sqrt((a**2).sum(axis=0))[None, :]
if np.any(asum == 0):
return np.inf
b = a / asum
bsum = np.sqrt((b ** 2).sum(axis=1))[:, None]
bsum = np.sqrt((b**2).sum(axis=1))[:, None]
if np.any(bsum == 0):
return np.inf
c = b / bsum
Expand Down
2 changes: 1 addition & 1 deletion src/emcee/tests/integration/test_longdouble.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

def test_longdouble_doesnt_crash_bug_312():
def log_prob(x, ivar):
return -0.5 * np.sum(ivar * x ** 2)
return -0.5 * np.sum(ivar * x**2)

ndim, nwalkers = 5, 20
ivar = 1.0 / np.random.rand(ndim).astype(np.longdouble)
Expand Down
4 changes: 2 additions & 2 deletions src/emcee/tests/integration/test_proposal.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@


def normal_log_prob_blobs(params):
return -0.5 * np.sum(params ** 2), params
return -0.5 * np.sum(params**2), params


def normal_log_prob(params):
return -0.5 * np.sum(params ** 2)
return -0.5 * np.sum(params**2)


def uniform_log_prob(params):
Expand Down
2 changes: 1 addition & 1 deletion src/emcee/tests/unit/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@


def normal_log_prob(params):
return -0.5 * np.sum(params ** 2)
return -0.5 * np.sum(params**2)


def normal_log_prob_blobs(params):
Expand Down
2 changes: 1 addition & 1 deletion src/emcee/tests/unit/test_blobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def __init__(self, blob_function):
self.blob_function = blob_function

def __call__(self, params):
return -0.5 * np.sum(params ** 2), self.blob_function(params)
return -0.5 * np.sum(params**2), self.blob_function(params)


@pytest.mark.parametrize("backend", backends.get_test_backends())
Expand Down
4 changes: 2 additions & 2 deletions src/emcee/tests/unit/test_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


def normal_log_prob(params):
return -0.5 * np.sum(params ** 2)
return -0.5 * np.sum(params**2)


@pytest.mark.parametrize(
Expand Down Expand Up @@ -211,7 +211,7 @@ def test_restart(backend):

def test_vectorize():
def lp_vec(p):
return -0.5 * np.sum(p ** 2, axis=1)
return -0.5 * np.sum(p**2, axis=1)

np.random.seed(42)
nwalkers, ndim = 32, 3
Expand Down
2 changes: 1 addition & 1 deletion src/emcee/tests/unit/test_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_overwrite(seed=1234):
np.random.seed(seed)

def ll(x):
return -0.5 * np.sum(x ** 2)
return -0.5 * np.sum(x**2)

nwalkers = 64
p0 = np.random.normal(size=(nwalkers, 1))
Expand Down