JupyROOT: SetInputTrees fails

What the title says. I’m trying to get signal and background events from the same tree.
But when I run:

thetree     = inputFile.Get("myTree")
sigCut = ROOT.TCut("Class>1")
bgCut = ROOT.TCut("Class<1")
dataloader.SetInputTrees(thetree, sigCut, bgCut)

I get this:

Error in callback <bound method StreamCapture.post_execute of <JupyROOT.helpers.utils.StreamCapture object at 0x000001F21C9AAB38>> (for post_execute):

UnicodeDecodeError                        Traceback (most recent call last)
C:\rootinstall\bin\JupyROOT\helpers\utils.py in post_execute(self)
    389         # Print for the notebook
    390         out = self.ioHandler.GetStdout()
--> 391         err = self.ioHandler.GetStderr()
    392         if not transformers:
    393             sys.stdout.write(out)

C:\rootinstall\bin\JupyROOT\helpers\handlers.py in GetStderr(self)
     67     def GetStderr(self):
---> 68        return _lib.JupyROOTExecutorHandler_GetStderr()
     70     def GetStreamsDicts(self):

UnicodeDecodeError: 'utf-8' codec can't decode byte 0x86 in position 60001: invalid start byte

Edit: What I write below about double loading isn’t correct, so I’m using the solution below. (See also my reply.)

Let me note that the following code, which loads signal and background separately, runs succesfully. But of course it loads all events twice.

dataloader.PrepareTrainingAndTestTree(sigCut, bgCut, etc.

Maybe @moneta can help

Sorry for the late reply. Your code seems correct, can you please post your code and the input file so I can try to reproduce the problem ?



I wrote that the last snippet in my question loads all events twice.
Actually, it doesn’t; it does so only at BookMethod, but the training uses the dataset only once. So I am using that solution, ie. separate loading.