Skip to content

Commit

Permalink
remove limits attribute and xmin and xmax kwargs (#212)
Browse files Browse the repository at this point in the history
* remove the `limits` attribut of `Samples`, `MCMCSamples`, and `NestedSamples`, as well as the `xmin` and `xmax` kwargs passed to the plotting functions

* remove unused import for flake8

* remove `limits` attribute from the various readers since it is no longer used by `Samples`

* add tests for incorrect `burn_in` input

* catch empty file UserWarning

* add tests for xmin, xmax only for fastkde to help with code coverage

* change pytest UserWarning match, apparently different for different python versions

* further xmin, xmax tests, now also individually...

* add test for incorrect `ticks` input to `make_2d_axes`

* remove inaccessible ValueError

* add test for `compress_weights` with `None` inputs

* remove what seems to be unneccessary checks whether `data` are empty arrays, this should be handled by `Samples.plot_2d`

* add docstrings for `q` to plotting functions

* Updated burn in so that there is no requirement of float

* modify docstring for `burn_in` to better reflect the distinction between <1 and >1

Co-authored-by: Will Handley <[email protected]>
  • Loading branch information
lukashergt and williamjameshandley authored Aug 11, 2022
1 parent 237b724 commit 46a716d
Show file tree
Hide file tree
Showing 12 changed files with 289 additions and 474 deletions.
8 changes: 4 additions & 4 deletions anesthetic/boundary.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from scipy.special import erf


def cut_and_normalise_gaussian(x, p, sigma, xmin=None, xmax=None):
def cut_and_normalise_gaussian(x, p, bw, xmin=None, xmax=None):
"""Cut and normalise boundary correction for a Gaussian kernel.
Parameters
Expand All @@ -15,7 +15,7 @@ def cut_and_normalise_gaussian(x, p, sigma, xmin=None, xmax=None):
p: np.array
probability densities for normalisation correction
sigma: float
bw: float
bandwidth of KDE
xmin, xmax: float
Expand All @@ -31,9 +31,9 @@ def cut_and_normalise_gaussian(x, p, sigma, xmin=None, xmax=None):
correction = np.ones_like(x)

if xmin is not None:
correction *= 0.5*(1 + erf((x - xmin)/sigma/np.sqrt(2)))
correction *= 0.5 * (1 + erf((x-xmin)/bw/np.sqrt(2)))
correction[x < xmin] = np.inf
if xmax is not None:
correction *= 0.5*(1 + erf((xmax - x)/sigma/np.sqrt(2)))
correction *= 0.5 * (1 + erf((xmax-x)/bw/np.sqrt(2)))
correction[x > xmax] = np.inf
return p/correction
3 changes: 2 additions & 1 deletion anesthetic/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ def to_getdist(nested_samples):
weights = nested_samples.weights
loglikes = -nested_samples.logL.to_numpy()
names = nested_samples.columns
ranges = {name: nested_samples._limits(name) for name in names}
ranges = {name: (nested_samples[name].min(), nested_samples[name].max())
for name in names}
return getdist.mcsamples.MCSamples(samples=samples,
weights=weights,
loglikes=loglikes,
Expand Down
Loading

0 comments on commit 46a716d

Please sign in to comment.