Getting started

Working on astrodynamics requires the installation of some development dependencies. These can be installed in a virtualenv using pip with the dev extras. You should install astrodynamics in editable mode.

For example:

$ # Create a virtualenv and activate it
$ pip install --editable .[dev]

You are now ready to run the tests and build the documentation.

Running tests

astrodynamics unit tests are found in the astrodynamics/tests/ directory and are designed to be run using pytest. pytest will discover the tests automatically, so all you have to do is:

$ py.test
...
2 passed in 0.78 seconds

This runs the tests with the default Python interpreter.

You can also verify that the tests pass on other supported Python interpreters. For this we use tox, which will automatically create a virtualenv for each supported Python version and run the tests. For example:

$ tox
...
 py27: commands succeeded
ERROR:   py32: InterpreterNotFound: python3.3
ERROR:   py33: InterpreterNotFound: python3.4
 py35: commands succeeded

You may not have all the required Python versions installed, in which case you will see one or more InterpreterNotFound errors.

Building documentation

astrodynamics documentation is stored in the docs/ directory. It is written in reStructured Text and rendered using Sphinx.

Use shovel to build the documentation. For example:

$ shovel docs.gen
...

The HTML documentation index can now be found at docs/_build/html/index.html.

The documentation can be re-built as-you-edit like so:

$ shovel docs.watch
...

Adding/modifying constants

The constants package is created from source files stored in data/constants. Each text file becomes a module in astrodynamics/constants. Users import all constants directly from astrodynamics.constants, but the modules are used for organisation.

After editing the data files, the constants can be updated with the following commands:

$ shovel constants.make_module
$ shovel constants.make_documentation
...
# Or, to do both:
$ shovel constants.make
...

Import order

A consistent import order is used in astrodynamics. The order is as follows:

  • from __future__ import ...
  • Standard library
  • Third party modules
  • Current project [1]
  • Local imports (from . import ..., from .module import ...)

This order, and the formatting of the imports, can be enforced by running the following commands:

$ shovel code.format_imports
...
[1]

Although this order is enforced, within astrodynamics/, use relative imports rather than absolute imports:

# Bad
from astrodynamics.bodies import ReferenceEllipsoid

# Good
from ..bodies import ReferenceEllipsoid