Skip to content

Latest commit

 

History

History
149 lines (113 loc) · 4.83 KB

File metadata and controls

149 lines (113 loc) · 4.83 KB

Welcome to modepy!

Installation

The latest version of modepy is available on PyPI. It can be installed with

pip install modepy

It is also available on conda-forge and can be installed from there using, e.g.,

conda install modepy

Obtaining the source

For development, we recommend cloning the Git repository and setting up a development environment. The source can be obtained from GitHub using, e.g.,

git clone https://github.com/inducer/modepy

Virtual Environments

modepy is a pure Python library that (mainly) depends on numpy. However, it has several development dependencies that will be needed when submitting a PR. To ensure a development environment that does not pollute your system install, we recommend using virtual environments.

A new virtual environment can be created as follows

python -m venv .venv

and activated using

source .venv/bin/activate

These commands may differ slightly based on your operating system, so for more information see the official documentation. modepy uses standard Python packaging techniques and as such is also compatible with additional tools, such as uv or conda.

Development ("editable") install

Once a virtual environment has been set up, we recommend performing an editable install with all the necessary dependencies.

If using the standard pip, you can directly run (in your activated virtual environment!) the following command

pip install --verbose --editable .[doc,test]

Bug reports

Reporting any issues should be done in the GitHub Issue Tracker. When reporting an issue, include as much information as possible to allow reproducing or pinpointing the exact cause. For example, consider adding

  • A small code snippet that reproduces the issue.
  • Library versions (especially numpy).
  • Environment information (operating system, Python version, etc.).

Contributing

Coding style

modepy uses ruff to check for coding style and other issues. The library follows a variant of the PEP 8 rules as checked by the linter.

Furthermore, we aim for (close to) full type annotated code. This is checked with basedpyright.

Pull Requests

The suggested way to contribute to modepy is through pull requests on Github. If you are aiming to develop a larger feature, we recommend opening an issue first to discuss if it is appropriate for inclusion and any additional implementation details.

To get your PR merged, we require that

  • All unit tests pass.
  • All linting tests must pass (ruff, typos, and any other future additions).
  • New functionality should be documented and tested appropriately.

Any new code added to the repository is expected to have sufficient type annotations to pass basedpyright. In specific cases (and with adequate justification), additions to the existing baseline of typing deficiencies may be allowable.

Documentation

You can find the official documentation for modepy online. The documentation is generated using the Sphinx generator using the default syntax. It can be generated locally using

cd doc
make html

and loaded from _build/html/index.html.

Additions and corrections are very welcome! If you have a cool non-trivial example of modepy usage, also consider adding it to the examples folder.

License

By contributing, you agree that your contributions will be licensed under the same license as the project (the MIT license). You will retain copyright to your contribution. To facilitate appropriate tracking, please add your name to the license header that should be present at the top of each file.

Testing

Running unit tests

modepy uses pytest for its unit testing needs. All tests (unit tests and doctests) can be run directly using

python -m pytest -v -s modepy

New unit tests should be added to a new or existing file in modepy/test.

Linting and type annotations

As mentioned before, modepy uses ruff and basedpyright for static linting. These tools are configured in the pyproject.toml file and can be run directly without additional options. For example, for linting use

ruff check

and for type checking use

basedpyright