Coverage for tests/test_RBTransiNetInterface.py: 35%
18 statements
« prev ^ index » next coverage.py v7.3.0, created at 2023-09-01 09:59 +0000
« prev ^ index » next coverage.py v7.3.0, created at 2023-09-01 09:59 +0000
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 RBTransiNetInterface, CutoutInputs
29class TestInference(unittest.TestCase):
30 def setUp(self):
31 self.interface = RBTransiNetInterface("dummy", "local")
33 def test_infer_single_empty(self):
34 """Test running infer on a single blank triplet.
35 """
36 data = np.zeros((256, 256), dtype=np.single)
37 inputs = CutoutInputs(science=data, difference=data, template=data)
38 result = self.interface.infer([inputs])
39 self.assertTupleEqual(result.shape, (1,))
40 self.assertAlmostEqual(result[0], 0.5011908) # Empricial meaningless value spit by this very model
42 def test_infer_many(self):
43 """Test running infer on a large number of images,
44 to make sure partitioning to batches works.
45 """
46 data = np.zeros((256, 256), dtype=np.single)
47 inputs = [CutoutInputs(science=data, difference=data, template=data) for _ in range(100)]
48 result = self.interface.infer(inputs)
49 self.assertTupleEqual(result.shape, (100,))
50 self.assertAlmostEqual(result[0], 0.5011908)