File: new_module.rst

package info (click to toggle)
python-skbio 0.6.2-4
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 9,312 kB
  • sloc: python: 60,482; ansic: 672; makefile: 224
file content (46 lines) | stat: -rw-r--r-- 1,784 bytes parent folder | download
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
Adding a new module
===================

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 LICENSE.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 LICENSE.txt, distributed with this software.
    # ----------------------------------------------------------------------------

Finally, remember to also follow the :doc:`doc_guide`.