[simplex] Fix formatting and typing.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
1bcdb494cf
commit
d994636ab4
@ -1,4 +1,6 @@
|
|||||||
|
---
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
name: default
|
name: default
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -11,3 +11,4 @@ __pycache__
|
|||||||
.mypy_cache
|
.mypy_cache
|
||||||
**/*.egg-info
|
**/*.egg-info
|
||||||
**/.eggs
|
**/.eggs
|
||||||
|
venv
|
||||||
|
@ -16,7 +16,7 @@ ignore_missing_imports = True
|
|||||||
ignore_missing_imports = True
|
ignore_missing_imports = True
|
||||||
|
|
||||||
[tox:tox]
|
[tox:tox]
|
||||||
envlist = py36,py37,py36-lint
|
envlist = py{36,37,38},py{36,37,38}-lint
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
deps =
|
deps =
|
||||||
@ -24,13 +24,15 @@ deps =
|
|||||||
commands =
|
commands =
|
||||||
pytest tests
|
pytest tests
|
||||||
|
|
||||||
[testenv:py36-lint]
|
[testenv:py{36,37,38}-lint]
|
||||||
deps =
|
deps =
|
||||||
black
|
black
|
||||||
flake8
|
flake8
|
||||||
flake8-black
|
flake8-black
|
||||||
mypy
|
mypy
|
||||||
|
isort
|
||||||
commands =
|
commands =
|
||||||
black --check --diff setup.py simplex tests
|
black --check --diff setup.py simplex tests
|
||||||
flake8 simplex tests
|
flake8 simplex tests
|
||||||
mypy simplex tests
|
mypy simplex tests
|
||||||
|
isort -c simplex tests setup.py
|
||||||
|
3
setup.py
3
setup.py
@ -5,7 +5,6 @@ import setuptools
|
|||||||
with open("README.md", "r") as fh:
|
with open("README.md", "r") as fh:
|
||||||
long_description = fh.read()
|
long_description = fh.read()
|
||||||
|
|
||||||
install_requires = []
|
|
||||||
test_requires = ["pytest", "mypy", "black", "flake8", "flake8-black"]
|
test_requires = ["pytest", "mypy", "black", "flake8", "flake8-black"]
|
||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
@ -18,7 +17,7 @@ setuptools.setup(
|
|||||||
long_description_content_type="text/markdown",
|
long_description_content_type="text/markdown",
|
||||||
url="https://gitea.typename.fr/mikael.capelle/simplex",
|
url="https://gitea.typename.fr/mikael.capelle/simplex",
|
||||||
packages=setuptools.find_packages(),
|
packages=setuptools.find_packages(),
|
||||||
install_requires=install_requires,
|
install_requires=[],
|
||||||
test_requires=test_requires,
|
test_requires=test_requires,
|
||||||
extras_require={"test": test_requires},
|
extras_require={"test": test_requires},
|
||||||
classifiers=[
|
classifiers=[
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- encoding: utf-8 -*-
|
||||||
|
|
||||||
# flake8: noqa
|
|
||||||
|
|
||||||
from .simplex_dictionary import simplex_dictionary
|
from .simplex_dictionary import simplex_dictionary # noqa: F401
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- encoding: utf-8 -*-
|
||||||
|
|
||||||
import typing
|
import typing
|
||||||
|
from abc import ABC, abstractmethod
|
||||||
from abc import abstractmethod, ABC
|
|
||||||
from fractions import Fraction
|
from fractions import Fraction
|
||||||
|
|
||||||
from .magic_dictionary import magic_dictionary
|
from .magic_dictionary import magic_dictionary
|
||||||
@ -105,7 +104,8 @@ class simplex_dictionary(typing.Generic[V]):
|
|||||||
@property
|
@property
|
||||||
def variables(self) -> typing.List[V]:
|
def variables(self) -> typing.List[V]:
|
||||||
"""
|
"""
|
||||||
Returns: The list of variables in this dictionary.
|
Returns:
|
||||||
|
The list of variables in this dictionary.
|
||||||
"""
|
"""
|
||||||
return sorted(self.B + self.N)
|
return sorted(self.B + self.N)
|
||||||
|
|
||||||
@ -119,14 +119,16 @@ class simplex_dictionary(typing.Generic[V]):
|
|||||||
@property
|
@property
|
||||||
def N(self) -> typing.List[V]:
|
def N(self) -> typing.List[V]:
|
||||||
"""
|
"""
|
||||||
Returns: The list of non-basic variables for this dictionary.
|
Returns:
|
||||||
|
The list of non-basic variables for this dictionary.
|
||||||
"""
|
"""
|
||||||
return self.__N
|
return self.__N
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def a(self) -> magic_dictionary[V, magic_dictionary[V, Fraction]]:
|
def a(self) -> magic_dictionary[V, magic_dictionary[V, Fraction]]:
|
||||||
"""
|
"""
|
||||||
Returns: The a matrix of this dictionary.
|
Returns:
|
||||||
|
The a matrix of this dictionary.
|
||||||
"""
|
"""
|
||||||
return self._a
|
return self._a
|
||||||
|
|
||||||
@ -236,7 +238,7 @@ class simplex_dictionary(typing.Generic[V]):
|
|||||||
Args:
|
Args:
|
||||||
name: Name of the dictionary.
|
name: Name of the dictionary.
|
||||||
"""
|
"""
|
||||||
from IPython.display import display, Math
|
from IPython.display import Math, display
|
||||||
|
|
||||||
d = (
|
d = (
|
||||||
r"\begin{{array}}{{r||{}}}".format("r|" * (1 + len(self.B)))
|
r"\begin{{array}}{{r||{}}}".format("r|" * (1 + len(self.B)))
|
||||||
|
@ -4,8 +4,10 @@ from simplex.magic_dictionary import magic_dictionary
|
|||||||
|
|
||||||
|
|
||||||
def test_basic():
|
def test_basic():
|
||||||
"""Tests that a non-customized magic_dictionary acts
|
"""
|
||||||
as a standard python dictionary."""
|
Tests that a non-customized magic_dictionary acts
|
||||||
|
as a standard python dictionary.
|
||||||
|
"""
|
||||||
|
|
||||||
d = magic_dictionary()
|
d = magic_dictionary()
|
||||||
assert len(d) == 0
|
assert len(d) == 0
|
||||||
@ -43,7 +45,9 @@ def test_basic():
|
|||||||
|
|
||||||
|
|
||||||
def test_value_converter():
|
def test_value_converter():
|
||||||
""" Tests that conversion is correctly done. """
|
"""
|
||||||
|
Tests that conversion is correctly done.
|
||||||
|
"""
|
||||||
|
|
||||||
# Convert a value to its string representation:
|
# Convert a value to its string representation:
|
||||||
def converter(x):
|
def converter(x):
|
||||||
|
Loading…
Reference in New Issue
Block a user