Skip to content

Commit

Permalink
Blackened.
Browse files Browse the repository at this point in the history
  • Loading branch information
justinbois committed Mar 5, 2021
1 parent dff9782 commit 433efb4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion bebi103/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@

__author__ = """Justin Bois"""
__email__ = "[email protected]"
__version__ = "0.1.3"
__version__ = "0.1.4"
9 changes: 4 additions & 5 deletions bebi103/gp.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ def _d1_se_kernel(x1, x2, alpha, rho):
x_diff = x1 - x2
rho2 = rho ** 2

return -alpha ** 2 * x_diff * np.exp(-x_diff ** 2 / 2.0 / rho2) / rho2
return -(alpha ** 2) * x_diff * np.exp(-(x_diff ** 2) / 2.0 / rho2) / rho2


@numba.njit
Expand All @@ -457,10 +457,10 @@ def _d2_se_kernel(x1, x2, alpha, rho):
@numba.njit
def _d1_d2_se_kernel(x1, x2, alpha, rho):
"""Derivative of first variable of squared exponential kernel."""
x_diff2 = (x1 - x2)**2
rho2 = rho**2
x_diff2 = (x1 - x2) ** 2
rho2 = rho ** 2

return (alpha / rho)**2 * np.exp(-x_diff2 / 2.0 / rho2) * (1 - x_diff2 / rho2)
return (alpha / rho) ** 2 * np.exp(-x_diff2 / 2.0 / rho2) * (1 - x_diff2 / rho2)


def _matern_kernel(x1, x2, alpha, rho, nu):
Expand Down Expand Up @@ -951,4 +951,3 @@ def _solve_mean_cov(y, Ky, Kstar, Kstarstar, delta):
)

return mstar, Sigmastar

1 change: 1 addition & 0 deletions bebi103/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from . import viz
from . import utils


def imshow(
im,
cmap=None,
Expand Down
13 changes: 9 additions & 4 deletions bebi103/stan.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@

from . import viz


def StanModel(
file=None,
charset="utf-8",
Expand Down Expand Up @@ -447,7 +448,7 @@ def df_to_datadict_hier(
return data, new_df


def arviz_to_dataframe(data, var_names=None, diagnostics=('diverging',)):
def arviz_to_dataframe(data, var_names=None, diagnostics=("diverging",)):
"""Convert ArviZ InferenceData to a Pandas data frame.
Any multi-dimensional parameters are converted to one-dimensional
Expand Down Expand Up @@ -502,12 +503,14 @@ def arviz_to_dataframe(data, var_names=None, diagnostics=('diverging',)):
diag_dict = {}
if diagnostics is not None and len(diagnostics) > 0:
if not hasattr(data, "sample_stats"):
raise RuntimeError("Asking for diagnostics, but input has not attribute sample_stats")
raise RuntimeError(
"Asking for diagnostics, but input has not attribute sample_stats"
)
for diag in diagnostics:
if hasattr(data.sample_stats, diag):
diag_dict[diag + "__"] = np.ravel(data.sample_stats[diag])
else:
raise RuntimeError(f'{diag} not in data.sample_stats.')
raise RuntimeError(f"{diag} not in data.sample_stats.")

cols, data_as_ndarray = _xarray_to_ndarray(data.posterior, var_names=var_names)

Expand Down Expand Up @@ -1715,7 +1718,9 @@ def _xarray_to_ndarray(ds, var_names=None, omit_dunders=True):
"""

names, vals = arviz.plots.plot_utils.xarray_to_ndarray(ds, var_names=var_names, combined=True)
names, vals = arviz.plots.plot_utils.xarray_to_ndarray(
ds, var_names=var_names, combined=True
)

names = [
name.replace("\n", "[").replace(", ", ",") + "]" if "\n" in name else name
Expand Down

0 comments on commit 433efb4

Please sign in to comment.