diff --git a/anesthetic/samples.py b/anesthetic/samples.py index 05743ea7..5523b5f5 100644 --- a/anesthetic/samples.py +++ b/anesthetic/samples.py @@ -93,6 +93,7 @@ def __init__(self, *args, **kwargs): logzero = kwargs.pop('logzero', -1e30) logL = kwargs.pop('logL', None) if logL is not None: + logL = np.array(logL) logL = np.where(logL <= logzero, -np.inf, logL) self.tex = kwargs.pop('tex', {}) self.limits = kwargs.pop('limits', {}) @@ -487,6 +488,7 @@ def __init__(self, *args, **kwargs): self._beta = kwargs.pop('beta', 1.) logL_birth = kwargs.pop('logL_birth', None) if not isinstance(logL_birth, int) and logL_birth is not None: + logL_birth = np.array(logL_birth) logL_birth = np.where(logL_birth <= logzero, -np.inf, logL_birth) diff --git a/tests/test_samples.py b/tests/test_samples.py index 4f956cf0..9cc8c558 100644 --- a/tests/test_samples.py +++ b/tests/test_samples.py @@ -885,3 +885,14 @@ def test_plotting_with_integer_names(): assert_array_equal(samples_1.loc[:, 0], samples_1.iloc[:, 0]) with pytest.raises(KeyError): samples_1['0'] + + +def test_logL_list(): + np.random.seed(5) + default = NestedSamples(root='./tests/example_data/pc') + logL = default.logL.tolist() + logL_birth = default.logL_birth.tolist() + data = default.iloc[:, :5].to_numpy().tolist() + + samples = NestedSamples(data=data, logL=logL, logL_birth=logL_birth) + assert_array_equal(default, samples)