Skip to content

Commit

Permalink
auto update limits of derived parameters (#166)
Browse files Browse the repository at this point in the history
* call _set_automatic_limits at the start of plot to ensure derived parameters have appropriate limits even when they were defined after the creation of the NestedSamples or MCMCSamples object

* add test for auto update of derived parameters when calling plot
  • Loading branch information
Lukas Hergt authored Jul 4, 2021
1 parent 9c0aae4 commit 82f6b37
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions anesthetic/samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ def plot(self, ax, paramname_x, paramname_y=None, *args, **kwargs):
Pandas array of axes objects
"""
self._set_automatic_limits()
plot_type = kwargs.pop('plot_type', 'kde')
do_1d_plot = paramname_y is None or paramname_x == paramname_y
kwargs['label'] = kwargs.get('label', self.label)
Expand Down
9 changes: 9 additions & 0 deletions tests/test_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,15 @@ def test_limit_assignment():
assert ns.limits['logL'][1] == 5.748335384373301
assert ns.limits['nlive'][0] == 1
assert ns.limits['nlive'][1] == 125
# limits for derived parameters:
ns['x5'] = ns.x0 + ns.x1
assert 'x5' in ns.columns and 'x5' not in ns.limits
ns.plot_1d(['x5'])
assert 'x5' in ns.columns and 'x5' in ns.limits
ns['x6'] = ns.x2 + ns.x3
assert 'x6' in ns.columns and 'x6' not in ns.limits
ns.plot_2d(['x5', 'x6'])
assert 'x6' in ns.columns and 'x6' in ns.limits


def test_xmin_xmax_1d():
Expand Down

0 comments on commit 82f6b37

Please sign in to comment.