Skip to content

DM-45569: Add access to color value. #781

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion include/lsst/afw/image/Color.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class Color final {

/// Whether the color is the special value that indicates that it is unspecified.
bool isIndeterminate() const noexcept { return std::isnan(_g_r); }
double getColorValue() const noexcept { return _g_r;}

//@{
/**
Expand All @@ -55,7 +56,6 @@ class Color final {
/// Return a hash of this object.
std::size_t hash_value() const noexcept { return isIndeterminate() ? 42 : std::hash<double>()(_g_r); }

private:
double _g_r;
};
} // namespace image
Expand Down
1 change: 1 addition & 0 deletions python/lsst/afw/image/_color.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ void wrapColor(lsst::cpputils::python::WrapperCollection &wrappers) {

/* Members */
cls.def("isIndeterminate", &Color::isIndeterminate);
cls.def("getColorValue", &Color::getColorValue);
});
}

Expand Down
4 changes: 4 additions & 0 deletions tests/test_color.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ def testIsIndeterminate(self):
self.assertTrue(afwImage.Color().isIndeterminate())
self.assertFalse(afwImage.Color(1.2).isIndeterminate())

def testGetColor(self):
color = afwImage.Color(0.42)
self.assertEqual(color.getColorValue(), 0.42)


class MemoryTester(lsst.utils.tests.MemoryTestCase):
pass
Expand Down