def test_constructor_with_many_point_sources(): # Test with 200 point sources many_p_sources = map(lambda x:_get_point_source("pts_source%i" %x), range(200)) m = Model(*many_p_sources) assert m.get_number_of_point_sources()==200
def test_constructor_with_many_extended_sources(): # Test with one extended source ext = _get_extended_source() _ = Model(ext) # Test with 200 extended sources many_e_sources = map(lambda x: _get_extended_source("ext_source%i" %x), range(200)) m = Model(*many_e_sources) assert m.get_number_of_extended_sources() == 200
def test_default_constructor(): # Test that we cannot build a model with no sources with pytest.raises(AssertionError): _ = Model()
def test_constructor_with_mix(): many_p_sources = map(lambda x: _get_point_source("pts_source%i" % x), range(200)) many_e_sources = map(lambda x: _get_extended_source("ext_source%i" % x), range(200)) many_part_sources = map(lambda x: _get_particle_source("part_source%i" % x), range(200)) all_sources = [] all_sources.extend(many_p_sources) all_sources.extend(many_e_sources) all_sources.extend(many_part_sources) m = Model(*all_sources) assert m.get_number_of_point_sources() == 200 assert m.get_number_of_extended_sources() == 200 assert m.get_number_of_particle_sources() == 200
def test_constructor_1source(): # Test with one point source pts = _get_point_source() m = Model(pts) # Test with a point source with an invalid name pts = PointSource("name", 0, 0, Powerlaw()) with pytest.raises(InvalidInput): _ = Model(pts) # Test with two identical point sources, which should raise, as sources must have unique names many_sources = [pts] * 2 with pytest.raises(InvalidInput): _ = Model(*many_sources)
def __init__(self): # 2 point sources and 3 ext sources pts1 = _get_point_source("one") # 5 params, 2 free pts2 = _get_point_source("two") ext1 = _get_extended_source("ext_one") # 6 params, 5 free ext2 = _get_extended_source("ext_two") ext3 = _get_extended_source("ext_three") # Two particle sources part1 = _get_particle_source("part_one") part2 = _get_particle_source("part_two") self._m = Model(pts1, pts2, ext1, ext2, ext3, part1, part2)