Skip to content

DavidLapous/multipers

Repository files navigation

Multipers

Downloads
Scikit-style multiparameter persistent homology python library. This librairy aims to provide easy to use and performant strategies for applied multiparameter topology. A non-exhaustive list of features can be found in the Features section.
Meant to be integrated in the Gudhi library.

Installation

Some dependencies are needed, e.g., using conda

conda create -n python311
conda activate python311
conda install python=3.11 numpy matplotlib gudhi scikit-learn scipy sympy tqdm shapely -c conda-forge
pip install filtration-domination pykeops

Other libraries may be required for some specific functions, e.g., pytorch for to compute the rank invariant.

Using pip (Recommended)

Precompiled versions, for linux and macos, are available on PyPI. Just use

pip install multipers

Building from source

Clone the repo, and in a terminal, in the root folder

conda install python=3.11 cxx-compiler boost tbb tbb-devel numpy matplotlib gudhi scikit-learn cython sympy tqdm cycler typing shapely -c conda-forge
pip install .

Mostly tested on latest everything on linux. For macos users, this command may fail, see a fix at the end.

How to use

To get a first idea on how this library works, we provide a few tutorial notebooks, in the tutorial folder.
If something is not clear, or a function not covered, feel free to open an issue to ask for an example (or open a PR with a new notebook).
As the example zoo is far from covering everything, don't hesitate to submit something if you find an interesting example.

Features, and linked projects

This librairy features a bunch of different functions and helpers. See below for a non-exhaustive list.
Filled box refers to implemented or interfaced code.

If I missed something, or you want to add something, feel free to open an issue.

Authors

David Loiseaux,
Hannah Schreiber (Persistence backend code),
Luis Scoccola (Möbius inversion in python, degree-rips using persistable and RIVET),
Mathieu Carrière (Sliced Wasserstein)

Contributions

Feel free to contribute, report a bug on a pipeline, or ask for documentation by opening an issue.

For mac users

Due to apple's clang compiler, one may have to disable a compilator optimization to compile multipers: in the setup.py file, add the

-fno-aligned-new

line in the extra_compile_args list. You should have should end up with something like the following.

extensions = [
    Extension(
        f"multipers.{module}",
        sources=[
            f"multipers/{module}.pyx",
        ],
        language="c++",
        extra_compile_args=[
            "-Ofast",
            "-std=c++20",
            "-fno-aligned-new", # Uncomment this if you have trouble compiling on macos.
            "-Wall",
        ],
        include_dirs=cpp_dirs,
        define_macros=[("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")],
        libraries=["tbb", "tbbmalloc"],
        library_dirs=library_dirs,
    )
    for module in cython_modules
]

Alternatives

One may try to use the clang compiler provided by conda or brew. If you have a simpler alternative, please let me know ;)