Uploaded image for project: 'ROOT'
  1. ROOT
  2. ROOT-10731

[PyROOT] Broken conversion from boolean numpy array to bool*

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.22/00
    • Component/s: PyROOT
    • Labels:
      None
    • Environment:

      master on 40983d5bbda3200b101c0b7d5c74eccbff3cff20
      pyroot_experimental=ON

      Description

      Such as reported on the forum (https://root-forum.cern.ch/t/reading-boolean-data-from-ttree-using-pyroot/39178), the conversion from a boolean numpy array to a bool* is broken. See the following reproducer.

      import ROOT
      import numpy
       
      ROOT.gInterpreter.Declare("""
      void convert(bool* x) {
          cout << x[0] << ", " << x[1] << endl;
      }
       
      void convert(int* x) {
          cout << x[0] << ", " << x[1] << endl;
      }
      """)
       
      # Works
      i = numpy.array([0, 1], dtype=numpy.int32)
      ROOT.convert(i)
       
      # Fails with
      # void ::convert(bool* x) =>
      #   TypeError: could not convert argument 1 (could not convert argument to buffer or nullptr)
      b = numpy.array([0, 1], dtype=numpy.bool)
      ROOT.convert(b)
      

        Attachments

          Activity

            People

            • Assignee:
              swunsch Stefan Wunsch
              Reporter:
              swunsch Stefan Wunsch
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: