Skip to content

Commit

Permalink
Fix for missing attribute in __array__ method of STLVector (#1323)
Browse files Browse the repository at this point in the history
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)
```

Co-authored-by: Jim Pivarski <jpivarski@users.noreply.github.com>
  • Loading branch information
rossodisera and jpivarski authored Oct 31, 2024
1 parent 73f03d8 commit 53f917c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/uproot/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1541,7 +1541,7 @@ def __eq__(self, other):
return False

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

def tolist(self):
return [
Expand Down Expand Up @@ -1656,7 +1656,7 @@ def __eq__(self, other):
return False

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

def tolist(self):
return [
Expand Down

0 comments on commit 53f917c

Please sign in to comment.