[simplex] Fix formatting and typing.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Mikael Capelle 2021-07-08 15:48:02 +02:00
parent 1bcdb494cf
commit d994636ab4
7 changed files with 25 additions and 16 deletions

View File

@ -1,4 +1,6 @@
---
kind: pipeline
type: docker
name: default
steps:

1
.gitignore vendored
View File

@ -11,3 +11,4 @@ __pycache__
.mypy_cache
**/*.egg-info
**/.eggs
venv

View File

@ -16,7 +16,7 @@ ignore_missing_imports = True
ignore_missing_imports = True
[tox:tox]
envlist = py36,py37,py36-lint
envlist = py{36,37,38},py{36,37,38}-lint
[testenv]
deps =
@ -24,13 +24,15 @@ deps =
commands =
pytest tests
[testenv:py36-lint]
[testenv:py{36,37,38}-lint]
deps =
black
flake8
flake8-black
mypy
isort
commands =
black --check --diff setup.py simplex tests
flake8 simplex tests
mypy simplex tests
isort -c simplex tests setup.py

View File

@ -5,7 +5,6 @@ import setuptools
with open("README.md", "r") as fh:
long_description = fh.read()
install_requires = []
test_requires = ["pytest", "mypy", "black", "flake8", "flake8-black"]
setuptools.setup(
@ -18,7 +17,7 @@ setuptools.setup(
long_description_content_type="text/markdown",
url="https://gitea.typename.fr/mikael.capelle/simplex",
packages=setuptools.find_packages(),
install_requires=install_requires,
install_requires=[],
test_requires=test_requires,
extras_require={"test": test_requires},
classifiers=[

View File

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

View File

@ -1,8 +1,7 @@
# -*- encoding: utf-8 -*-
import typing
from abc import abstractmethod, ABC
from abc import ABC, abstractmethod
from fractions import Fraction
from .magic_dictionary import magic_dictionary
@ -105,7 +104,8 @@ class simplex_dictionary(typing.Generic[V]):
@property
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)
@ -119,14 +119,16 @@ class simplex_dictionary(typing.Generic[V]):
@property
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
@property
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
@ -236,7 +238,7 @@ class simplex_dictionary(typing.Generic[V]):
Args:
name: Name of the dictionary.
"""
from IPython.display import display, Math
from IPython.display import Math, display
d = (
r"\begin{{array}}{{r||{}}}".format("r|" * (1 + len(self.B)))

View File

@ -4,8 +4,10 @@ from simplex.magic_dictionary import magic_dictionary
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()
assert len(d) == 0
@ -43,7 +45,9 @@ def test_basic():
def test_value_converter():
""" Tests that conversion is correctly done. """
"""
Tests that conversion is correctly done.
"""
# Convert a value to its string representation:
def converter(x):