Skip to content

Backwards incompatible change in Filter in 6.40 #22710

Description

@acampove

Check duplicate issues.

  • Checked for duplicates

Description

I have always used (1) as a placeholder for skipping a cut and that is all over the code I use. It seem that both (1) and 1 are not valid anymore?

(rx_run3) [acampove@thinkbook ~]$ ipython
Python 3.13.0 | packaged by conda-forge | (main, Nov 27 2024, 19:18:50) [GCC 13.3.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 9.13.0 -- An enhanced Interactive Python. Type '?' for help.
Tip: `?` alone on a line will brings up IPython's help

In [1]: from ROOT import RDataFrame
[TerminalIPythonApp] WARNING | Shell is already running a different gui event loop for ROOT. Call with no arguments to disable the current loop.
[TerminalIPythonApp] WARNING | Shell is already running a different gui event loop for ROOT. Call with no arguments to disable the current loop.
[TerminalIPythonApp] WARNING | Shell is already running a different gui event loop for ROOT. Call with no arguments to disable the current loop.
[TerminalIPythonApp] WARNING | Shell is already running a different gui event loop for ROOT. Call with no arguments to disable the current loop.
[TerminalIPythonApp] WARNING | Shell is already running a different gui event loop for ROOT. Call with no arguments to disable the current loop.

In [2]: rdf = RDataFrame(100)

In [3]: rdf = rdf.Define('a', 'gRandom->Gaus()')

In [4]: rdf = rdf.Filter('(1)', 'x')
---------------------------------------------------------------------------
runtime_error                             Traceback (most recent call last)
Cell In[4], line 1
----> 1 rdf = rdf.Filter('(1)', 'x')

File ~/micromamba/envs/rx_run3/lib/python3.13/site-packages/ROOT/_pythonization/_rdf_pyz.py:404, in _PyFilter(rdf, callable_or_str, extra_args, *args)
    368 """
    369 Filters the entries of RDF according to a given condition.
    370 Arguments:
   (...)    401 
    402 """
    403 if isinstance(callable_or_str, str):  # If string argument is passed. Invoke the Original Filters.
--> 404     return rdf._OriginalFilter(callable_or_str, *args)
    405 # The 1st argument is either a string or a python callable.
    406 if not callable(callable_or_str):

runtime_error: Template method resolution failed:
  ROOT::RDF::RInterface<ROOT::Detail::RDF::RJittedFilter> ROOT::RDF::RInterface<ROOT::Detail::RDF::RLoopManager>::Filter(string_view expression, string_view name = "") =>
    runtime_error: Filter: the following expression does not evaluate to bool:
(1)
  ROOT::RDF::RInterface<ROOT::Detail::RDF::RJittedFilter> ROOT::RDF::RInterface<ROOT::Detail::RDF::RLoopManager>::Filter(string_view expression, string_view name = "") =>
    runtime_error: Filter: the following expression does not evaluate to bool:
(1)

In [5]: rdf = rdf.Filter('1', 'x')
---------------------------------------------------------------------------
runtime_error                             Traceback (most recent call last)
Cell In[5], line 1
----> 1 rdf = rdf.Filter('1', 'x')

File ~/micromamba/envs/rx_run3/lib/python3.13/site-packages/ROOT/_pythonization/_rdf_pyz.py:404, in _PyFilter(rdf, callable_or_str, extra_args, *args)
    368 """
    369 Filters the entries of RDF according to a given condition.
    370 Arguments:
   (...)    401 
    402 """
    403 if isinstance(callable_or_str, str):  # If string argument is passed. Invoke the Original Filters.
--> 404     return rdf._OriginalFilter(callable_or_str, *args)
    405 # The 1st argument is either a string or a python callable.
    406 if not callable(callable_or_str):

runtime_error: Template method resolution failed:
  ROOT::RDF::RInterface<ROOT::Detail::RDF::RJittedFilter> ROOT::RDF::RInterface<ROOT::Detail::RDF::RLoopManager>::Filter(string_view expression, string_view name = "") =>
    runtime_error: Filter: the following expression does not evaluate to bool:
1
  ROOT::RDF::RInterface<ROOT::Detail::RDF::RJittedFilter> ROOT::RDF::RInterface<ROOT::Detail::RDF::RLoopManager>::Filter(string_view expression, string_view name = "") =>
    runtime_error: Filter: the following expression does not evaluate to bool:
1

In [6]: rdf = rdf.Filter('true', 'x')

In [7]: 
  • was this intentional or a mistake?
  • How should we add 'no cut' cuts?
  • Will 'true' be supported in the long term?

Reproducer

from ROOT import RDataFrame

rdf = RDataFrame(100)
rdf = rdf.Define('a', 'gRandom->Gaus()')
rdf = rdf.Filter('(1)', 'x')

ROOT version

(rx_run3) [acampove@thinkbook ~]$ root --version
ROOT Version: 6.40.02
Built for linuxx8664gcc on Jun 14 2026, 10:42:24
From tags/6-40-02@6-40-02
(rx_run3) [acampove@thinkbook ~]$

Installation method

micromamba

Operating system

almalinux 8

Additional context

No response

Metadata

Metadata

Assignees

Type

No type

Fields

No fields configured for issues without a type.

Projects

Status
Issues

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions