Skip to content

Commit

Permalink
Rename lsst.afw.image components to use underscores in sub packages
Browse files Browse the repository at this point in the history
All these classes are lifted directly into lsst.afw.image and
so should not also be public in the child packages.
This leads to exposure, apCorrMap, basicUtils, image
and maskedImage all being replaced with leading underscores.
  • Loading branch information
timj committed Apr 13, 2023
1 parent 7304ef7 commit 877f219
Show file tree
Hide file tree
Showing 33 changed files with 63 additions and 60 deletions.
7 changes: 5 additions & 2 deletions python/lsst/afw/detection/multiband.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@

from lsst.geom import Point2I
from lsst.afw.geom import SpanSet
from lsst.afw.image.image import Mask, Image, MultibandImage, MultibandMaskedImage
from lsst.afw.image.maskedImage import MaskedImage

# Need to use the private name of the package for imports here because
# lsst.afw.image itself imports lsst.afw.detection
from lsst.afw.image._image import Mask, Image, MultibandImage, MultibandMaskedImage
from lsst.afw.image._maskedImage import MaskedImage

from lsst.afw.multiband import MultibandBase
from . import Footprint, makeHeavyFootprint
Expand Down
10 changes: 5 additions & 5 deletions python/lsst/afw/image/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from ._imageLib import *
from . import pixel
from .image import *
from .apCorrMap import *
from .maskedImage import *
from ._image import *
from ._apCorrMap import *
from ._maskedImage import *
from ._visitInfo import * # just here to support deprecation
from .exposure import *
from ._exposure import *
from ._exposureInfoContinued import *
from ._exposureSummaryStats import *
from .basicUtils import *
from ._basicUtils import *
from .testUtils import *
from ._photoCalibContinued import *
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void wrapApCorrMap(lsst::utils::python::WrapperCollection &wrappers) {
}

PYBIND11_MODULE(_apCorrMap, mod) {
lsst::utils::python::WrapperCollection wrappers(mod, "lsst.afw.image.apCorrMap");
lsst::utils::python::WrapperCollection wrappers(mod, "lsst.afw.image._apCorrMap");
wrappers.addInheritanceDependency("lsst.afw.table.io");
wrappers.addInheritanceDependency("lsst.afw.typehandling");
wrapApCorrMap(wrappers);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

__all__ = ["makeImageFromArray", "makeMaskFromArray", "makeMaskedImageFromArrays"]

from .image import Image, Mask
from .maskedImage import MaskedImage
from ._image import Image, Mask
from ._maskedImage import MaskedImage


def makeImageFromArray(array):
Expand Down
File renamed without changes.
24 changes: 24 additions & 0 deletions python/lsst/afw/image/_exposure/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# This file is part of afw.
#
# Developed for the LSST Data Management System.
# This product includes software developed by the LSST Project
# (https://www.lsst.org).
# See the COPYRIGHT file at the top-level directory of this distribution
# for details of code ownership.
#
# 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 GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

from ._exposure import *
from ._exposureContinued import *
from ._multiband import *
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,11 @@ PyExposure<PixelT> declareExposure(lsst::utils::python::WrapperCollection &wrapp
}
} // namespace
PYBIND11_MODULE(_exposure, mod) {
lsst::utils::python::WrapperCollection wrappers(mod, "lsst.afw.image.exposure");
wrappers.addSignatureDependency("lsst.afw.image.apCorrMap");
lsst::utils::python::WrapperCollection wrappers(mod, "lsst.afw.image._exposure");
wrappers.addSignatureDependency("lsst.afw.image._apCorrMap");
wrappers.addSignatureDependency("lsst.afw.geom");
wrappers.addSignatureDependency("lsst.afw.detection");
wrappers.addSignatureDependency("lsst.afw.image.maskedImage");
wrappers.addSignatureDependency("lsst.afw.image._maskedImage");

auto clsExposureF = declareExposure<float>(wrappers, "F");
auto clsExposureD = declareExposure<double>(wrappers, "D");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@

from lsst.utils import TemplateMeta

from ..image._slicing import supportSlicing
from ..image._disableArithmetic import disableImageArithmetic
from ..image._fitsIoWithOptions import imageReadFitsWithOptions, exposureWriteFitsWithOptions
from .._image._slicing import supportSlicing
from .._image._disableArithmetic import disableImageArithmetic
from .._image._fitsIoWithOptions import imageReadFitsWithOptions, exposureWriteFitsWithOptions
from ._exposure import ExposureI, ExposureF, ExposureD, ExposureU, ExposureL
from .exposureUtils import bbox_to_convex_polygon, bbox_contains_sky_coords
from ..exposure.exposureUtils import bbox_to_convex_polygon, bbox_contains_sky_coords


class Exposure(metaclass=TemplateMeta):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
from lsst.pex.exceptions import InvalidParameterError
from . import Exposure, ExposureF
from ..utils import projectImage
from ..image._multiband import MultibandTripleBase, MultibandPixel
from ..image._multiband import tripleFromSingles, tripleFromArrays, makeTripleFromKwargs
from ..maskedImage import MaskedImage
from .._image._multiband import MultibandTripleBase, MultibandPixel
from .._image._multiband import tripleFromSingles, tripleFromArrays, makeTripleFromKwargs
from .._maskedImage import MaskedImage


class IncompleteDataError(Exception):
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void wrapImage(lsst::utils::python::WrapperCollection &);
void wrapImageSlice(lsst::utils::python::WrapperCollection &);

PYBIND11_MODULE(_imageLib, mod) {
lsst::utils::python::WrapperCollection wrappers(mod, "lsst.afw.image.image");
lsst::utils::python::WrapperCollection wrappers(mod, "lsst.afw.image._image");
wrapImage(wrappers);
wrapImageSlice(wrappers);
wrappers.finish();
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

from lsst.geom import Point2I, Box2I, Extent2I
from . import Image, ImageF, Mask, MaskPixel, PARENT, LOCAL
from ..maskedImage import MaskedImage, MaskedImageF
from .._maskedImage import MaskedImage, MaskedImageF
from ._slicing import imageIndicesToNumpy
from ...multiband import MultibandBase

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ void declareImagesOverlap(lsst::utils::python::WrapperCollection &wrappers) {
} // namespace

PYBIND11_MODULE(_maskedImage, mod) {
lsst::utils::python::WrapperCollection wrappers(mod, "lsst.afw.image.maskedImage");
wrappers.addSignatureDependency("lsst.afw.image.image");
lsst::utils::python::WrapperCollection wrappers(mod, "lsst.afw.image._maskedImage");
wrappers.addSignatureDependency("lsst.afw.image._image");
wrappers.addInheritanceDependency("lsst.daf.base");

auto clsMaskedImageF = declareMaskedImage<float>(wrappers, "F");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
from lsst.utils import TemplateMeta
from ._maskedImage import MaskedImageI, MaskedImageF, MaskedImageD, MaskedImageU, MaskedImageL

from ..image._fitsIoWithOptions import imageReadFitsWithOptions, exposureWriteFitsWithOptions
from ..image._slicing import supportSlicing
from ..image._disableArithmetic import disableImageArithmetic
from .._image._fitsIoWithOptions import imageReadFitsWithOptions, exposureWriteFitsWithOptions
from .._image._slicing import supportSlicing
from .._image._disableArithmetic import disableImageArithmetic

__all__ = ["MaskedImage", "VariancePixel"]

Expand Down
6 changes: 3 additions & 3 deletions python/lsst/afw/image/_readers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,9 @@ void declareExposureFitsReader(lsst::utils::python::WrapperCollection &wrappers)
void wrapReaders(lsst::utils::python::WrapperCollection &wrappers) {
// wrappers.addInheritanceDependency("lsst.daf.base");
wrappers.addSignatureDependency("lsst.geom");
wrappers.addSignatureDependency("lsst.afw.image.image");
wrappers.addSignatureDependency("lsst.afw.image.maskedImage");
wrappers.addSignatureDependency("lsst.afw.image.exposure");
wrappers.addSignatureDependency("lsst.afw.image._image");
wrappers.addSignatureDependency("lsst.afw.image._maskedImage");
wrappers.addSignatureDependency("lsst.afw.image._exposure");
declareImageFitsReader(wrappers);
declareMaskFitsReader(wrappers);
declareMaskedImageFitsReader(wrappers);
Expand Down
24 changes: 0 additions & 24 deletions python/lsst/afw/image/exposure/__init__.py
Original file line number Diff line number Diff line change
@@ -1,24 +0,0 @@
# This file is part of afw.
#
# Developed for the LSST Data Management System.
# This product includes software developed by the LSST Project
# (https://www.lsst.org).
# See the COPYRIGHT file at the top-level directory of this distribution
# for details of code ownership.
#
# 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 GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

from ._exposure import *
from ._exposureContinued import *
from ._multiband import *
4 changes: 2 additions & 2 deletions python/lsst/afw/image/testUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
import numpy as np

import lsst.utils.tests
from .image import ImageF
from .basicUtils import makeMaskedImageFromArrays
from ._image import ImageF
from ._basicUtils import makeMaskedImageFromArrays


def makeGaussianNoiseMaskedImage(dimensions, sigma, variance=1.0):
Expand Down
4 changes: 2 additions & 2 deletions python/lsst/afw/image/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
__all__ = ["clipImage", "projectImage", "getProjectionIndices"]

import lsst.afw.detection as afwDetect
from .maskedImage import MaskedImage, makeMaskedImage
from .image import Mask
from ._maskedImage import MaskedImage, makeMaskedImage
from ._image import Mask


def clipImage(im, minClip, maxClip):
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/afw/math/_background.cc
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ void declareBackground(lsst::utils::python::WrapperCollection &wrappers) {
}
void wrapBackground(lsst::utils::python::WrapperCollection &wrappers) {
// FIXME: review when lsst.afw.image is converted to python wrappers
wrappers.addInheritanceDependency("lsst.afw.image.image");
wrappers.addInheritanceDependency("lsst.afw.image");
declareBackground(wrappers);
declareMakeBackground<image::Image<float>>(wrappers);
declareMakeBackground<image::MaskedImage<float>>(wrappers);
Expand Down
2 changes: 1 addition & 1 deletion tests/test_photoCalib.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ def setupImage(self):
image = np.random.normal(loc=1000.0, scale=sigma, size=npDim).astype(np.float32)
mask = np.zeros(npDim, dtype=np.int32)
variance = (np.random.normal(loc=0.0, scale=sigma, size=npDim).astype(np.float32))**2
maskedImage = lsst.afw.image.basicUtils.makeMaskedImageFromArrays(image, mask, variance)
maskedImage = lsst.afw.image.makeMaskedImageFromArrays(image, mask, variance)
maskedImage.mask[0, 0] = True # set one mask bit to check propagation of mask bits.

return npDim, maskedImage, image, mask, variance
Expand Down

0 comments on commit 877f219

Please sign in to comment.