Skip to main content

The official Python interface to the Scotch and PT-Scotch graph partitioning libraries

Project description

ScotchPy

This project provides a Python3 interface for the Scotch graph partitioning library

pipeline status Developer documentation

Requirements

  • Python >= 3.10
  • NumPy, to handle integer arrays
  • pytest, to test the ScotchPy module
  • Optional :
  • mpi4py, to use the features of PT-ScotchPy
  • Sphinx, to build the documentation
  • networkx and matplotlib, to view some examples
  • A recent DYNAMIC/SHARED Scotch library (>=v7.0.9), if you do not have access to the Internet

Configuring, compiling and testing ScotchPy

Configure

Before using pip you need to generate the pyproject.toml and select which version of the package you need:

  • integer size (32/64) -> export INTSIZE=64, for instance
  • ptscotch -> export PTSCOTCH=ON
./configure

At the time being, the scotchpy package supports 4 configurations:

config INTSIZE=32 INTSIZE=64
sequential scotchpy scotchpy64
parallel ptscotchpy ptscotchpy64

Before using pip you need to generate the pyproject.toml and select which version of the package you need:

  • integer size (32/64) -> export INTSIZE=64, for instance
  • ptscotch -> export PTSCOTCH=1
./configure

We strongly recommand to have the same integer size for scotch than the numpy.dtype.

If you already have a Scotch library >= 7.0.8 installed on your system

virtualenv /some/path
SCOTCHPY_SCOTCH="dir/containing/the/lib" /some/path/bin/pip -v  install .
export SCOTCHPY_ERR=${$(find /some/path/lib/ -name "*scotchpy_err*.so"):h}
SCOTCHPY_SCOTCH="dir/containing/the/lib" /some/path/bin/python -m pytest

Scotch library older than 7.0.9 or not available

The building system (scikit-build-core) will download sources from the Internet and compile it for you.

virtualenv /some/path
/some/path/bin/pip -v  install .  # This step uses scikit-build-core
/some/path/bin/python -m pytest

Using a binary wheel from the Internet (experimental, only for Linux and sequential version at the time being)

virtualenv /tmp/test_sotchpy
/tmp/test_sotchpy/bin/pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple scotchpy64==1.0.1
/tmp/test_sotchpy/bin/python -c 'import scotchpy; print(scotchpy.num_sizeof())'

Testing ScotchPy

To use ScotchPy locally, you can run some examples like load_part.py provided below:

import scotchpy
import scotchpy 
from scotchpy.common import proper_int as scotch_num
import importlib.resources as resources
import os

# Allocate a graph

graf = scotchpy.Graph()

# Read a graph from the scotchpy/data dir

data_dir = resources.files("scotchpy").joinpath("data")
graf.load(os.path.join(data_dir, "m4x4.grf"))

# Partition a graph into 4 parts

parttab = np.zeros(graf.vertnbr, dtype=scotch_num)
graf.part(partnbr = 4, parttab = parttab)

# Export the graph to the dot format

if scotchpy.graph._nx_found:
    import networkx as nx
    graf_nx = graf.tonx()
    color = { 0:"red" , 1:"blue", 2:"green", 3:"black"}
    for i in graf_nx.nodes:
         graf_nx.nodes[i]["color"] = color[parttab[i]]
    try:
       nx.nx_pydot.to_pydot(graf_nx).write_dot("m4x4.dot")
    except ModuleNotFoundError:
       pass

from a Python prompt.

Generating the documentation

sphinx-build -b html doc/source build/doc

The HTML pages will be in build/doc.

Testing

To run all ScotchPy tests, type:

tmpdir=$(mktemp -d)
cp -R path/to/scotchpy/sources/tests $tmpdir
cd $tmpdir
/path/to/an/installed/scotchpy/bin/python -m pytest

For parallel tests (e.g. those involving mpi4py and the submodule scotchpy.dgraph), we use the plugin pytest-isolate-mpi that you can find on pypi.org

Contributing

Contributions are welcome!

To apply the pylint syntax checking tool, type:

pylint --disable=R0902,R0903,R0904,R0912,R0913,C0114,C0116 scotchpy

Authors

License

This project is distributed under the 2-clause BSD License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

scotchpy64-1.0.1-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

scotchpy64-1.0.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

scotchpy64-1.0.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

scotchpy64-1.0.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

scotchpy64-1.0.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

scotchpy64-1.0.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

File details

Details for the file scotchpy64-1.0.1-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for scotchpy64-1.0.1-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e0c8c77a8aa5cc75d59b40cfb47f02814c5bdfb605fc82deaa57cac4f486f125
MD5 ceb96387834686daf6f46f3aa7c63d68
BLAKE2b-256 e4f025613cd7f193b23dd5f886555b04012816fcebe0589c39d51e75f9fcb687

See more details on using hashes here.

File details

Details for the file scotchpy64-1.0.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for scotchpy64-1.0.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3cd52831289d592cca3ca9ec4093467855f3c77d0af0966ba182fe49ceadc4d2
MD5 24d0c497a208c1bd3bb8eb4e4ff39496
BLAKE2b-256 82cdb2f1f81a7adbec6e4c70cea0b518f89c5b2650e2fdc669aed380bcbb2bb4

See more details on using hashes here.

File details

Details for the file scotchpy64-1.0.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for scotchpy64-1.0.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e2ea7f50b3a7797e0cd71537b2c072114dd9bb6ca48dc5f826d555370eb3150a
MD5 d0c7760c94c597b49d0ac0ac0e9ca17e
BLAKE2b-256 3bea12491425a0148b8b0ccbe3694a24d2b498a99c21084c8cec09e3e94dd78f

See more details on using hashes here.

File details

Details for the file scotchpy64-1.0.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for scotchpy64-1.0.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 87705f9c4105740306d5048c7c44a51e62b2f03c9a95fa7610d6a3386989e8c5
MD5 88269dcbe8efa3dad9fb7a20576e8a40
BLAKE2b-256 5fbe3b344a1beba0abd011d0193f151d510a286787d3910c3ae3d7940dd70931

See more details on using hashes here.

File details

Details for the file scotchpy64-1.0.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for scotchpy64-1.0.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 78b17354dafe8d99471ff01fc54ce2d26fca2061ea27db95c8f8bb73813fc579
MD5 aae9447275ac29166f40d34cf4dc606f
BLAKE2b-256 bdb35e171536989e4fa154b22a480f256dd5fada8d9ce47614c77b747adb250c

See more details on using hashes here.

File details

Details for the file scotchpy64-1.0.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for scotchpy64-1.0.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 276fd237f27ad5e71731ea5fac3e78964062ae98112be6d1eef579cff7c864e8
MD5 83028ddf48569ec0bbfdc65a34117502
BLAKE2b-256 bcd1ef71e3836625fc31e9578c275ddcf197fcbc60362dce822369aa1ecde422

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page