Coverage for python/lsst/cell_coadds/typing_helpers.py: 76%

23 statements  

« prev     ^ index     » next       coverage.py v7.3.2, created at 2023-10-28 09:14 +0000

1# This file is part of cell_coadds. 

2# 

3# Developed for the LSST Data Management System. 

4# This product includes software developed by the LSST Project 

5# (https://www.lsst.org). 

6# See the COPYRIGHT file at the top-level directory of this distribution 

7# for details of code ownership. 

8# 

9# This program is free software: you can redistribute it and/or modify 

10# it under the terms of the GNU General Public License as published by 

11# the Free Software Foundation, either version 3 of the License, or 

12# (at your option) any later version. 

13# 

14# This program is distributed in the hope that it will be useful, 

15# but WITHOUT ANY WARRANTY; without even the implied warranty of 

16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

17# GNU General Public License for more details. 

18# 

19# You should have received a copy of the GNU General Public License 

20# along with this program. If not, see <https://www.gnu.org/licenses/>. 

21 

22"""Collection of type hint stubs for use in type checking.""" 

23 

24 

25from __future__ import annotations 

26 

27from typing import Protocol, Self, overload 

28 

29import numpy as np 

30from lsst.geom import Box2I, Point2I 

31 

32 

33class ImageLike(Protocol): 

34 """Interface for objects that behave like `lsst.afw.image.Image` with 

35 respect to subimage slicing, bounding box access, and XY0 offset. 

36 """ 

37 

38 @overload 

39 def __getitem__(self, slices: tuple[slice, slice]) -> Self: 

40 pass 

41 

42 @overload 

43 def __getitem__(self, bbox: Box2I) -> Self: 

44 pass 

45 

46 def __setitem__(self, bbox: Box2I, other: Self | int) -> None: # noqa: D105 

47 pass 

48 

49 def getBBox(self) -> Box2I: # noqa: D102 

50 pass 

51 

52 def getXY0(self) -> Point2I: # noqa: D102 

53 pass 

54 

55 def setXY0(self, xy0: Point2I) -> None: # noqa: D102 

56 pass 

57 

58 @property 

59 def array(self) -> np.ndarray: # noqa: D102 

60 pass