Coverage for tests/test_RBTransiNetInterface.py: 32%
23 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-03-23 03:57 -0700
« prev ^ index » next coverage.py v7.4.4, created at 2024-03-23 03:57 -0700
1# This file is part of meas_transiNet.
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/>.
22import unittest
24import numpy as np
26from lsst.meas.transiNet import RBTransiNetTask
27from lsst.meas.transiNet import RBTransiNetInterface, CutoutInputs
30class TestInference(unittest.TestCase):
31 def setUp(self):
33 # Create a mock TransiNetTask.
34 config = RBTransiNetTask.ConfigClass()
35 config.modelPackageName = "dummy"
36 config.modelPackageStorageMode = "local"
37 self.task = RBTransiNetTask(config=config)
38 self.interface = RBTransiNetInterface(self.task)
40 def test_infer_single_empty(self):
41 """Test running infer on a single blank triplet.
42 """
43 data = np.zeros((256, 256), dtype=np.single)
44 inputs = CutoutInputs(science=data, difference=data, template=data)
45 result = self.interface.infer([inputs])
46 self.assertTupleEqual(result.shape, (1,))
47 self.assertAlmostEqual(result[0], 0.5011908) # Empricial meaningless value spit by this very model
49 def test_infer_many(self):
50 """Test running infer on a large number of images,
51 to make sure partitioning to batches works.
52 """
53 data = np.zeros((256, 256), dtype=np.single)
54 inputs = [CutoutInputs(science=data, difference=data, template=data) for _ in range(100)]
55 result = self.interface.infer(inputs)
56 self.assertTupleEqual(result.shape, (100,))
57 self.assertAlmostEqual(result[0], 0.5011908)