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
DM-13189: add FunctorKey for Boxes #306
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handful of minor comments.
This did remind me that RFC-209 is still not implemented: I went looking for the text in the dev guide and had to resort to JIRA.
@@ -40,6 +40,11 @@ class PointKey(with_metaclass(TemplateMeta, object)): | |||
PointKey.register((np.float64, 2), aggregates.Point2DKey) | |||
|
|||
|
|||
# Because Boxes aren't templates themselves, we don't expose the fact that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be in a docstring?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so; the potential confusion this comment is trying to avoid is from seeing a change in the pattern established in the rest of the file, and hence I don't think there's much to explain for someone who isn't reading the code.
include/lsst/afw/table/aggregates.h
Outdated
/** | ||
* A FunctorKey used to get or set a geom::Box2I or Box2D from a (min, max) pair of PointKeys. | ||
* | ||
* the Box2IKey and Box2DKey typedefs should be preferred to using the template name directly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
capitalize "The"
include/lsst/afw/table/aggregates.h
Outdated
* | ||
* @param[in,out] schema Schema to add fields to. | ||
* @param[in] name Name prefix for all fields; suffixes above will be appended to this | ||
* to form the full field names. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please give an example, e.g. "somename_min_x"
template <typename Box> | ||
class BoxKey : public FunctorKey<Box> { | ||
public: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specify default/delete copy/move (RFC-209)?
@@ -112,6 +112,52 @@ def testPointKey(self): | |||
self.doTestPointKey("D", lsst.afw.table.Point2DKey, | |||
lsst.afw.geom.Point2D) | |||
|
|||
def doTestBoxKey(self, pointFieldType, functorKeyType, valueType): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docstring, please, at least for the args.
tests/test_functorKeys.py
Outdated
minKey = pointFieldType(schema["a_min"]) | ||
maxKey = pointFieldType(schema["a_max"]) | ||
# we create two equivalent functor keys, using the two different | ||
# constructors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't have to do 80 chars, I don't think...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, this is just what my editor does when I tell it to wrap (since it treats comments like docs, which do have to by 80 chars, I think). Anyhow, I agree it looks funny here; will fix.
Also, thanks for the reminder on RFC-209; I just had another reminder about that from another angle (DM-9932), and the implementation of the RFC is now in review. |
4d0cafd
to
607a951
Compare
607a951
to
404a483
Compare
This adds
FunctorKeys
forBox2I
andBox2D
, which should start us towards recording boxes in tables in a consistent way.I've also updated three other classes in afw to use the new
FunctorKey
because they were already using the same convention and hence the change could be done in a backwards-compatible way. Two others (AmpInfoRecord
andChebyshev1Function2d
) use a different convention and cannot be converted without changing APIs and/or persistence formats.