Working on astrodynamics
requires the installation of some
development dependencies. These can be installed in a virtualenv
using pip with the dev-requirements.txt
file. This installs the
dependencies and installs astrodynamics
in editable mode.
For example:
$ # Create a virtualenv and activate it
$ pip install -r dev-requirements.txt
You are now ready to run the tests and build the documentation.
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.
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
...
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
:mod:`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
...
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 # Bad
from astrodynamics.bodies import ReferenceEllipsoid
# Good
from ..bodies import ReferenceEllipsoid |