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: missing attribute in __array__ method of STLVector #1323

Merged
merged 2 commits into from
Oct 31, 2024

Conversation

rossodisera
Copy link
Contributor

Commit #cdaf9a7 adds an __array__ method to STLVector in containers.py L1544 and L1659.

However, the method tries to return an attribute that does not exist. I think it should return self._values and not self._vector

def __array__(self, *args, **kwargs):
    return numpy.asarray(self._vector, *args, **kwargs)

should be:

def __array__(self, *args, **kwargs):
    return numpy.asarray(self._values, *args, **kwargs)

Commit [#cdaf9a7](cdaf9a7) adds an __array__ method to STLVector in containers.py [L1544](https://github.com/scikit-hep/uproot5/blob/afca74c2af16641299abfbf91935e8010d601111/src/uproot/containers.py#L1544) and [L1659](https://github.com/scikit-hep/uproot5/blob/afca74c2af16641299abfbf91935e8010d601111/src/uproot/containers.py#L1659).

However, the method tries to return an attribute that does not exist. I think it should return `self._values` and not `self._vector`

```python
def __array__(self, *args, **kwargs):
    return numpy.asarray(self._vector, *args, **kwargs)
```
should be:
```python
def __array__(self, *args, **kwargs):
    return numpy.asarray(self._values, *args, **kwargs)
```
@rossodisera
Copy link
Contributor Author

I reported the corresponding issue in #1324

@jpivarski jpivarski changed the title Fix for missing attribute in __array__ method of STLVector fix: missing attribute in __array__ method of STLVector Oct 30, 2024
@jpivarski jpivarski linked an issue Oct 30, 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.

You're absolutely right! I'll merge this as soon as the tests pass. Thank you!!!

@jpivarski
Copy link
Member

@all-contributors please add @rossodisera for code

The failure in pyodide-build is unrelated to this; I'm checking up on it.

Copy link
Contributor

@jpivarski

I've put up a pull request to add @rossodisera! 🎉

@rossodisera
Copy link
Contributor Author

Thank you, @jpivarski! I feel a bit guilty about being added to the contributors for such a small change (it was only two lines of code!) :)
I use this tool every day, so I just wanted to thank you and all the contributors again for your work on Uproot.

@jpivarski
Copy link
Member

No problem—I think it's appropriate! My ideal is for Uproot to "belong" to the community, with frequent user-driven updates. We still need a core team to review PRs and make sure that everything fits together, and to respond to bugs that are too "deep" (in the sense of background knowledge needed). But I want to include everyone who makes a code update, even when it's just a small one, in the all-contributors matrix, to emphasize that you're all contributors.

About the test failure, it looks like an upstream library needs to be fixed: #1326 (comment). Can this PR wait until that fix is in? I don't like to merge things into main when a test fails, even though in this case, it's not hurting main because main has the same upstream problem. For formality's sake, I'd just rather fix the test and then merge, but I'll make an exception if this fix needs to be fast-tracked.

@jpivarski
Copy link
Member

This merge with main should bring in the fix (pinning the Selenium version). Then when the tests pass, I'll merge it.

@jpivarski jpivarski enabled auto-merge (squash) October 31, 2024 17:08
@jpivarski jpivarski merged commit 53f917c into scikit-hep:main Oct 31, 2024
26 checks passed
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.

Missing attribute in __array__ method of STLVector
2 participants