Code Monkey home page Code Monkey logo

piam-scm-interface's People

Contributors

gabriel-abrahao avatar

Watchers

 avatar

piam-scm-interface's Issues

Use numpy-style docstrings for function documentation

Hi Gabriel,

You have added quite useful documentation for your functions, eg:

# Writes a dict as a single parameter in a new GDX file
# vargamsname:
# GAMS name of the variable
# vardict:
# dictionary with the values. The keys define a new Set called gamssetname
# vartext:
# explanatory text (optional)
# gamssetname:
# name of the GAMS Set that will be built from vardict's keys
# outfname:
# output GDX file name
def write_gdx_parameter_from_dict(vargamsname, vardict, gamssetname, outfname, vartext = ""):
However, at the moment the documentation is in the form of comments, which is non-standard. A standard way of specifying documentation is using numpy-style docstrings. For example, the documentation for write_gdx_parameter_from_dict using numpy docstring style would look like this:

def write_gdx_parameter_from_dict(vargamsname, vardict, gamssetname, outfname, vartext = ""):
    """Writes a dict as a single parameter in a new GDX file

    Parameters
    ----------
    vargamsname: str
        GAMS name of the variable
    vardict: dict
        Dictionary containing the values. The keys define a new Set called gamssetname.
    gamssetname: str
        Name of the GAMS Set that will be built from vardict's keys
    outfname: str
        output GDX file name
    vartext: str, default empty string
        ???
    """

Using an integrated development environment like pycharm or VS Code, the documentation is then displayed inside tool tips etc., and also on the ipython console, you get nice documentation using ?:

In [3]: write_gdx_parameter_from_dict?
Signature:
write_gdx_parameter_from_dict(
    vargamsname,
    vardict,
    gamssetname,
    outfname,
    vartext='',
)
Docstring:
Writes a dict as a single parameter in a new GDX file

Parameters
----------
vargamsname: str
    GAMS name of the variable
vardict: dict
    Dictionary containing the values. The keys define a new Set called gamssetname.
gamssetname: str
    Name of the GAMS Set that will be built from vardict's keys
outfname: str
    output GDX file name
vartext: str, default empty string
    ???
File:      ~/<ipython-input-2-dbb33317714f>
Type:      function

Cheers,

Mika

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.