mc3 3.2.0__tar.gz → 3.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mc3-3.3.0/.github/workflows/python-package.yml +47 -0
- mc3-3.3.0/MANIFEST.in +12 -0
- {mc3-3.2.0 → mc3-3.3.0}/PKG-INFO +6 -24
- mc3-3.3.0/docs/docs_requirements.txt +6 -0
- {mc3-3.2.0 → mc3-3.3.0}/docs/get_started.rst +1 -1
- {mc3-3.2.0 → mc3-3.3.0}/docs/index.rst +1 -1
- {mc3-3.2.0 → mc3-3.3.0}/mc3/__init__.py +1 -1
- {mc3-3.2.0 → mc3-3.3.0}/mc3/__main__.py +1 -1
- {mc3-3.2.0 → mc3-3.3.0}/mc3/chain.py +1 -1
- {mc3-3.2.0 → mc3-3.3.0}/mc3/fit_driver.py +1 -1
- {mc3-3.2.0 → mc3-3.3.0}/mc3/mcmc_driver.py +1 -1
- {mc3-3.2.0 → mc3-3.3.0}/mc3/plots/__init__.py +1 -1
- {mc3-3.2.0 → mc3-3.3.0}/mc3/plots/colors.py +10 -2
- {mc3-3.2.0 → mc3-3.3.0}/mc3/plots/plot_functions.py +1 -1
- {mc3-3.2.0 → mc3-3.3.0}/mc3/plots/posterior.py +116 -26
- {mc3-3.2.0 → mc3-3.3.0}/mc3/sampler_driver.py +1 -1
- {mc3-3.2.0 → mc3-3.3.0}/mc3/stats/__init__.py +3 -1
- mc3-3.3.0/mc3/stats/dwt.py +229 -0
- {mc3-3.2.0 → mc3-3.3.0}/mc3/stats/gelman.py +1 -1
- {mc3-3.2.0 → mc3-3.3.0}/mc3/stats/prayer.py +1 -1
- {mc3-3.2.0 → mc3-3.3.0}/mc3/stats/stats.py +80 -149
- mc3-3.3.0/mc3/stats/time_averaging.py +199 -0
- {mc3-3.2.0 → mc3-3.3.0}/mc3/utils/__init__.py +1 -1
- {mc3-3.2.0 → mc3-3.3.0}/mc3/utils/log.py +1 -1
- {mc3-3.2.0 → mc3-3.3.0}/mc3/utils/utils.py +1 -1
- {mc3-3.2.0 → mc3-3.3.0}/mc3/version.py +2 -2
- {mc3-3.2.0 → mc3-3.3.0}/mc3.egg-info/PKG-INFO +6 -24
- {mc3-3.2.0 → mc3-3.3.0}/mc3.egg-info/SOURCES.txt +3 -15
- {mc3-3.2.0 → mc3-3.3.0}/mc3.egg-info/requires.txt +1 -1
- {mc3-3.2.0 → mc3-3.3.0}/pyproject.toml +4 -4
- {mc3-3.2.0 → mc3-3.3.0}/requirements.txt +1 -1
- {mc3-3.2.0 → mc3-3.3.0}/tests/test_fit.py +1 -1
- {mc3-3.2.0 → mc3-3.3.0}/tests/test_logging.py +1 -1
- {mc3-3.2.0 → mc3-3.3.0}/tests/test_mcmc.py +11 -4
- {mc3-3.2.0 → mc3-3.3.0}/tests/test_plots.py +1 -1
- {mc3-3.2.0 → mc3-3.3.0}/tests/test_stats.py +39 -34
- {mc3-3.2.0 → mc3-3.3.0}/tests/test_utils.py +1 -1
- mc3-3.2.0/MANIFEST.in +0 -19
- mc3-3.2.0/Makefile +0 -46
- mc3-3.2.0/docs/figures/quad_bestfit.png +0 -0
- mc3-3.2.0/docs/figures/quad_fitting.png +0 -0
- mc3-3.2.0/docs/figures/quad_hist.png +0 -0
- mc3-3.2.0/docs/figures/quad_pairwise.png +0 -0
- mc3-3.2.0/docs/figures/quad_trace.png +0 -0
- mc3-3.2.0/docs/figures/rms-vs-binsize.png +0 -0
- mc3-3.2.0/mc3/stats/time_averaging.py +0 -60
- mc3-3.2.0/setup.py +0 -38
- mc3-3.2.0/src_c/_binarray.c +0 -107
- mc3-3.2.0/src_c/_chisq.c +0 -167
- mc3-3.2.0/src_c/_dwt.c +0 -216
- mc3-3.2.0/src_c/_time_averaging.c +0 -171
- mc3-3.2.0/src_c/include/ind.h +0 -9
- mc3-3.2.0/src_c/include/stats.h +0 -224
- mc3-3.2.0/src_c/include/wavelet.h +0 -128
- {mc3-3.2.0 → mc3-3.3.0}/.readthedocs.yml +0 -0
- {mc3-3.2.0 → mc3-3.3.0}/CONTRIBUTING.md +0 -0
- {mc3-3.2.0 → mc3-3.3.0}/LICENSE +0 -0
- {mc3-3.2.0 → mc3-3.3.0}/README.md +0 -0
- {mc3-3.2.0 → mc3-3.3.0}/docs/Makefile +0 -0
- {mc3-3.2.0 → mc3-3.3.0}/docs/api.rst +0 -0
- {mc3-3.2.0 → mc3-3.3.0}/docs/conf.py +0 -0
- {mc3-3.2.0 → mc3-3.3.0}/docs/contributing.rst +0 -0
- {mc3-3.2.0 → mc3-3.3.0}/docs/fit_tutorial.rst +0 -0
- {mc3-3.2.0 → mc3-3.3.0}/docs/license.rst +0 -0
- {mc3-3.2.0 → mc3-3.3.0}/docs/make.bat +0 -0
- {mc3-3.2.0 → mc3-3.3.0}/docs/mcmc_tutorial.rst +0 -0
- {mc3-3.2.0 → mc3-3.3.0}/docs/references.rst +0 -0
- {mc3-3.2.0 → mc3-3.3.0}/docs/time_averaging.rst +0 -0
- {mc3-3.2.0 → mc3-3.3.0}/examples/get_started.py +0 -0
- {mc3-3.2.0 → mc3-3.3.0}/examples/timeavg.py +0 -0
- {mc3-3.2.0 → mc3-3.3.0}/examples/tutorial.py +0 -0
- {mc3-3.2.0 → mc3-3.3.0}/mc3.egg-info/dependency_links.txt +0 -0
- {mc3-3.2.0 → mc3-3.3.0}/mc3.egg-info/entry_points.txt +0 -0
- {mc3-3.2.0 → mc3-3.3.0}/mc3.egg-info/top_level.txt +0 -0
- {mc3-3.2.0 → mc3-3.3.0}/pytest.ini +0 -0
- {mc3-3.2.0 → mc3-3.3.0}/setup.cfg +0 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
|
|
2
|
+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
|
|
3
|
+
|
|
4
|
+
name: Tests
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
branches: [ "*" ]
|
|
9
|
+
pull_request:
|
|
10
|
+
branches: [ "main" ]
|
|
11
|
+
schedule:
|
|
12
|
+
- cron: '0 12 1 * *'
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
build:
|
|
16
|
+
|
|
17
|
+
runs-on: ${{ matrix.os }}
|
|
18
|
+
strategy:
|
|
19
|
+
fail-fast: false
|
|
20
|
+
matrix:
|
|
21
|
+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
|
|
22
|
+
os: [ubuntu-latest]
|
|
23
|
+
|
|
24
|
+
steps:
|
|
25
|
+
- uses: actions/checkout@v6
|
|
26
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
27
|
+
uses: actions/setup-python@v6
|
|
28
|
+
with:
|
|
29
|
+
python-version: ${{ matrix.python-version }}
|
|
30
|
+
- name: Install dependencies
|
|
31
|
+
run: |
|
|
32
|
+
python -m pip install --upgrade pip
|
|
33
|
+
python -m pip install flake8 pytest
|
|
34
|
+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
|
35
|
+
|
|
36
|
+
- name: Install package
|
|
37
|
+
run: |
|
|
38
|
+
python -m pip install -e .
|
|
39
|
+
- name: Lint with flake8
|
|
40
|
+
run: |
|
|
41
|
+
# stop the build if there are Python syntax errors or undefined names
|
|
42
|
+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
|
43
|
+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
|
|
44
|
+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
|
45
|
+
- name: Test with pytest
|
|
46
|
+
run: |
|
|
47
|
+
pytest tests -v
|
mc3-3.3.0/MANIFEST.in
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
include MANIFEST.in
|
|
2
|
+
include CONTRIBUTING.md
|
|
3
|
+
include README.md
|
|
4
|
+
include LICENSE
|
|
5
|
+
include pyproject.toml
|
|
6
|
+
include requirements.txt
|
|
7
|
+
include pytest.ini
|
|
8
|
+
include .readthedocs.yml
|
|
9
|
+
include .github/workflows/python-package.yml
|
|
10
|
+
include tests/*
|
|
11
|
+
include docs/*
|
|
12
|
+
include examples/*.py
|
{mc3-3.2.0 → mc3-3.3.0}/PKG-INFO
RENAMED
|
@@ -1,37 +1,19 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: mc3
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.3.0
|
|
4
4
|
Summary: Multi-core Markov-chain Monte Carlo package
|
|
5
5
|
Author-email: Patricio Cubillos <patricio.cubillos@oeaw.ac.at>
|
|
6
|
-
License:
|
|
7
|
-
|
|
8
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
10
|
-
in the Software without restriction, including without limitation the rights
|
|
11
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
13
|
-
furnished to do so, subject to the following conditions:
|
|
14
|
-
|
|
15
|
-
The above copyright notice and this permission notice shall be included in
|
|
16
|
-
all copies or substantial portions of the Software.
|
|
17
|
-
|
|
18
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
24
|
-
THE SOFTWARE.
|
|
25
|
-
|
|
6
|
+
License-Expression: MIT
|
|
26
7
|
Project-URL: Homepage, https://github.com/pcubillos/mc3
|
|
27
|
-
Requires-Python: >=3.
|
|
8
|
+
Requires-Python: >=3.10
|
|
28
9
|
Description-Content-Type: text/markdown
|
|
29
10
|
License-File: LICENSE
|
|
30
|
-
Requires-Dist: numpy>=
|
|
11
|
+
Requires-Dist: numpy>=2.0.0
|
|
31
12
|
Requires-Dist: scipy>=1.5.4
|
|
32
13
|
Requires-Dist: matplotlib>=3.3.4
|
|
33
14
|
Provides-Extra: test
|
|
34
15
|
Requires-Dist: pytest>=6.0; extra == "test"
|
|
16
|
+
Dynamic: license-file
|
|
35
17
|
|
|
36
18
|
# mc3: Multi-core Markov-chain Monte Carlo
|
|
37
19
|
> A Python implementation of the Markov-chain Monte Carlo algorithm.
|
|
@@ -6,7 +6,7 @@ Getting Started
|
|
|
6
6
|
System Requirements
|
|
7
7
|
-------------------
|
|
8
8
|
|
|
9
|
-
``mc3`` is compatible with Python 3.
|
|
9
|
+
``mc3`` is compatible with Python 3.10+, and is `tested
|
|
10
10
|
<https://github.com/pcubillos/mc3/actions/workflows/python-package.yml>`_ to work on Unix/Linux and OS X machines.
|
|
11
11
|
|
|
12
12
|
Install
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright (c) 2015-
|
|
1
|
+
# Copyright (c) 2015-2026 Patricio Cubillos and contributors.
|
|
2
2
|
# mc3 is open-source software under the MIT license (see LICENSE).
|
|
3
3
|
|
|
4
4
|
__all__ = [
|
|
@@ -105,6 +105,7 @@ def rainbow_text(ax, texts, fontsize, colors=None, loc='above'):
|
|
|
105
105
|
fig = ax.get_figure()
|
|
106
106
|
t = ax.transAxes
|
|
107
107
|
x = 0.02
|
|
108
|
+
horizontalalignment = 'left'
|
|
108
109
|
if loc == 'above':
|
|
109
110
|
y = 1.02
|
|
110
111
|
verticalalignment = 'bottom'
|
|
@@ -113,11 +114,18 @@ def rainbow_text(ax, texts, fontsize, colors=None, loc='above'):
|
|
|
113
114
|
y = 0.97
|
|
114
115
|
verticalalignment = 'top'
|
|
115
116
|
bbox = {'facecolor':'white', 'alpha':0.5, 'pad':0.0, 'edgecolor':'none'}
|
|
117
|
+
elif loc == 'under':
|
|
118
|
+
y = -0.04
|
|
119
|
+
x = 0.97
|
|
120
|
+
verticalalignment = 'top'
|
|
121
|
+
horizontalalignment = 'right'
|
|
122
|
+
bbox = None
|
|
123
|
+
|
|
116
124
|
printed_texts = []
|
|
117
125
|
for string, col in zip(texts, colors):
|
|
118
126
|
text = ax.text(
|
|
119
127
|
x, y, string, color=col, transform=t,
|
|
120
|
-
ha=
|
|
128
|
+
ha=horizontalalignment, va=verticalalignment,
|
|
121
129
|
size=fontsize,
|
|
122
130
|
bbox=bbox,
|
|
123
131
|
)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright (c) 2015-
|
|
1
|
+
# Copyright (c) 2015-2026 Patricio Cubillos and contributors.
|
|
2
2
|
# mc3 is open-source software under the MIT license (see LICENSE).
|
|
3
3
|
|
|
4
4
|
__all__ = [
|
|
@@ -140,6 +140,8 @@ def _histogram(
|
|
|
140
140
|
hist_kw['facecolor'] = 'none'
|
|
141
141
|
|
|
142
142
|
for i in range(npars):
|
|
143
|
+
if np.any(np.isnan(posterior[:,i])):
|
|
144
|
+
continue
|
|
143
145
|
ax = axes[i]
|
|
144
146
|
if clear:
|
|
145
147
|
ax.clear()
|
|
@@ -193,6 +195,7 @@ def _pairwise(
|
|
|
193
195
|
hist, hist_xran, axes, ranges, estimates,
|
|
194
196
|
palette, nlevels, absolute_dens, lmax,
|
|
195
197
|
linewidth, theme, alpha=0.8, clear=True,
|
|
198
|
+
swap_axes=False,
|
|
196
199
|
):
|
|
197
200
|
"""
|
|
198
201
|
Lowest-lever routine to plot pair-wise posterior distributions.
|
|
@@ -206,13 +209,19 @@ def _pairwise(
|
|
|
206
209
|
for icol in range(npars-1):
|
|
207
210
|
for irow in range(icol, npars-1):
|
|
208
211
|
ax = axes[irow,icol]
|
|
212
|
+
if swap_axes:
|
|
213
|
+
row, col = icol, irow+1
|
|
214
|
+
histo = hist[col-1,row].T
|
|
215
|
+
else:
|
|
216
|
+
row, col = irow+1, icol
|
|
217
|
+
histo = hist[row-1,col]
|
|
209
218
|
if clear:
|
|
210
219
|
ax.clear()
|
|
211
220
|
extent = (
|
|
212
|
-
hist_xran[
|
|
213
|
-
hist_xran[
|
|
214
|
-
hist_xran[
|
|
215
|
-
hist_xran[
|
|
221
|
+
hist_xran[col, 0],
|
|
222
|
+
hist_xran[col, -1],
|
|
223
|
+
hist_xran[row, 0],
|
|
224
|
+
hist_xran[row, -1],
|
|
216
225
|
)
|
|
217
226
|
levels = np.zeros(nlevels+1)
|
|
218
227
|
levels[1:] = np.linspace(1.0, lmax[irow,icol], nlevels)
|
|
@@ -220,29 +229,30 @@ def _pairwise(
|
|
|
220
229
|
colors[0,3] = 0.0
|
|
221
230
|
colors[1,3] = 0.75*alpha
|
|
222
231
|
cont = ax.contourf(
|
|
223
|
-
|
|
232
|
+
histo,
|
|
224
233
|
colors=colors, levels=levels,
|
|
225
234
|
origin='lower', extent=extent,
|
|
226
235
|
)
|
|
227
|
-
edge_color = to_rgba(theme.color, alpha=0.
|
|
228
|
-
for
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
cont.
|
|
232
|
-
|
|
236
|
+
edge_color = to_rgba(theme.color, alpha=0.25)
|
|
237
|
+
edge_colors = [edge_color for _ in cont.get_paths()]
|
|
238
|
+
edge_colors[0] = (1,1,1,0)
|
|
239
|
+
cont.set_edgecolor(edge_colors)
|
|
240
|
+
cont.set_linewidth(0.1)
|
|
241
|
+
|
|
242
|
+
if estimates[col] is not None:
|
|
233
243
|
ax.axvline(
|
|
234
|
-
estimates[
|
|
244
|
+
estimates[col],
|
|
235
245
|
dashes=(9,2), lw=linewidth, color=theme.dark_color,
|
|
236
246
|
)
|
|
237
|
-
if estimates[
|
|
247
|
+
if estimates[row] is not None:
|
|
238
248
|
ax.axhline(
|
|
239
|
-
estimates[
|
|
249
|
+
estimates[row],
|
|
240
250
|
dashes=(9,2), lw=linewidth, color=theme.dark_color,
|
|
241
251
|
)
|
|
242
|
-
if ranges[
|
|
243
|
-
ax.set_xlim(ranges[
|
|
244
|
-
if ranges[
|
|
245
|
-
ax.set_ylim(ranges[
|
|
252
|
+
if ranges[col] is not None:
|
|
253
|
+
ax.set_xlim(ranges[col])
|
|
254
|
+
if ranges[row] is not None:
|
|
255
|
+
ax.set_ylim(ranges[row])
|
|
246
256
|
|
|
247
257
|
|
|
248
258
|
def _plot_marginal(obj):
|
|
@@ -302,7 +312,11 @@ def _plot_pairwise(obj):
|
|
|
302
312
|
for icol in range(npars-1):
|
|
303
313
|
for irow in range(icol, npars-1):
|
|
304
314
|
ax = obj.pair_axes[irow,icol]
|
|
305
|
-
|
|
315
|
+
if obj.orientation == 'vertical':
|
|
316
|
+
h = nx*irow + icol + 1 + npars*int(obj.plot_marginal)
|
|
317
|
+
else:
|
|
318
|
+
h = 2 + (nx+int(obj.plot_marginal))*icol + irow - icol
|
|
319
|
+
|
|
306
320
|
ax_position = subplot(
|
|
307
321
|
obj.rect, obj.margin, h, nx, nx, obj.ymargin, dry=True,
|
|
308
322
|
)
|
|
@@ -495,7 +509,7 @@ class RangeUpdate(SoftUpdate):
|
|
|
495
509
|
setattr(obj.source, var_name, value)
|
|
496
510
|
|
|
497
511
|
|
|
498
|
-
class Marginal(
|
|
512
|
+
class Marginal():
|
|
499
513
|
"""A mostly-interactive marginal posterior plotting object."""
|
|
500
514
|
# Soft-update properties:
|
|
501
515
|
pnames = SoftUpdate()
|
|
@@ -521,6 +535,7 @@ class Marginal(object):
|
|
|
521
535
|
bins=25, fontsize=11, linewidth=1.5,
|
|
522
536
|
axes=None,
|
|
523
537
|
show_texts=True, show_estimates=True,
|
|
538
|
+
alpha=0.6,
|
|
524
539
|
):
|
|
525
540
|
self.source = source
|
|
526
541
|
self.fig = None
|
|
@@ -532,6 +547,7 @@ class Marginal(object):
|
|
|
532
547
|
self.bestp = bestp
|
|
533
548
|
self.ranges = ranges
|
|
534
549
|
self.theme = theme
|
|
550
|
+
self.alpha = alpha
|
|
535
551
|
|
|
536
552
|
if nx is None or ny is None:
|
|
537
553
|
# Default layout:
|
|
@@ -618,6 +634,7 @@ class Marginal(object):
|
|
|
618
634
|
hpd_min, self.source.low_bounds, self.source.high_bounds,
|
|
619
635
|
self.linewidth, self.theme,
|
|
620
636
|
self.orientation,
|
|
637
|
+
alpha=self.alpha,
|
|
621
638
|
top_pad=1.25,
|
|
622
639
|
)
|
|
623
640
|
_plot_marginal(self)
|
|
@@ -625,6 +642,62 @@ class Marginal(object):
|
|
|
625
642
|
if savefile is not None:
|
|
626
643
|
self.fig.savefig(savefile, dpi=300)
|
|
627
644
|
|
|
645
|
+
def overplot(self, posts, labels=None, nlevels=4, alpha=0.4, axes_mask=None):
|
|
646
|
+
"""
|
|
647
|
+
Overplot additional posteriors in the same figure.
|
|
648
|
+
|
|
649
|
+
This method is still work in progress!
|
|
650
|
+
Note that a call to self.update() or even soft updates
|
|
651
|
+
will remove all/some of the overplot data. In such case
|
|
652
|
+
the user would need to make a new call to self.overplot().
|
|
653
|
+
It is also recommended to set show_estimates=False to
|
|
654
|
+
prevent over-crowding the figures.
|
|
655
|
+
|
|
656
|
+
Parameters
|
|
657
|
+
----------
|
|
658
|
+
posts: 1D iterable of Posterior objects
|
|
659
|
+
Currently there are no checks that these new posteriors
|
|
660
|
+
have the same parameters (nor same statistics) as self.
|
|
661
|
+
The user needs to make sure they are all compartible.
|
|
662
|
+
labels: 1D iterable of strings
|
|
663
|
+
Labels for each posterior. Note that if provided, the
|
|
664
|
+
length of labels has to be one more than posts, because
|
|
665
|
+
it also contains the label for self.
|
|
666
|
+
"""
|
|
667
|
+
all_posts = [self.source] + list(posts)
|
|
668
|
+
for i,post in enumerate(posts):
|
|
669
|
+
estimates = post.estimates
|
|
670
|
+
if not self.show_estimates:
|
|
671
|
+
estimates = [None for _ in estimates]
|
|
672
|
+
hpd_min = None
|
|
673
|
+
if '_like' in self.statistics:
|
|
674
|
+
hpd_min = self.source.hpd_min
|
|
675
|
+
|
|
676
|
+
_histogram(
|
|
677
|
+
post.posterior, estimates, self.ranges,
|
|
678
|
+
self.hist_axes, self.bins,
|
|
679
|
+
post.pdf, post.xpdf,
|
|
680
|
+
hpd_min, post.low_bounds, post.high_bounds,
|
|
681
|
+
self.linewidth, post.theme,
|
|
682
|
+
post.orientation, alpha=alpha,
|
|
683
|
+
clear=False,
|
|
684
|
+
)
|
|
685
|
+
if not self.show_texts:
|
|
686
|
+
return
|
|
687
|
+
text_cols = [post.theme.color for post in all_posts]
|
|
688
|
+
for text in self.stats_texts:
|
|
689
|
+
text.set_visible(False)
|
|
690
|
+
self.stats_texts = []
|
|
691
|
+
|
|
692
|
+
for j in range(self.npars):
|
|
693
|
+
stats_texts = [
|
|
694
|
+
'' if post.mask[j] else rf'{post.tex_estimates[j]}'
|
|
695
|
+
for post in all_posts
|
|
696
|
+
]
|
|
697
|
+
self.stats_texts += colors.rainbow_text(
|
|
698
|
+
self.hist_axes[j], stats_texts, self.fontsize, text_cols,
|
|
699
|
+
)
|
|
700
|
+
|
|
628
701
|
|
|
629
702
|
class Figure(Marginal):
|
|
630
703
|
"""A mostly-interactive pair-wise posterior plotting object."""
|
|
@@ -640,10 +713,11 @@ class Figure(Marginal):
|
|
|
640
713
|
bins=25, nlevels=6, fontsize=None, linewidth=None,
|
|
641
714
|
show_texts=True, show_estimates=True,
|
|
642
715
|
show_colorbar=True,
|
|
716
|
+
figure=None,
|
|
643
717
|
fignum=None,
|
|
644
718
|
):
|
|
645
719
|
self.source = source
|
|
646
|
-
self.fig =
|
|
720
|
+
self.fig = figure
|
|
647
721
|
self.pair_axes = None
|
|
648
722
|
self.hist_axes = None
|
|
649
723
|
self.posterior = posterior
|
|
@@ -756,6 +830,7 @@ class Figure(Marginal):
|
|
|
756
830
|
self.lmax,
|
|
757
831
|
self.linewidth,
|
|
758
832
|
self.theme,
|
|
833
|
+
swap_axes=self.orientation=='upper right',
|
|
759
834
|
)
|
|
760
835
|
|
|
761
836
|
# The colorbar:
|
|
@@ -879,7 +954,7 @@ class Figure(Marginal):
|
|
|
879
954
|
post.posterior, estimates, self.ranges, self.hist_axes,
|
|
880
955
|
self.bins, post.pdf, post.xpdf,
|
|
881
956
|
hpd_min, post.low_bounds, post.high_bounds,
|
|
882
|
-
self.linewidth, post.theme, post.orientation, alpha=
|
|
957
|
+
self.linewidth, post.theme, post.orientation, alpha=alpha,
|
|
883
958
|
clear=False,
|
|
884
959
|
)
|
|
885
960
|
if not self.show_texts:
|
|
@@ -989,7 +1064,7 @@ class StatisticsUpdate(ShareUpdate):
|
|
|
989
1064
|
)
|
|
990
1065
|
|
|
991
1066
|
|
|
992
|
-
class Posterior(
|
|
1067
|
+
class Posterior():
|
|
993
1068
|
"""
|
|
994
1069
|
Classification of posterior plotting tools.
|
|
995
1070
|
|
|
@@ -1035,6 +1110,7 @@ class Posterior(object):
|
|
|
1035
1110
|
show_texts=True, show_estimates=True,
|
|
1036
1111
|
show_colorbar=True,
|
|
1037
1112
|
seed=314159,
|
|
1113
|
+
mask=None,
|
|
1038
1114
|
):
|
|
1039
1115
|
self.figures = []
|
|
1040
1116
|
nsamples, self.npars = np.shape(posterior)
|
|
@@ -1076,7 +1152,9 @@ class Posterior(object):
|
|
|
1076
1152
|
self.bestp = bestp
|
|
1077
1153
|
self.statistics = statistics
|
|
1078
1154
|
self.quantile = quantile
|
|
1079
|
-
|
|
1155
|
+
if mask is None:
|
|
1156
|
+
mask = np.ones(self.npars, bool)
|
|
1157
|
+
self.mask = mask
|
|
1080
1158
|
|
|
1081
1159
|
def plot(
|
|
1082
1160
|
self, plot_marginal=True,
|
|
@@ -1088,6 +1166,7 @@ class Posterior(object):
|
|
|
1088
1166
|
show_texts=None, show_estimates=None,
|
|
1089
1167
|
show_colorbar=None,
|
|
1090
1168
|
savefile=None,
|
|
1169
|
+
nlevels=None,
|
|
1091
1170
|
):
|
|
1092
1171
|
"""
|
|
1093
1172
|
Plot marginal histograms and pairwise posteriors.
|
|
@@ -1101,6 +1180,8 @@ class Posterior(object):
|
|
|
1101
1180
|
show_texts = self.show_texts
|
|
1102
1181
|
if show_colorbar is None:
|
|
1103
1182
|
show_colorbar = self.show_colorbar
|
|
1183
|
+
if nlevels is None:
|
|
1184
|
+
nlevels = 6
|
|
1104
1185
|
|
|
1105
1186
|
fig = Figure(
|
|
1106
1187
|
self,
|
|
@@ -1119,7 +1200,8 @@ class Posterior(object):
|
|
|
1119
1200
|
show_texts=show_texts,
|
|
1120
1201
|
show_estimates=show_estimates,
|
|
1121
1202
|
show_colorbar=show_colorbar,
|
|
1122
|
-
# bins=25,
|
|
1203
|
+
# bins=25,
|
|
1204
|
+
nlevels=nlevels,
|
|
1123
1205
|
)
|
|
1124
1206
|
self.figures.append(fig)
|
|
1125
1207
|
fig.plot(figure=figure, savefile=savefile)
|
|
@@ -1130,7 +1212,9 @@ class Posterior(object):
|
|
|
1130
1212
|
self, fignum=None, axes=None, quantile=None,
|
|
1131
1213
|
nx=None, ny=None,
|
|
1132
1214
|
savefile=None,
|
|
1215
|
+
fontsize=11, linewidth=1.5,
|
|
1133
1216
|
show_texts=None, show_estimates=None,
|
|
1217
|
+
alpha=0.6,
|
|
1134
1218
|
):
|
|
1135
1219
|
"""
|
|
1136
1220
|
Plot histogram of marginal posteriors.
|
|
@@ -1139,6 +1223,8 @@ class Posterior(object):
|
|
|
1139
1223
|
show_estimates = self.show_estimates
|
|
1140
1224
|
if show_texts is None:
|
|
1141
1225
|
show_texts = self.show_texts
|
|
1226
|
+
if quantile is None:
|
|
1227
|
+
quantile = self.quantile
|
|
1142
1228
|
|
|
1143
1229
|
fig = Marginal(
|
|
1144
1230
|
self,
|
|
@@ -1146,8 +1232,12 @@ class Posterior(object):
|
|
|
1146
1232
|
self.ranges, self.theme,
|
|
1147
1233
|
statistics=self.statistics,
|
|
1148
1234
|
nx=nx, ny=ny,
|
|
1235
|
+
quantile=quantile,
|
|
1236
|
+
fontsize=fontsize,
|
|
1237
|
+
linewidth=linewidth,
|
|
1149
1238
|
show_texts=show_texts,
|
|
1150
1239
|
show_estimates=show_estimates,
|
|
1240
|
+
alpha=alpha,
|
|
1151
1241
|
)
|
|
1152
1242
|
self.figures.append(fig)
|
|
1153
1243
|
fig.plot(savefile=savefile, fignum=fignum, axes=axes)
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
# Copyright (c) 2015-
|
|
1
|
+
# Copyright (c) 2015-2026 Patricio Cubillos and contributors.
|
|
2
2
|
# mc3 is open-source software under the MIT license (see LICENSE).
|
|
3
3
|
|
|
4
4
|
from .gelman import *
|
|
5
5
|
from .stats import *
|
|
6
6
|
from .time_averaging import *
|
|
7
|
+
from .dwt import *
|
|
7
8
|
from .prayer import *
|
|
8
9
|
|
|
9
10
|
__all__ = (
|
|
10
11
|
gelman.__all__
|
|
11
12
|
+ stats.__all__
|
|
12
13
|
+ time_averaging.__all__
|
|
14
|
+
+ dwt.__all__
|
|
13
15
|
+ prayer.__all__
|
|
14
16
|
)
|
|
15
17
|
|