diff --git a/mypy.ini b/mypy.ini index 2ca3e7f7..1f77553f 100644 --- a/mypy.ini +++ b/mypy.ini @@ -94,6 +94,3 @@ warn_unreachable = False warn_unused_ignores = False allow_untyped_globals = True allow_redefinition = True - -[mypy-lsst.summit.utils.version] -ignore_missing_imports = True diff --git a/pyproject.toml b/pyproject.toml index 2f7371b5..643eb3f1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,3 +6,6 @@ known_first_party = ["lsst", "tests"] [tool.black] line-length = 110 target-version = ["py311"] + +[tool.lsst_versions] +write_to = "python/lsst/summit/utils/version.py" diff --git a/python/lsst/summit/utils/imageExaminer.py b/python/lsst/summit/utils/imageExaminer.py index a343fada..5ded21d8 100644 --- a/python/lsst/summit/utils/imageExaminer.py +++ b/python/lsst/summit/utils/imageExaminer.py @@ -47,8 +47,8 @@ def gauss( - x: float | npt.NDArray[np.float_], a: float, x0: float, sigma: float -) -> float | npt.NDArray[np.float_]: + x: float | npt.NDArray[np.float64], a: float, x0: float, sigma: float +) -> float | npt.NDArray[np.float64]: return a * np.exp(-((x - x0) ** 2) / (2 * sigma**2)) @@ -312,7 +312,7 @@ def _calcBbox(self, centroid: tuple[float, float]) -> geom.Box2I: return bbox - def getStarBoxData(self) -> npt.NDArray[np.float_]: + def getStarBoxData(self) -> npt.NDArray[np.float64]: """Get the image data for the star. Calculates the maximum valid box, and uses that to return the image @@ -330,8 +330,8 @@ def getStarBoxData(self) -> npt.NDArray[np.float_]: return self.exp.image[bbox].array def getMeshGrid( - self, data: npt.NDArray[np.float_] - ) -> tuple[npt.NDArray[np.float_], npt.NDArray[np.float_]]: + self, data: npt.NDArray[np.float64] + ) -> tuple[npt.NDArray[np.float64], npt.NDArray[np.float64]]: """Get the meshgrid for a data array. Parameters diff --git a/python/lsst/summit/utils/peekExposure.py b/python/lsst/summit/utils/peekExposure.py index a41115ef..0a0b6fed 100644 --- a/python/lsst/summit/utils/peekExposure.py +++ b/python/lsst/summit/utils/peekExposure.py @@ -53,7 +53,7 @@ IDX_SENTINEL = -99999 -def _estimateMode(data: npt.NDArray[np.float_], frac: float = 0.5) -> float: +def _estimateMode(data: npt.NDArray[np.float64], frac: float = 0.5) -> float: """Estimate the mode of a 1d distribution. Finds the smallest interval containing the fraction ``frac`` of the data, diff --git a/python/lsst/summit/utils/spectrumExaminer.py b/python/lsst/summit/utils/spectrumExaminer.py index 97172d43..2e6f0895 100644 --- a/python/lsst/summit/utils/spectrumExaminer.py +++ b/python/lsst/summit/utils/spectrumExaminer.py @@ -131,8 +131,8 @@ def calcGoodSpectrumSection(self, threshold: int = 5, windowSize: int = 5) -> tu def fit(self) -> None: def gauss( - x: float | npt.NDArray[np.float_], a: float, x0: float, sigma: float - ) -> float | npt.NDArray[np.float_]: + x: float | npt.NDArray[np.float64], a: float, x0: float, sigma: float + ) -> float | npt.NDArray[np.float64]: return a * np.exp(-((x - x0) ** 2) / (2 * sigma**2)) data = self.spectrumData[self.goodSlice] diff --git a/python/lsst/summit/utils/utils.py b/python/lsst/summit/utils/utils.py index 3c8e162b..995555a8 100644 --- a/python/lsst/summit/utils/utils.py +++ b/python/lsst/summit/utils/utils.py @@ -127,7 +127,7 @@ def countPixels(maskedImage: afwImage.MaskedImage, maskPlane: str) -> int: return len(np.where(np.bitwise_and(maskedImage.mask.array, bit))[0]) -def quickSmooth(data: npt.NDArray[np.float_], sigma: float = 2) -> npt.NDArray[np.float_]: +def quickSmooth(data: npt.NDArray[np.float64], sigma: float = 2) -> npt.NDArray[np.float64]: """Perform a quick smoothing of the image. Not to be used for scientific purposes, but improves the stretch and @@ -150,7 +150,7 @@ def quickSmooth(data: npt.NDArray[np.float_], sigma: float = 2) -> npt.NDArray[n return smoothData -def argMax2d(array: npt.NDArray[np.float_]) -> tuple[tuple[float, float], bool, list[tuple[float, float]]]: +def argMax2d(array: npt.NDArray[np.float64]) -> tuple[tuple[float, float], bool, list[tuple[float, float]]]: """Get the index of the max value of an array and whether it's unique. If its not unique, returns a list of the other locations containing the @@ -339,7 +339,7 @@ def fluxesFromFootprints( footprints: afwDetect.FootprintSet | afwDetect.Footprint | Iterable[afwDetect.Footprint], parentImage: afwImage.Image, subtractImageMedian: bool = False, -) -> npt.NDArray[np.float_]: +) -> npt.NDArray[np.float64]: """Calculate the flux from a set of footprints, given the parent image, optionally subtracting the whole-image median from each pixel as a very rough background subtraction. @@ -1052,7 +1052,7 @@ def getCdf(data: np.ndarray, scale: int, nBinsMax: int = 300_000) -> tuple[np.nd return cdf, minVal, maxVal -def getQuantiles(data: npt.NDArray[np.float_], nColors: int) -> npt.NDArray[np.float_]: +def getQuantiles(data: npt.NDArray[np.float64], nColors: int) -> npt.NDArray[np.float64]: """Get a set of boundaries that equally distribute data into nColors intervals. The output can be used to make a colormap of nColors colors. @@ -1096,7 +1096,7 @@ def getQuantiles(data: npt.NDArray[np.float_], nColors: int) -> npt.NDArray[np.f return boundaries -def digitizeData(data: npt.NDArray[np.float_], nColors: int = 256) -> npt.NDArray[np.integer]: +def digitizeData(data: npt.NDArray[np.float64], nColors: int = 256) -> npt.NDArray[np.integer]: """ Scale data into nColors using its cumulative distribution function. diff --git a/types.txt b/requirements.txt similarity index 62% rename from types.txt rename to requirements.txt index 6db1eb2c..4ee9143a 100644 --- a/types.txt +++ b/requirements.txt @@ -3,3 +3,6 @@ numpy==1.24.4 matplotlib astro-metadata-translator humanize +lsst-utils +lsst-daf-butler +lsst-pipe-base