Coverage for tests/test_observationconfig.py: 100%

35 statements  

« prev     ^ index     » next       coverage.py v7.16.1, created at 2026-09-23 09:54 +0000

1# This file is part of multiprofit. 

2# 

3# Developed for the LSST Data Management System. 

4# This product includes software developed by the LSST Project 

5# (https://www.lsst.org). 

6# See the COPYRIGHT file at the top-level directory of this distribution 

7# for details of code ownership. 

8# 

9# This program is free software: you can redistribute it and/or modify 

10# it under the terms of the GNU General Public License as published by 

11# the Free Software Foundation, either version 3 of the License, or 

12# (at your option) any later version. 

13# 

14# This program is distributed in the hope that it will be useful, 

15# but WITHOUT ANY WARRANTY; without even the implied warranty of 

16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

17# GNU General Public License for more details. 

18# 

19# You should have received a copy of the GNU General Public License 

20# along with this program. If not, see <https://www.gnu.org/licenses/>. 

21import pytest 

22 

23import lsst.gauss2d as g2 

24import lsst.gauss2d.fit as g2f 

25from lsst.multiprofit.observationconfig import CoordinateSystemConfig, ObservationConfig 

26 

27 

28@pytest.fixture(scope="module") 

29def kwargs_coordsys(): 

30 """Return kwargs for a coordinate system config.""" 

31 return { 

32 "dx1": 0.4, 

33 "dy2": 1.6, 

34 "x_min": -51.3, 

35 "y_min": 1684.5, 

36 } 

37 

38 

39@pytest.fixture(scope="module") 

40def config_coordsys(kwargs_coordsys) -> CoordinateSystemConfig: 

41 """Return a coordinate system config.""" 

42 return CoordinateSystemConfig(**kwargs_coordsys) 

43 

44 

45@pytest.fixture(scope="module") 

46def coordsys(config_coordsys) -> g2.CoordinateSystem: 

47 """Return a configured coordinate system.""" 

48 return config_coordsys.make_coordinate_system() 

49 

50 

51def test_CoordinateSystemConfig(kwargs_coordsys, coordsys): 

52 """Test that the configured coordinate system matches its kwargs.""" 

53 for kwarg, value in kwargs_coordsys.items(): 

54 assert getattr(coordsys, kwarg) == value 

55 

56 

57def test_ObservationConfig(): 

58 """Test that Observation configs work correctly.""" 

59 n_cols, n_rows = 15, 17 

60 shape = [n_rows, n_cols] 

61 config = ObservationConfig(n_cols=n_cols, n_rows=n_rows) 

62 observation = config.make_observation() 

63 assert observation.channel == g2f.Channel.NONE 

64 planes = ("image", "mask_inv", "sigma_inv") 

65 for plane in planes: 

66 attr = getattr(observation, plane) 

67 assert attr.shape == shape 

68 config.band = "red" 

69 observation2 = config.make_observation() 

70 assert observation2.channel == g2f.Channel.get("red") 

71 for plane in planes: 

72 attr1, attr2 = (getattr(obs, plane) for obs in (observation, observation2)) 

73 assert attr1 is not attr2 

74 # Initialize both images; comparison checks equality 

75 attr1.fill(0) 

76 attr2.fill(0) 

77 assert attr1 == attr2