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

update chainconsuer version and api #51

Merged
merged 1 commit into from
Nov 29, 2023
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
43 changes: 27 additions & 16 deletions docs/notebooks/01_Fitting.ipynb

Large diffs are not rendered by default.

52 changes: 29 additions & 23 deletions docs/notebooks/02_MultiFitter.ipynb

Large diffs are not rendered by default.

58 changes: 15 additions & 43 deletions docs/notebooks/05_Fitting_Flat.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/ticktack/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name = "ticktack"
__version__ = "1.1.2"
__version__ = "1.1.3"

from .ticktack import *
27 changes: 16 additions & 11 deletions src/ticktack/fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
from tqdm import tqdm
import emcee

from chainconsumer import ChainConsumer
from chainconsumer import ChainConsumer, Chain, PlotConfig

import pandas as pd
import seaborn as sns
# from jaxns.nested_sampler import NestedSampler
# from jaxns.prior_transforms import PriorChain, UniformPrior
Expand Down Expand Up @@ -127,9 +128,10 @@ def chain_summary(self, chain, walkers, figsize=(10, 10), labels=None, plot_dist
and the posterior surface
"""
if labels:
c = ChainConsumer().add_chain(chain, walkers=walkers, parameters=labels)
else:
c = ChainConsumer().add_chain(chain, walkers=walkers)
newchain = Chain(samples=pd.DataFrame(chain, columns=labels), walkers=walkers,name='Chain 1')
c = ChainConsumer().add_chain(newchain)
# else:
# c = ChainConsumer().add_chain(chain, walkers=walkers)

if test_convergence:
gelman_rubin_converged = c.diagnostic.gelman_rubin()
Expand All @@ -143,8 +145,8 @@ def chain_summary(self, chain, walkers, figsize=(10, 10), labels=None, plot_dist
if plot_dist:
fig = c.plotter.plot_distributions(figsize=figsize)
else:
c.configure(spacing=0.0, usetex=usetex, label_font_size=label_font_size, tick_font_size=tick_font_size,
diagonal_tick_labels=False)
c.set_plot_config(PlotConfig(spacing=0.0, usetex=usetex, label_font_size=label_font_size, tick_font_size=tick_font_size,
diagonal_tick_labels=False))
fig = c.plotter.plot(figsize=figsize)

if mle:
Expand Down Expand Up @@ -273,13 +275,16 @@ def plot_multiple_chains(self, chains, walker, figsize=(10, 10), title=None, par
if labels:
assert len(labels) == len(chains), "labels must have the same length as chains"
for i in range(len(chains)):
c.add_chain(chains[i], walkers=walker, parameters=params_labels, name=labels[i])
newchain = Chain(samples=pd.DataFrame(chains[i], columns=params_labels), walkers=walker,name='Chain %d' % i)
c = ChainConsumer().add_chain(newchain)
else:
for i in range(len(chains)):
c.add_chain(chains[i], walkers=walker, parameters=params_labels)
c.configure(colors=colors, shade_alpha=alpha, linewidths=linewidths, usetex=usetex,
assert len(chains) >= 0, "chains must have labels"
# else:
# for i in range(len(chains)):
# c.add_chain(chains[i], walkers=walker, parameters=params_labels)
c.set_plot_config(PlotConfig(colors=colors, shade_alpha=alpha, linewidths=linewidths, usetex=usetex,
label_font_size=label_font_size, tick_font_size=tick_font_size, diagonal_tick_labels=False,
max_ticks=max_ticks)
max_ticks=max_ticks))
# legend_kwargs={"fontsize":14}

if plot_dists:
Expand Down
Loading