[simplex] Minor cleaning.
All checks were successful
continuous-integration/drone Build is passing

This commit is contained in:
Mikaël Capelle 2021-10-04 11:20:23 +02:00
parent 33bf6496c9
commit fe61c179cd
6 changed files with 20 additions and 14 deletions

View File

@ -7,4 +7,5 @@ steps:
- name: python-tests - name: python-tests
image: themattrix/tox image: themattrix/tox
commands: commands:
- tox # python 3.9 is not included in themattrix/tox yet
- tox -e py36,py37,py38,py36-lint,py37-lint,py38-lint

View File

@ -1,13 +1,16 @@
# Simplex dictionary # Simplex dictionary
[![Python Versions](https://img.shields.io/badge/python-3.6%20|%203.7-blue.svg)](https://img.shields.io/badge/python-3.6%20|%203.7-blue.svg) [![Python Versions](https://img.shields.io/badge/python-3.6%20|%203.7-blue.svg)](https://img.shields.io/badge/python-3.6%20|%203.7%20|%203.8%20|%203.9-blue.svg)
[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://img.shields.io/badge/license-MIT-green.svg) [![License](https://img.shields.io/badge/license-MIT-green.svg)](https://img.shields.io/badge/license-MIT-green.svg)
[![Build Status](https://drone.typename.fr/api/badges/mikael.capelle/simplex/status.svg)](https://drone.typename.fr/mikael.capelle/simplex) [![Build Status](https://drone.typename.fr/api/badges/mikael.capelle/simplex/status.svg)](https://drone.typename.fr/mikael.capelle/simplex)
`simplex` is a small python module that implements a `simplex_dictionary` structure representing `simplex` is a small python module that implements a `simplex_dictionary` structure
a dictionary for the [Simplex algorithm](https://en.wikipedia.org/wiki/Simplex_algorithm). representing a dictionary for the
[Simplex algorithm](https://en.wikipedia.org/wiki/Simplex_algorithm).
The package is intended for educational purpose, e.g., to have students implement the
Simplex algorithm based on the structure.
# Basic usage ## Basic usage
The following code creates a simplex dictionary with 5 variables: The following code creates a simplex dictionary with 5 variables:
@ -38,10 +41,15 @@ sdict.z = 0
# Coefficients of the non-basic variables in the objective function: # Coefficients of the non-basic variables in the objective function:
sdict.c[x1] = 3 sdict.c[x1] = 3
sdict.c[x2] = 2 sdict.c[x2] = 2
# Trying to set the coefficients for a basic variables that should be 0 raise an
# exception:
sdict.c[x3] = 4 # raises "x_3 is not a non-basic variable."
sdict.b[x1] = 1 # raises "x_1 is not a basic variable."
``` ```
When using the `simplex` module within a jupyter notebook, the `display()` method outputs When using the `simplex` module within a jupyter notebook, the `display()` method
a latex version of the dictionary: outputs a latex version of the dictionary:
```python ```python
sdict.display(name='S_0') sdict.display(name='S_0')

View File

@ -9,14 +9,11 @@ extend-ignore =
warn_return_any = True warn_return_any = True
warn_unused_configs = True warn_unused_configs = True
[mypy-pytest.*]
ignore_missing_imports = True
[mypy-IPython.*] [mypy-IPython.*]
ignore_missing_imports = True ignore_missing_imports = True
[tox:tox] [tox:tox]
envlist = py{36,37,38},py{36,37,38}-lint envlist = py{36,37,38,39},py{36,37,38,39}-lint
[testenv] [testenv]
deps = deps =
@ -24,13 +21,14 @@ deps =
commands = commands =
pytest tests pytest tests
[testenv:py{36,37,38}-lint] [testenv:py{36,37,38,39}-lint]
deps = deps =
black black
flake8 flake8
flake8-black flake8-black
mypy mypy
isort isort
commands = commands =
black --check --diff setup.py simplex tests black --check --diff setup.py simplex tests
flake8 simplex tests flake8 simplex tests

View File

@ -8,7 +8,7 @@ with open("README.md", "r") as fh:
test_requires = ["pytest", "mypy", "black", "flake8", "flake8-black"] test_requires = ["pytest", "mypy", "black", "flake8", "flake8-black"]
setuptools.setup( setuptools.setup(
name="simplex", # Replace with your own username name="simplex-dictionary",
version="0.0.1", version="0.0.1",
author="Mikaël Capelle", author="Mikaël Capelle",
author_email="capelle.mikael@gmail.com", author_email="capelle.mikael@gmail.com",

View File

@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*- # -*- encoding: utf-8 -*-
from .simplex_dictionary import simplex_dictionary # noqa: F401 from .simplex_dictionary import simplex_dictionary # noqa: F401

0
simplex/py.typed Normal file
View File