Coverage for tests/test_Interval1d.py : 23%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# # LSST Data Management System # See COPYRIGHT file at the top of the source tree. # # This product includes software developed by the # LSST Project (http://www.lsst.org/). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the LSST License Statement and # the GNU General Public License along with this program. If not, # see <https://www.lsstcorp.org/LegalNotices/>. #
i = Interval1d(1) self.assertEqual(i.getA(), i.getB()) self.assertEqual(i.getA(), 1) i = Interval1d(1, 2) self.assertEqual(i, Interval1d(1, 2)) self.assertTrue(Interval1d.empty().isEmpty())
self.assertEqual(Interval1d(1), Interval1d(1, 1)) self.assertEqual(Interval1d(1), 1) self.assertNotEqual(Interval1d(1, 1), Interval1d(2, 2)) self.assertNotEqual(Interval1d(2, 2), 1)
i = Interval1d(1, 2) self.assertEqual(i.getSize(), 1) self.assertEqual(i.getCenter(), 1.5)
i02 = Interval1d(0, 2) i13 = Interval1d(1, 3) i46 = Interval1d(4, 6) i06 = Interval1d(0, 6) self.assertTrue(i02.contains(1)) self.assertTrue(i02.contains(Interval1d(0.5, 1.5))) self.assertTrue(i02.isDisjointFrom(3)) self.assertTrue(i02.isDisjointFrom(i46)) self.assertTrue(i02.intersects(1)) self.assertTrue(i02.intersects(i13)) self.assertTrue(Interval1d(1, 1).isWithin(i02)) self.assertTrue(i02.isWithin(i06)) r = i02.relate(1) self.assertEqual(r, CONTAINS) r = i46.relate(i02) self.assertEqual(r, DISJOINT)
a = Interval1d(1, 2) b = ( a.expandedTo(3) .expandedTo(Interval1d(2, 4)) .clippedTo(Interval1d(0, 2)) .clippedTo(1) ) a.expandTo(3).expandTo(Interval1d(2, 4)) a.clipTo(Interval1d(0, 2)).clipTo(1) self.assertEqual(a, b) self.assertEqual(a, 1)
a = Interval1d(1, 3) b = a.dilatedBy(1).erodedBy(2) a.dilateBy(1).erodeBy(2) self.assertEqual(a, b) self.assertEqual(a, 2)
i = Interval1d(1, 2) self.assertEqual(str(i), '[1.0, 2.0]') self.assertEqual(repr(i), 'Interval1d(1.0, 2.0)') self.assertEqual(i, eval(repr(i), dict(Interval1d=Interval1d)))
a = Interval1d(1.5, 3.5) b = pickle.loads(pickle.dumps(a)) self.assertEqual(a, b)
unittest.main() |