Skip to content

Commit

Permalink
more tests on q_source
Browse files Browse the repository at this point in the history
  • Loading branch information
rpoleski committed May 2, 2024
1 parent 18be9b3 commit 616fb34
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
23 changes: 19 additions & 4 deletions source/MulensModel/modelparameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,13 +480,28 @@ def _divide_parameters(self, parameters):
parameters_2[key] = value

if self.n_sources == 2 and self._type['xallarap']:
if parameters['q_source'] < 0.:
raise ValueError('q_source cannot be negative')
parameters_2['xi_semimajor_axis'] /= parameters['q_source']
parameters_2['xi_argument_of_latitude_reference'] += 180.
self._set_changed_parameters_2nd_source(parameters['q_source'],
parameters_2)

return (parameters_1, parameters_2)

def _set_changed_parameters_2nd_source(self, q_source, parameters_2):
"""
For xallarap model with 2 sources, the orbit of the second source
must have 2 parameters changed.
Functions starts with tests of input
"""
if q_source <= 0.:
raise ValueError('q_source cannot be negative')

check_keys = ['xi_semimajor_axis', 'xi_argument_of_latitude_reference']
for key in check_keys:
if key not in parameters_2:
raise KeyError('xallarap model with 2 sources requires ' + key)

parameters_2['xi_semimajor_axis'] /= q_source
parameters_2['xi_argument_of_latitude_reference'] += 180.

def __repr__(self):
"""A nice way to represent a ModelParameters object as a string"""
out = self._get_main_parameters_to_print()
Expand Down
7 changes: 7 additions & 0 deletions source/MulensModel/tests/test_ModelParameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,13 @@ def test_no_q_source_but_with_rho_2(self):
with self.assertRaises(KeyError):
mm.ModelParameters(parameters)

def test_PSPL_and_q_source(self):
"""
Make sure one cannot provide only PSPL parameters and q_source.
"""
with self.assertRaises(KeyError):
mm.ModelParameters({'t_0': 1, 'u_0': 2, 't_E': 3, 'q_source': 1})


def test_print_xallarap():
"""
Expand Down

0 comments on commit 616fb34

Please sign in to comment.