exmplpckg package

Submodules

exmplpckg.base module

Example Package in python to show how to use documentation with sphinx and readthedocs .

The purpose of this module is to demonstrate documentation as specified by the NumPy Documentation HOWTO. Docstrings may extend over multiple lines. Sections are created with a section header followed by an underline of equal length.

Sphinx allows to include documentation from docstrings . To make the docstrings look nice within your html page, use any reStructuredText formatting.

This simple package calculates the slope m and the offset t of a linear function for two given points P1 = [x,y] and P2 = [x,y]

\[y = m * x + t\]

Example

Here you can provide an Example in doctest format

>>> import exmplpckg as ep
>>> P1 = [3,4]
>>> P2 = [6,8]
>>> linf = ep.LinearFunction(P1,P2)
>>> linf.calc_y(3)
4

Notes

  • Here you can specify more stuff
  • e.g. in a list
class exmplpckg.base.LinearFunction(P1, P2)[source]

Bases: object

Linear function object

Some more description of your class

m

float – slope of the linear function

t

float – offset of the linear function.

calc_y(x)[source]

Calculate function output for given x

Parameters:x (float) – any float number
Returns:function output y = m*x + t
Return type:float
fit(P1, P2)[source]

Calculate slope m and offset t.

Parameters:
  • P1 (list) – List with x and y value of point 1: P1 = [x,y]
  • P2 (list) – List with x and y value of point 2: P2 = [x,y]

exmplpckg.plot module

In this file we define all (here one) methods for plotting. We do this in a seperate file because plotting functions usually need many lines of code. (And to have two different files in this example). Of courese we could simply add this in the base file (also as a method), which even might be the better solution…

exmplpckg.plot.plot_linf(linf, xrange=[0, 10])[source]

Plot the linear function

Parameters:linf – LinearFunction object containing slope m and offset t
Returns:matplotlib figure object
Return type:figure

exmplpckg.get_settings module

The function get_parameter() is supposed to return parameters saved in a csv file /settings/settings_file.csv within this package

exmplpckg.get_settings.get_parameter(parameter)[source]

Read settings csv file in /settings/settings_file.csv in this package

Parameters:parameter (str) – parameter to read
Returns:
  • float – value of the parameter
  • str – comment for the parameter

Module contents

You can also have a docstring for your init file