scikit-hep / awkward-0.x

Manipulate arrays of complex data structures as easily as Numpy.
BSD 3-Clause "New" or "Revised" License
215 stars 39 forks source link

dynamically created methods are confusing for users #233

Open HDembinski opened 4 years ago

HDembinski commented 4 years ago

I am teaching about uproot and I found that several methods on a jagged array do not seem to exist, but they can be accessed anyway.

# x is a JaggedArray
dir(x)
['__class__',
 '__delattr__',
 '__dir__',
 '__doc__',
 '__eq__',
 '__format__',
 '__ge__',
 '__get__',
 '__getattribute__',
 '__gt__',
 '__hash__',
 '__init__',
 '__init_subclass__',
 '__le__',
 '__lt__',
 '__ne__',
 '__new__',
 '__reduce__',
 '__reduce_ex__',
 '__repr__',
 '__self__',
 '__self_class__',
 '__setattr__',
 '__sizeof__',
 '__str__',
 '__subclasshook__',
 '__thisclass__',
 '_content',
 '_counts',
 '_isvalid',
 '_offsets',
 '_parents',
 '_starts',
 '_stops',
 'leafcount']

But x.content, x.starts, etc. can be accessed.

jpivarski commented 4 years ago

Adding a note to this issue: the properties (content, starts) are not dynamically created, but there is a __dir__ that is intended to add field names (which are dynamically added because they depend on the data). The __dir__ might not be accounting for the primary methods properly.