-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81 from astronomy-commons/sean/healpix-pixel-para…
…meter-decorator Add `healpix_pixel_decorator` to accept `HealpixPixel` objects or tuples and change functions to use it
- Loading branch information
Showing
18 changed files
with
395 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from __future__ import annotations | ||
|
||
from typing import Tuple, Union | ||
|
||
from hipscat.pixel_math.healpix_pixel import HealpixPixel | ||
|
||
HealpixInputTypes = Union[HealpixPixel, Tuple[int, int]] | ||
|
||
|
||
def get_healpix_pixel(pixel: HealpixInputTypes) -> HealpixPixel: | ||
"""Function to convert argument of either HealpixPixel or a tuple of (order, pixel) to a | ||
HealpixPixel | ||
Args: | ||
pixel: an object to be converted to a HealpixPixel object | ||
""" | ||
|
||
if isinstance(pixel, tuple): | ||
if len(pixel) != 2: | ||
raise ValueError( | ||
"Tuple must contain two values: HEALPix order and HEALPix pixel number" | ||
) | ||
return HealpixPixel(order=pixel[0], pixel=pixel[1]) | ||
if isinstance(pixel, HealpixPixel): | ||
return pixel | ||
raise TypeError( | ||
"pixel must either be of type `HealpixPixel` or tuple (order, pixel)" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.