Uploaded image for project: 'Instrument control development'
  1. Instrument control development
  2. INSTRM-2734

Fix numpy 2 ~uint usage for COBRA_OK_MASK

    XMLWordPrintable

    Details

      Description

      The PFI class variables COBRA_XXX_MASK are set to 0x0001, etc. That fails in status &= ~self.COBRA_OK_MASK because the non-numpy ~0x0001 is turned into a negative integer after which numpy 2 rejects the operation against the `np.uint16` `status`:

      ----> 1 ~0x0001 & np.uint16(0)
      
      OverflowError: Python integer -2 out of bounds for uint16
      

      Either all the constants should be set to np.uint16(0x0001, etc, or the negation in setCobraStatus() needs to be protected. The cowardly way out is just to fix that specific usage, but I suspect we should type the constants. Am a bit worried about all possible downstream users....

      Or hide all such constants and wrap with accessors?

        Attachments

          Activity

            People

            • Assignee:
              cloomis cloomis
              Reporter:
              cloomis cloomis
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: