Coverage for tests/test_statisticsOverloads.py : 94%
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 # Copyright 2008, 2009, 2010 LSST Corporation. # # 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 <http://www.lsstcorp.org/LegalNotices/>. #
Tests for Statistics
Run with: ./statisticsOverloads.py or python >>> import statisticsOverloads; statisticsOverloads.run() """
"""A test case to check all overloaded makeStatistics() factories for Statistics"""
# Integers lsst.geom.Extent2I(self.nRow, self.nCol)) lsst.geom.Extent2I(self.nRow, self.nCol), self.val) # TODO: pybind11, this should probably be ndarray
# floats lsst.geom.Extent2I(self.nRow, self.nCol)) lsst.geom.Extent2I(self.nRow, self.nCol), self.val) # TODO: pybind11, this should probably be ndarray
# doubles lsst.geom.Extent2I(self.nRow, self.nCol)) lsst.geom.Extent2I(self.nRow, self.nCol), self.val) # TODO: pybind11, this should probably be ndarray
# The guts of the testing: grab a mean, stddev, and sum for whatever # you're called with afwMath.MEAN | afwMath.SUM, self.sctrl)
stats.getValue(afwMath.SUM))
# same as compareMakeStatistics but calls constructor directly (only for # masked image) self.assertEqual(stats.getValue(afwMath.NPOINT), n) self.assertEqual(stats.getValue(afwMath.NPOINT)*stats.getValue(afwMath.MEAN), stats.getValue(afwMath.SUM)) self.assertEqual(stats.getValue(afwMath.MEAN), self.val) self.assertEqual(stats.getValue(afwMath.STDEV), 0)
# Test regular image::Image
# Test the image::MaskedImages
# Test the std::vectors
"""Test std::vector, but with weights"""
afwMath.NPOINT | afwMath.STDEV | afwMath.MEAN | afwMath.SUM, sctrl)
0.5*weight*sum(vec)/stats.getValue(afwMath.SUM), 1.0) sum(vec)/len(vec), stats.getValue(afwMath.MEAN))
# Try calling the Statistics constructor directly statsI = afwMath.StatisticsI(self.mimgI.getImage(), self.mimgI.getMask(), afwMath.NPOINT | afwMath.STDEV | afwMath.MEAN | afwMath.SUM, self.sctrl) statsF = afwMath.StatisticsF(self.mimgF.getImage(), self.mimgF.getMask(), afwMath.NPOINT | afwMath.STDEV | afwMath.MEAN | afwMath.SUM, self.sctrl) statsD = afwMath.StatisticsD(self.mimgD.getImage(), self.mimgD.getMask(), afwMath.NPOINT | afwMath.STDEV | afwMath.MEAN | afwMath.SUM, self.sctrl)
self.compareStatistics( statsI, self.mimgI.getWidth()*self.mimgI.getHeight()) self.compareStatistics( statsF, self.mimgF.getWidth()*self.mimgF.getHeight()) self.compareStatistics( statsD, self.mimgD.getWidth()*self.mimgD.getHeight())
# Test the Mask specialization
stats.getValue(afwMath.NPOINT))
lsst.utils.tests.init() unittest.main() |