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

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

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • High
    • Resolution: Fixed
    • None
    • 6.22/00
    • PyROOT
    • None
    • 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

            swunsch Stefan Wunsch (Inactive)
            swunsch Stefan Wunsch (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: