File: new_module.rst

package info (click to toggle)
python-skbio 0.5.1-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 16,556 kB
  • ctags: 7,222
  • sloc: python: 42,085; ansic: 670; makefile: 180; sh: 10
file content (47 lines) | stat: -rw-r--r-- 1,870 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
Adding a new module to skbio
############################

Each module needs an `__init__.py` file and a `tests` folder that also
contains an `__init__.py` file. For a module, a simple one may look
like this::

  r"""
  A module (:mod:`skbio.module`)
  ==============================

  .. currentmodule:: skbio.module

  Documentation for this module.
  """

  # ----------------------------------------------------------------------------
  # Copyright (c) 2013--, scikit-bio development team.
  #
  # Distributed under the terms of the Modified BSD License.
  #
  # The full license is in the file COPYING.txt, distributed with this software.
  # ----------------------------------------------------------------------------

  from skbio.util import TestRunner
  test = TestRunner(__file__).test

Usually, some functionality from the module will be made accessible by
importing it in `__init__.py`. It's convenient to use explicit
relative imports (`from .implementation import compute`), so that
functionality can be neatly separated in different files but the user
doesn't face a deeply nested package: `from skbio.module import
compute` instead of `from skbio.module.implementation import compute`.

Inside the tests folder, a simpler `__init__.py` works fine (it is
necessary so that all tests can be run after installation)::

  # ----------------------------------------------------------------------------
  # Copyright (c) 2013--, scikit-bio development team.
  #
  # Distributed under the terms of the Modified BSD License.
  #
  # The full license is in the file COPYING.txt, distributed with this software.
  # ----------------------------------------------------------------------------

Finally, remember to also follow the `documentation guidelines
<https://github.com/biocore/scikit-bio/blob/master/doc/README.md#documenting-a-module-in-scikit-bio>`_.