diff --git a/source/MulensModel/modelparameters.py b/source/MulensModel/modelparameters.py index 651e8da6..8c2f3553 100644 --- a/source/MulensModel/modelparameters.py +++ b/source/MulensModel/modelparameters.py @@ -975,7 +975,7 @@ def t_E(self): return self.t_star / self.rho elif ('t_eff' in self.parameters.keys() and 'u_0' in self.parameters.keys()): - return self.t_eff / self.u_0 + return self.t_eff / abs(self.u_0) else: raise KeyError("You're trying to access t_E that was not set") diff --git a/source/MulensModel/tests/test_ModelParameters.py b/source/MulensModel/tests/test_ModelParameters.py index 739dcdc5..8d9e9733 100644 --- a/source/MulensModel/tests/test_ModelParameters.py +++ b/source/MulensModel/tests/test_ModelParameters.py @@ -135,6 +135,19 @@ def test_repr_t_0_kep(): assert (out_1 + out_2) == str(params) +def test_positive_t_E(): + """ + Check if t_E is positive when t_eff is given, even if u_0 is negative. + """ + t_0 = 10205.1 + u_0 = -0.50 + t_eff = 12.5 + params = mm.ModelParameters({'t_0': t_0, 'u_0': u_0, 't_eff': t_eff}) + + assert params.t_E >= 0. + assert params.t_E == params.t_eff / abs(params.u_0) + + def test_rho_t_e_t_star(): """check if conversions between rho, t_E, and t_star work ok""" t_0 = 2450000. diff --git a/source/MulensModel/version.py b/source/MulensModel/version.py index 6ebac24f..68a0e512 100644 --- a/source/MulensModel/version.py +++ b/source/MulensModel/version.py @@ -1 +1 @@ -__version__ = "2.18.0" +__version__ = "2.18.1"