Wrong conversion of bool array to numpy array

Hi,

The following code used to work prior to ROOT 6.38 (I think last tested in ROOT 6.30)

self.Focalsurface = np.array(self.tree.focal_surface, dtype=bool)

not depending on the dimensions of self.tree.focal_surface. I tested it on [1][1] and [2][2]. With ROOT 6.38 it works on [1][1], but not on [2][2]. With focal_surface[2][2]/O I get:

  File "/home/lewhoo/workspace/etos/eusottrees/exptree.py", line 107, in __init__
    self.Focalsurface = np.array(self.tree.focal_surface, dtype=bool)
                        ~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: Item size 8 for PEP 3118 buffer format string ? does not match the dtype ? item size 1.

The workaround is to have:

			if isinstance(self.tree.focal_surface, bool):
				self.Focalsurface = np.array(self.tree.focal_surface, dtype=bool)
			else:
				self.Focalsurface = np.frombuffer(self.tree.focal_surface, dtype=np.bool, count=self.FocalsurfaceMaxPdmX * self.FocalsurfaceMaxPdmY)

which shows another bug: 1x1 is pythonised to scalar, so frombuffer can’t be used on it. It would give the following error:

    self.Focalsurface = np.frombuffer(self.tree.focal_surface, dtype=np.bool, count=self.FocalsurfaceMaxPdmX * self.FocalsurfaceMaxPdmY)
                        ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: a bytes-like object is required, not 'bool'


ROOT Version: 6.38
Platform: Fedora 43