Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow colon in key names #1127

Merged
merged 4 commits into from
Feb 15, 2024
Merged

Conversation

ioanaif
Copy link
Collaborator

@ioanaif ioanaif commented Feb 15, 2024

This adds fixes the infinite recursion issue when trying to add keys which have a colon in their name:

#974

If we have a file with a key name "one:two", but also a TTree "one" which contains a "two" named branch:

 with uproot.recreate(newfile) as f:
        f["one:two"] = "together"
        array = ak.Array(["one", "two", "three"])
        f["one"] = {"two": array}

the behaviour will be the following when reading the two:

 with uproot.open(newfile) as f:
        f["one:two"] == "together"
        f["one"]["two"].array() == ["one", "two", "three"]

@ioanaif ioanaif linked an issue Feb 15, 2024 that may be closed by this pull request
Copy link
Member

@jpivarski jpivarski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We talked about it in our meeting, and this is a great solution. It's important that it prioritizes names with colons over parsing a colon as a separator, but allows both, since this makes access to all objects possible. (f["one:two"] versus f["one"]["two"] in your test example.)

It's ready to merge when you think it is.

@ioanaif ioanaif enabled auto-merge (squash) February 15, 2024 16:57
@ioanaif ioanaif merged commit 8a42e7d into main Feb 15, 2024
21 checks passed
@ioanaif ioanaif deleted the ioanaif/fix-allow-column-in-key-name branch February 15, 2024 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't read keys in root files with colon in name
2 participants