Details
-
Type:
Story
-
Status: Invalid
-
Resolution: Done
-
Fix Version/s: None
-
Component/s: None
-
Labels:
Description
lsst.pipe.tasks.mocks.mockCoadd.MockCoaddTask is initialized with
self.objectIdKey = self.schema.addField("objectId", type=long, doc="foreign key to truth catalog") |
self.exposureIdKey = self.schema.addField("exposureId", type=long, |
doc="foreign key to observation catalog") |
When attempting to set fields in a new catalog with
simSrcRecord = simSrcCatalog.addNew() |
simSrcRecord.setL(self.objectIdKey, truthRecord.getId()) |
the following error is given:
TypeError: in method 'BaseRecord_setL', argument 2 of type 'lsst::afw::table::Key< std::int64_t > const &'
|
This error only occurs in python 3 when trying to use a long, which is really a wrapper for int. Using setI works but truncates the integer to 32 bits, which is unacceptable. See
https://github.com/lsst/pipe_tasks/blob/master/python/lsst/pipe/tasks/mocks/mockCoadd.py#L170-L201
https://github.com/lsst/pipe_tasks/blob/master/python/lsst/pipe/tasks/mocks/mockCoadd.py#L112-L131
for the relevant code.
Pim Schellart [X] and I looked at this and determined that the problem is that when a field is added to a schema and the type uses `type=long`, since the aliases in afw/table/Base.i lookup the suffix using the type, in python 3 it always uses "I" for both int and long types (see below).
}
However, using the current framework the user can specify a string, for instance "L" which will add a 64 bit integer and I verified that this does resolve the problem in pipe_tasks.
Since using the long type as an alias will never work correctly in python 3, it may be worth removing the long alias in afw, requiring the user to specify the string "L" for a 64 bit integer. Another option would be to alias both long and int to "I" and require the user to specify type="L" for a 64 bit integer.