Skip to content
This repository has been archived by the owner on Jun 21, 2022. It is now read-only.

Embed branch titles in awkward docstrings for lazyarrays #417

Merged
merged 2 commits into from
Dec 10, 2019

Conversation

nsmith-
Copy link
Member

@nsmith- nsmith- commented Dec 10, 2019

Although python has nothing to say about instance docstrings, it seems IPython supports setting __doc__ on both class and class instances, in which case it displays both with the ? magic or shift+tab in jupyter. This PR takes advantage of that to display branch titles in lazy array docstrings.
This might not work in python 2, not sure. If not, I'll just use six to disable this feature for py2.

@jpivarski
Copy link
Member

Chances are, it just doesn't do anything in Python 2. Old Python docstrings were more "hard-coded," and attempts to set them with __doc__ (at the class level) were just ignored. There was a hack to fix this by giving the class a custom metatype, which you can see in uproot.

Uproot doesn't depend on six, so if we had to set a switch, I'd rather just check sys.versioninfo (as you see elsewhere).

Is the PR done? I think lazyarrays gets checked in the tests, which passed (including Python 2).

@nsmith-
Copy link
Member Author

nsmith- commented Dec 10, 2019

The PR is done, feature-wise. It seems to work in my tests.

@jpivarski jpivarski merged commit b4f7cb8 into scikit-hep:master Dec 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants