Skip to content

Improving dataselection with strings #826

@sevmag

Description

@sevmag

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.

Metadata

Metadata

Assignees

Labels

featureNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions