Coverage for python/lsst/images/_transforms/_frame_set.py: 0%
17 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-07-30 08:38 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-07-30 08:38 +0000
1# This file is part of lsst-images.
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# Use of this source code is governed by a 3-clause BSD-style
10# license that can be found in the LICENSE file.
12from __future__ import annotations
14__all__ = ("FrameLookupError", "FrameSet")
16from abc import ABC, abstractmethod
18from ..describe import DescribableMixin
19from . import _frames # use this import style to facilitate pattern matching
20from ._transform import Transform
23class FrameLookupError(LookupError):
24 """Exception raised when a frame cannot be found in a `FrameSet`."""
27class FrameSet(DescribableMixin, ABC):
28 """A container or factory for `Transform` objects that relates frames.
30 Notes
31 -----
32 `FrameSet` supposes ``in`` (``__contains__``) tests on individual `Frame`
33 objects to test whether they are known to the frame set, and indexing
34 (``__getitem__``) of **pairs** of frames to return a `Transform` that maps
35 the first to the second.
36 """
38 @abstractmethod
39 def __contains__(self, frame: _frames.Frame) -> bool:
40 raise NotImplementedError()
42 @abstractmethod
43 def __getitem__[I: _frames.Frame, O: _frames.Frame](self, key: tuple[I, O]) -> Transform[I, O]:
44 raise NotImplementedError()
46 def get[I: _frames.Frame, O: _frames.Frame](self, in_frame: I, out_frame: O) -> Transform[I, O] | None:
47 """Return the `Transform` that maps the two frames, or `None` if at
48 least one is not known to the `FrameSet`.
50 Parameters
51 ----------
52 in_frame
53 Frame to transform from.
54 out_frame
55 Frame to transform to.
56 """
57 try:
58 return self[in_frame, out_frame]
59 except FrameLookupError:
60 return None