Uploaded image for project: 'Data Management'
  1. Data Management
  2. DM-10380

Allow numpy bool scalars as input when setting Flag table fields

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: To Do
    • Resolution: Unresolved
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      record.set(flagKey, True) works, but record.set(flagKey, np.bool_(True)) raises an exception. It would be nice if both worked.

      Here's a more complete minimal failing example:

      import numpy as np
      import lsst.afw.table as afwTable
       
      schema = afwTable.SourceTable.makeMinimalSchema()
      flagKey = schema.addField("spam", type="Flag")
      table = afwTable.SourceTable.make(schema)
      catalog = afwTable.SourceCatalog(table)
      record = catalog.addNew()
      print("Setting spam to True")
      record.set("spam", True)  # Works
      print("Setting spam to np.bool_(True)")
      record.set("spam", np.bool_(True))  # Raises exception
      
      

      yields

      Setting spam to True
      Setting spam to np.bool_(True)
      Traceback (most recent call last):
        File "boolTicket.py", line 12, in <module>
          record.set("spam", np.bool_(True))  # Raises exception
      TypeError: set(): incompatible function arguments. The following argument types are supported:
          1. (self: lsst.afw.table.schema.schema.KeyFlag, arg0: lsst::afw::table::BaseRecord, arg1: bool) -> None
       
      Invoked with: Key['Flag'](offset=32, bit=0), <lsst.afw.table.source.source.SourceRecord object at 0x2b269ed2d2d0>, True
      
      

        Attachments

          Activity

          Hide
          yusra Yusra AlSayyad added a comment -

          Worth keeping open

          Show
          yusra Yusra AlSayyad added a comment - Worth keeping open

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            jmeyers314 Joshua Meyers
            Watchers:
            Chris Morrison [X] (Inactive), John Parejko, Joshua Meyers, Nate Lust, Pim Schellart [X] (Inactive), Yusra AlSayyad
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Dates

              Created:
              Updated:

                Jenkins Builds

                No builds found.