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

Improve getAffiliation docstring to follow numpy/scipy documentation #98

Merged
merged 2 commits into from
Sep 27, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions odm2api/ODM2/services/readService.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,12 +544,30 @@ def getPeople(self, ids=None, firstname=None, lastname=None):

def getAffiliations(self, ids=None, personfirst=None, personlast=None, orgcode=None):
"""
getAffiliations(self, ids=None, personfirst=None, personlast=None, orgcode=None)
* Pass nothing - returns a list of all Affiliation objects
* Pass a list of AffiliationID - returns a single Affiliation object
* Pass a First Name - returns a single Affiliation object
* Pass a Last Name - returns a single Affiliation object
* Pass an OrganizationCode - returns a Affiliation object
Retrieve a list of ODM2 Affiliation objects.
Copy link
Member

Choose a reason for hiding this comment

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

Based on the behavior described in the old docstring, I'd change this to: "Retrieve an Affiliation object or a list of such objects." But please confirm whether a request that returns one object, returns a list with one element or the object proper. Adjust the above string as appropriate.

Copy link
Member Author

Choose a reason for hiding this comment

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

The previous docstring seems to be incorrect, the function always returns a list...

Copy link
Member

Choose a reason for hiding this comment

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

Ok. Glad you checked it!

I would just remove "ODM2" from the string. It's obvious that odm2api query methods all return ODM2 objects!


Parameters
Copy link
Member

Choose a reason for hiding this comment

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

We may need the numpydoc extension for this. I don't have a strong preference but lately I've stop using numpy-style and adopted the simpler http://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah okay!

Copy link
Member

Choose a reason for hiding this comment

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

I don't know much about the two styles, so I'll go with whatever @ocefpaf recommends! Can you tell us why you've made the change (pros and cons), offline? Say, on the email thread we started yesterday about documentation?

----------
ids: list, default None
List of AffiliationIDs
personfirst: str, default None
Person First Name
personlast: str, default None
Person Last Name
orgcode: str, default None
Organization Code

Copy link
Member

Choose a reason for hiding this comment

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

Looks like if you call the function with no arguments (or None for all / any of them), a list of ALL affiliations will be returned. Tweak the docstring to include that information.

Copy link
Member Author

Choose a reason for hiding this comment

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

Should I say:

Retrieve a list of ODM2 Affiliation objects.
        
Note: If no arguments are passed to the function, 
ALL ODM2 Affiliation objects within the database will be queried.

Copy link
Member

Choose a reason for hiding this comment

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

Retrieve a list of Affiliation objects.
        
If no arguments are passed to the function, or their values are None, 
all Affiliation objects in the database will be returned.

Returns
-------
List of Affiliation objects

Examples
--------
>>> read.getAffiliations(ids=[39,40])
>>> read.getAffiliations(personfirst='Anthony',
... personlast='Aufdenkampe')
>>> read.getAffiliations(orgcode='LimnoTech')

Copy link
Member

Choose a reason for hiding this comment

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

Change the examples so they don't refer to Anthony's actual identity (first & last name and actual organization)! Use made up names and organization code, eg: John Smith, orgcode='Acme'

"""
q = self._session.query(Affiliations)

Expand Down