Git Product home page Git Product logo

python_project_example's Introduction

python_project_example

Simple example of a good project structure with pytest and sphinx implemented

Resources

Getting Started

  • Install the requirements by typing
pip install -r requirements.txt

Running Tests

pip install -e .   # install package using setup.py in editable mode
  • Then run the tests using
py.test

Building Documentation

  • The documentation is built on Sphinx.
  • The Car class contains docstrings in 3 different styles:
    • Googley
    • Sphinxy
    • numpydoc
  • To build HTML documentation:
cd doc
make html
  • To build LaTeX documentation:
cd doc
make latex
cd build/latex
make

Importing into another project

The main project directory contains two files called func_1.py and func_2.py. They contain two useless functions called avg and dim which give the mean and shape of a given vector, respectively. In order to use these functions in other projects the __init__.py file requires the following lines

from .func_1 import *                                                           
from .func_2 import *

The __init__.py file is executed when the project is imported so these functions become available.

The steps are as follows:

  • Install the package by running $ pip install -e . in the root directory.
  • In your project/iPython, import as normal: import mean as mean.
  • Can now use these function as mean.avg([1,2,3]) which returns 3.0.

python_project_example's People

Contributors

ferdinandvanwyk avatar

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.