Skip to content

Commit

Permalink
Create empty image when ctor is called with None
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Wittgen authored and Matthias Wittgen committed Oct 15, 2024
1 parent b167e1a commit b0e6a9e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/image/MaskedImage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* Implementation for MaskedImage
*/
#include <cstdint>
#include <stdexcept>

#include "boost/format.hpp"
#include "lsst/log/Log.h"
Expand Down Expand Up @@ -148,7 +149,8 @@ MaskedImage<ImagePixelT, MaskPixelT, VariancePixelT>::MaskedImage(
template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
MaskedImage<ImagePixelT, MaskPixelT, VariancePixelT>::MaskedImage(ImagePtr image, MaskPtr mask,
VariancePtr variance)
: _image(image), _mask(mask), _variance(variance) {
: _image(image != nullptr ? image : std::make_shared<Image>()),
_mask(mask), _variance(variance) {
conformSizes();
}

Expand Down
6 changes: 6 additions & 0 deletions tests/test_maskedImage.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,12 @@ def testTicket653(self):
mi = afwImage.MaskedImageF(im)
afwImage.ExposureF(mi)

def testTicket41478(self):
"""Test for DM-41478 fix"""
masked_image = afwImage.MaskedImageF(None)
image = afwImage.ImageF(None)
self.assertEqual(masked_image.getBBox(), image.getBBox())

def testMaskedImageInitialisation(self):
dims = self.mimage.getDimensions()
factory = self.mimage.Factory
Expand Down

0 comments on commit b0e6a9e

Please sign in to comment.