Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-45226: Change np.float_ to np.float64 #116

Merged
merged 4 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
10 changes: 5 additions & 5 deletions python/lsst/summit/utils/imageExaminer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))


Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/summit/utils/peekExposure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions python/lsst/summit/utils/spectrumExaminer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
10 changes: 5 additions & 5 deletions python/lsst/summit/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.

Expand Down
3 changes: 3 additions & 0 deletions types.txt → requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ numpy==1.24.4
matplotlib
astro-metadata-translator
humanize
lsst-utils
lsst-daf-butler
lsst-pipe-base
Loading