Skip to content

Commit

Permalink
new release
Browse files Browse the repository at this point in the history
  • Loading branch information
johannesulf committed Oct 18, 2024
1 parent 22815fe commit eef8808
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ All notable changes to nautilus will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [1.0.5] - 2023-10-18

### Added
- The equal-weighted posterior can now be made larger and more precise using the `equal_weight_boost` keyword argument of `sampler.posterior`.
Expand Down
2 changes: 1 addition & 1 deletion nautilus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@

__author__ = 'Johannes U. Lange'
__email__ = 'julange.astro@pm.me'
__version__ = '1.0.4'
__version__ = '1.0.5'
5 changes: 2 additions & 3 deletions nautilus/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import numpy as np

from functools import partial
from multiprocessing import Pool
from pathlib import Path
from scipy.special import logsumexp
from shutil import get_terminal_size
Expand All @@ -16,7 +15,7 @@
from warnings import warn

from .bounds import UnitCube, NautilusBound
from .pool import initialize_worker, likelihood_worker, NautilusPool
from .pool import likelihood_worker, NautilusPool


class Sampler():
Expand Down Expand Up @@ -608,7 +607,7 @@ def posterior(self, return_as_dict=None, equal_weight=False,
repeats = np.exp(log_w - np.amax(log_w)) * equal_weight_boost
repeats = np.floor(repeats).astype(int) + (
self.rng.random(len(repeats)) < repeats - np.floor(repeats)
).astype(int)
).astype(int)
points = np.repeat(points, repeats, axis=0)
log_w = np.zeros(np.sum(repeats))
log_l = np.repeat(log_l, repeats, axis=0)
Expand Down
2 changes: 2 additions & 0 deletions tests/test_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ def likelihood(x):
points, log_w, log_l = sampler.posterior(return_as_dict=pass_dict)
points, log_w, log_l = sampler.posterior(
return_as_dict=pass_dict, equal_weight=True)
# All points should be unique (unless equal_weight_boost > 1).
assert len(np.unique(points, axis=0)) == len(points)
assert sampler.n_eff > 0
sampler.log_z
assert sampler.eta > 0
Expand Down

0 comments on commit eef8808

Please sign in to comment.