Is your feature request related to a problem? Please describe.
When you want to select events from a database that all have a non-Nan value for a truth variable. Ideally, one would have a way to use the selection argument of the graphnet.data.dataset like this:
"energy.notna()"
Where energy is a truth variable and .notna() is a pandas.DataFrame.query-compatible syntax.
Until now, this has not worked since the handling of attributes/functions that are called as attributes is not handled in
|
class StringSelectionResolver(Logger): |
more specifically, in
|
for node in ast.walk(tree): |
|
# Save named entities |
|
if isinstance(node, ast.Name): |
|
names.append(node.id) |
|
|
|
# Save names of functions |
|
elif isinstance(node, ast.Call): |
|
functions.append(node.func.id) # type: ignore[attr-defined] |
Describe the solution you'd like
One needs to expand the parsing of the string with ast to adapt to this case.
It's quite easy, and I will pull up a PR with a proposed solution.
Is your feature request related to a problem? Please describe.
When you want to select events from a database that all have a non-Nan value for a truth variable. Ideally, one would have a way to use the
selectionargument of thegraphnet.data.datasetlike this:"energy.notna()"Where energy is a truth variable and .notna() is a
pandas.DataFrame.query-compatiblesyntax.Until now, this has not worked since the handling of attributes/functions that are called as attributes is not handled in
graphnet/src/graphnet/data/utilities/string_selection_resolver.py
Line 18 in 631b1a6
more specifically, in
graphnet/src/graphnet/data/utilities/string_selection_resolver.py
Lines 123 to 130 in 631b1a6
Describe the solution you'd like
One needs to expand the parsing of the string with
astto adapt to this case.It's quite easy, and I will pull up a PR with a proposed solution.