Coverage for tests / test_observationconfig.py: 29%
35 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-26 08:58 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-26 08:58 +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 lsst.gauss2d as g2
22import lsst.gauss2d.fit as g2f
23from lsst.multiprofit.observationconfig import CoordinateSystemConfig, ObservationConfig
24import pytest
27@pytest.fixture(scope="module")
28def kwargs_coordsys():
29 return {
30 "dx1": 0.4,
31 "dy2": 1.6,
32 "x_min": -51.3,
33 "y_min": 1684.5,
34 }
37@pytest.fixture(scope="module")
38def config_coordsys(kwargs_coordsys) -> CoordinateSystemConfig:
39 return CoordinateSystemConfig(**kwargs_coordsys)
42@pytest.fixture(scope="module")
43def coordsys(config_coordsys) -> g2.CoordinateSystem:
44 return config_coordsys.make_coordinate_system()
47def test_CoordinateSystemConfig(kwargs_coordsys, coordsys):
48 for kwarg, value in kwargs_coordsys.items():
49 assert getattr(coordsys, kwarg) == value
52def test_ObservationConfig():
53 n_cols, n_rows = 15, 17
54 shape = [n_rows, n_cols]
55 config = ObservationConfig(n_cols=n_cols, n_rows=n_rows)
56 observation = config.make_observation()
57 assert observation.channel == g2f.Channel.NONE
58 planes = ("image", "mask_inv", "sigma_inv")
59 for plane in planes:
60 attr = getattr(observation, plane)
61 assert attr.shape == shape
62 config.band = "red"
63 observation2 = config.make_observation()
64 assert observation2.channel == g2f.Channel.get("red")
65 for plane in planes:
66 attr1, attr2 = (getattr(obs, plane) for obs in (observation, observation2))
67 assert attr1 is not attr2
68 # Initialize both images; comparison checks equality
69 attr1.fill(0)
70 attr2.fill(0)
71 assert attr1 == attr2