Coverage for python/lsst/images/tests/_reset_afw_mask_planes.py: 100%
14 statements
« prev ^ index » next coverage.py v7.16.0, created at 2026-09-16 02:39 -0700
« prev ^ index » next coverage.py v7.16.0, created at 2026-09-16 02:39 -0700
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__ = ("reset_afw_mask_planes",)
16import pytest
18try:
19 from lsst.afw.image import Mask
20except ImportError: # pragma: no cover
22 @pytest.fixture
23 def reset_afw_mask_planes() -> None:
24 """Reset afw's process-global mask-plane registry.
26 This variant of the fixture just skips tests, because afw could not
27 be imported.
28 """
29 pytest.skip("lsst.afw.image could not be imported")
30else:
32 def _get_standard_afw_mask_planes() -> tuple[str, ...]:
33 plane_dict = Mask(1, 1).getMaskPlaneDict()
34 return tuple(sorted(plane_dict, key=plane_dict.get))
36 _STANDARD_AFW_MASK_PLANES = _get_standard_afw_mask_planes()
38 @pytest.fixture
39 def reset_afw_mask_planes() -> None:
40 """Reset afw's process-global mask-plane registry.
42 `lsst.afw.image.Mask` has a fixed 32-plane registry that is global
43 to the process. We can run out of bits if we don't reset it for
44 every test, even if no single Mask needs more than 32.
45 """
46 Mask.clearMaskPlaneDict()
47 for name in _STANDARD_AFW_MASK_PLANES:
48 Mask.addMaskPlane(name)