Skip to main content

A wrapper for the SLICOT control and systems library

Project description

https://img.shields.io/pypi/v/slycot.svg https://anaconda.org/conda-forge/slycot/badges/version.svg https://github.com/python-control/Slycot/workflows/Build%20and%20Test%20Slycot/badge.svg https://coveralls.io/repos/github/python-control/Slycot/badge.svg?branch=master

Python wrapper for selected SLICOT routines, notably including solvers for Riccati, Lyapunov, and Sylvester equations.

Dependencies

Slycot supports Python versions 3.10 or later.

To run the compiled Slycot package, the following must be installed as dependencies:

  • Python 3.10+

  • NumPy

If you are compiling and installing Slycot from source, you will need the following dependencies:

  • Python 3.10+

  • NumPy

  • scikit-build

  • CMake

  • C compiler (e.g. gcc, MS Visual C++, clang)

  • FORTRAN compiler (e.g. gfortran, ifort, flang)

  • BLAS/LAPACK (e.g. OpenBLAS, ATLAS, MKL)

To run the Slycot unit tests and examples, you’ll also need SciPy and pytest.

There are a variety of ways to install these dependencies on different operating systems. See the individual packages’ documentation for options.

Installing

The easiest way to get started with Slycot is to install pre-compiled binaries from conda-forge (see below); these are available for Linux, OSX, and Windows.

Compiling the Slycot source is unfortunately a bit tricky, especially on Windows, but we give some pointers further below for doing this.

Using conda and conda-forge

First install Miniconda or Anaconda. Slycot can then be installed from the conda-forge channel with the following command:

conda install -c conda-forge slycot

Compiling from source

The hardest part about installing from source is getting a working version of FORTRAN and LAPACK (provided by OpenBLAS, MKL, etc.) installed on your system. Depending on where you get your NumPy and SciPy from, you will need to use a compatible LAPACK implementation. Make sure that the correct header files are installed, and specify the CMake variable BLA_VENDOR, if necessary. We recommend to use BLA_VENDOR=Generic in order to produce a Slycot module, which is binary compatible with all implementations.

Compiling the PyPI source with pip

We publish Slycot to the Python package index, but only as a source package, so to install using pip you’ll first need to install the build prerequisites (compilers, libraries, etc.)

If you have these build prerequisites, the command:

pip install slycot

will download the latest release of the source code from PyPI, compile, and install Slycot into the currently configured location (virtual environment or user site-packages).

Getting the full source code

Get it from PyPI

Get the source code of the latest release is available from PyPI. It contains both the Python to Fortran wrappers as well as the SLICOT-Reference Fortran sources.

Get it from GitHub archives

If you decide to download a source code archive from GitHub (tagged release or a specific branch), you also have to get the correct version of our SLICOT-Reference fork and place it into slycot/src/SLICOT-Reference:

  1. Download and unpack https://github.com/python-control/Slycot/archive/master.zip

  2. Go to https://github.com/python-control/Slycot/master/slycot/src

  3. Follow the link of SLICOT-Reference @ <commit-id>

  4. Download the archive of SLICOT-Reference from the Code download button (https://github.com/python-control/SLICOT-Reference/archive/<commit-id>.zip)

  5. Unpack the contents of the SLICOT-Reference archive into slycot/src/SLICOT-Reference

Replace master with the release tag or branch name, which you want to build.

Clone the git repository

Directly checkout the submodule, when cloning the git repository:

git clone --recurse-submodules https://github.com/python-control/Slycot.git

or if you forked the repository:

git clone --recurse-submodules https://github.com/<your-username>/Slycot.git

If you already have a local checkout, but still need to init the submodule:

git submodule init
git submodule update

Compiling the source (Linux, macOS, Windows)

If you need to specify a specific compiler, set the environment variable FC before running the install:

# Linux/OSX:
export FC=/path/to/my/fortran

# Windows:
set FC=D:\path\to\my\fortran.exe

To build and install, execute:

cd /path/to/slycot_src/
pip install -v .

Using the conda recipe

You can use conda to compile and install Slycot from source. The recipe is located in the folder conda-recipe and is intended to work for all platforms.

The conda-forge channel provides almost all requirements to compile Slycot with conda-build, except:

To build and install:

conda build -c conda-forge conda-recipe
conda install -c conda-forge --use-local slycot

Building from source manually in a conda environment (Windows)

A similar method can be used for Linux and macOS, but is detailed here for Windows. This method uses conda and conda-forge to get most build dependencies, except for the C compiler.

  1. Install Microsoft Visual Studio.

  2. Unpack the source code to a directory of your choice,

  3. Create a command shell setup that can run the conda commands and the Visual Studio build tools (see above)

  4. In such a command shell, within the Slycot source code directory, run the following commands to build and install Slycot (this example creates a Python 3.8 environment):

    conda create --channel conda-forge --name build-slycot python=3.10 numpy scipy libblas=*=*netlib liblapack=*=*netlib scikit-build flang pytest
    conda activate build-slycot
    
    pip install -v .

Additional hints

Additional hints for how to install Slycot from source can be found in the .github directory , (commands used to build and test in the GitHub Actions CI), the logs from the GitHub Actions, and the conda-recipe directory (conda pre-requisites, install and test commands) which is included in the source code repository.

Testing

To test if the installation was successful, you can run the slycot unit tests:

pytest --pyargs slycot

You may also run the tests by calling slycot.test() from within the python interpreter:

import slycot
slycot.test()

Importing slycot or running pytest without --pyargs slycot from inside the source directory will fail, unless the compiled wrapper library has been installed into that directory. Note that the [tool:pytest] section in setup.cfg enforces the --pyargs slycot argument by default.

License

Up until version 0.4, Slycot used a version of SLICOT that was released under the GPLv2 license. This requires Slycot to be released under the same license. In December 2020, SLICOT 5.7 was released under BSD-3-Clause. However, as the existing Slycot wrappers have been submitted by many contributors, we cannot move away from GPLv2 unless we get the permission to do so by all authors. Thus, Slycot remains licensed under GPLv2 until further notice.

Project details


Download files

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

Source Distribution

slycot-0.6.0.tar.gz (3.1 MB view details)

Uploaded Source

File details

Details for the file slycot-0.6.0.tar.gz.

File metadata

  • Download URL: slycot-0.6.0.tar.gz
  • Upload date:
  • Size: 3.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.8

File hashes

Hashes for slycot-0.6.0.tar.gz
Algorithm Hash digest
SHA256 98ecf19cad0c6ce0d6f4db95169efc14f89a285ac24a4a8da1ca5b96b9da3c23
MD5 cef06d24f3957efcaaf4190ab08274ea
BLAKE2b-256 a81896acf7dcdc931d0c9a165a8aa3a6f3e6b145d0d69aea43ecef82b8611888

See more details on using hashes here.

Supported by

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