mirror of
https://github.com/fjosw/pyerrors.git
synced 2026-08-04 19:41:17 +02:00
better docstrings (#144)
* first example of returns statement in docstring * added a some return statements for pandas API * last return statements in pandas input * added returns to bdio docstrings * few returns statements added to docstring * finished docstrings for hadrons submodule * also finished docstrings for json submodule * finished misc submodule * added returns in docstrings in openqQCD * made some cosmetic chanes to dostrings * added return nad return statement in docstring * linting * Improved docstrings of mpm, fits, roots, misc to have return statements returns added for misc.py returns added for mpm.py reutrns added for fits.py * linting... * Some polishing of docstrings
This commit is contained in:
parent
b9cdebd442
commit
26447d658c
14 changed files with 276 additions and 6 deletions
|
|
@ -29,6 +29,11 @@ def create_json_string(ol, description='', indent=1):
|
|||
indent : int
|
||||
Specify the indentation level of the json file. None or 0 is permissible and
|
||||
saves disk space.
|
||||
|
||||
Returns
|
||||
-------
|
||||
json_string : str
|
||||
String for export to .json(.gz) file
|
||||
"""
|
||||
|
||||
def _gen_data_d_from_list(ol):
|
||||
|
|
@ -212,6 +217,10 @@ def dump_to_json(ol, fname, description='', indent=1, gz=True):
|
|||
saves disk space.
|
||||
gz : bool
|
||||
If True, the output is a gzipped json. If False, the output is a json file.
|
||||
|
||||
Returns
|
||||
-------
|
||||
Null
|
||||
"""
|
||||
|
||||
jsonstring = create_json_string(ol, description, indent)
|
||||
|
|
@ -247,6 +256,17 @@ def _parse_json_dict(json_dict, verbose=True, full_output=False):
|
|||
full_output : bool
|
||||
If True, a dict containing auxiliary information and the data is returned.
|
||||
If False, only the data is returned.
|
||||
|
||||
Returns
|
||||
-------
|
||||
result : list[Obs]
|
||||
reconstructed list of observables from the json string
|
||||
or
|
||||
result : Obs
|
||||
only one observable if the list only has one entry
|
||||
or
|
||||
result : dict
|
||||
if full_output=True
|
||||
"""
|
||||
|
||||
def _gen_obsd_from_datad(d):
|
||||
|
|
@ -447,6 +467,17 @@ def import_json_string(json_string, verbose=True, full_output=False):
|
|||
full_output : bool
|
||||
If True, a dict containing auxiliary information and the data is returned.
|
||||
If False, only the data is returned.
|
||||
|
||||
Returns
|
||||
-------
|
||||
result : list[Obs]
|
||||
reconstructed list of observables from the json string
|
||||
or
|
||||
result : Obs
|
||||
only one observable if the list only has one entry
|
||||
or
|
||||
result : dict
|
||||
if full_output=True
|
||||
"""
|
||||
|
||||
return _parse_json_dict(json.loads(json_string), verbose, full_output)
|
||||
|
|
@ -469,6 +500,17 @@ def load_json(fname, verbose=True, gz=True, full_output=False):
|
|||
full_output : bool
|
||||
If True, a dict containing auxiliary information and the data is returned.
|
||||
If False, only the data is returned.
|
||||
|
||||
Returns
|
||||
-------
|
||||
result : list[Obs]
|
||||
reconstructed list of observables from the json string
|
||||
or
|
||||
result : Obs
|
||||
only one observable if the list only has one entry
|
||||
or
|
||||
result : dict
|
||||
if full_output=True
|
||||
"""
|
||||
if not fname.endswith('.json') and not fname.endswith('.gz'):
|
||||
fname += '.json'
|
||||
|
|
@ -586,6 +628,10 @@ def dump_dict_to_json(od, fname, description='', indent=1, reps='DICTOBS', gz=Tr
|
|||
Specify the structure of the placeholder in exported dict to be reps[0-9]+.
|
||||
gz : bool
|
||||
If True, the output is a gzipped json. If False, the output is a json file.
|
||||
|
||||
Returns
|
||||
-------
|
||||
None
|
||||
"""
|
||||
|
||||
if not isinstance(od, dict):
|
||||
|
|
@ -683,6 +729,14 @@ def load_json_dict(fname, verbose=True, gz=True, full_output=False, reps='DICTOB
|
|||
If False, only the data is returned.
|
||||
reps : str
|
||||
Specify the structure of the placeholder in imported dict to be reps[0-9]+.
|
||||
|
||||
Returns
|
||||
-------
|
||||
data : Obs / list / Corr
|
||||
Read data
|
||||
or
|
||||
data : dict
|
||||
Read data and meta-data
|
||||
"""
|
||||
indata = load_json(fname, verbose=verbose, gz=gz, full_output=True)
|
||||
description = indata['description']['description']
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue