Skip to content

Installation and setup

Installation

You can install the latest development version of Megatop directly from GitHub.

pip install git+https://github.com/CMBSciPol/Megatop.git

Note

Megatop depends on NaMaster. The method above will compile that package on your machine, and assumes you have installed its dependencies. Otherwise, we suggest installing it from conda-forge beforehand.

Check the NaMaster documentation for more information.

Tip

Spherical harmonic transforms use ducc under the hood. For best performance, it is recommended to compile this package from source by adding --no-binary ducc0 (see https://gitlab.mpcdf.mpg.de/mtr/ducc#installation for details).

Most of the pipeline steps use MPI. To run those, you will need the mpi4py package, an optional dependency.

pip install megatop[mpi] @ git+https://github.com/CMBSciPol/Megatop.git

Refer to the mpi4py documentation for more information.

To use Snakemake to orchestrate the pipeline (recommended, requires Python >= 3.11):

pip install megatop[snake] @ git+https://github.com/CMBSciPol/Megatop.git

Both extras can be combined:

pip install "megatop[mpi,snake] @ git+https://github.com/CMBSciPol/Megatop.git"

Development

You should clone the repository and install in editable mode with the dev dependency group.

pip install -e .[mpi] --group dev

The dev group includes pytest for testing. You can simply run the tests with

pytest

Code quality checks

Our pre-commit hooks run automatically via GitHub actions. To run them locally, you can follow these steps.

  1. Install prek following the documentation.
  2. Install hooks with

    prek install
    
  3. That's it! Every commit will trigger the code quality checks.

Tip

You can run hooks on demand with prek run.