From e5a112dd0284063aff2ecc7318ef32149ef7d181 Mon Sep 17 00:00:00 2001 From: Simon Bowly Date: Tue, 6 Jun 2023 09:09:10 +1000 Subject: [PATCH] Apply isort Apply isort to all python source files Add isort with profile=black to pre-commit config --- .pre-commit-config.yaml | 4 ++++ pyproject.toml | 3 +++ src/gurobi_optimods/bipartite_matching.py | 5 ++--- src/gurobi_optimods/min_cost_flow.py | 4 ++-- src/gurobi_optimods/mwis.py | 3 +-- src/gurobi_optimods/portfolio.py | 3 ++- src/gurobi_optimods/qubo.py | 2 +- tests/test_min_cost_flow.py | 2 +- tests/test_mwis.py | 4 ++-- tests/test_portfolio.py | 3 ++- tests/test_qubo.py | 3 ++- tests/test_workforce.py | 4 ++-- 12 files changed, 24 insertions(+), 16 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 24c57cf6..30238207 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,3 +9,7 @@ repos: rev: 22.6.0 hooks: - id: black +- repo: https://github.com/pycqa/isort + rev: 5.12.0 + hooks: + - id: isort diff --git a/pyproject.toml b/pyproject.toml index 3e9fe968..493b16ae 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,3 +40,6 @@ examples = [ [tool.hatch.version] path = "src/gurobi_optimods/__init__.py" + +[tool.isort] +profile = "black" diff --git a/src/gurobi_optimods/bipartite_matching.py b/src/gurobi_optimods/bipartite_matching.py index 89178945..6dee1922 100644 --- a/src/gurobi_optimods/bipartite_matching.py +++ b/src/gurobi_optimods/bipartite_matching.py @@ -7,13 +7,12 @@ import logging from typing import List, overload +import gurobipy as gp +import gurobipy_pandas as gppd import numpy as np import pandas as pd import scipy.sparse as sp - -import gurobipy as gp from gurobipy import GRB -import gurobipy_pandas as gppd try: import networkx as nx diff --git a/src/gurobi_optimods/min_cost_flow.py b/src/gurobi_optimods/min_cost_flow.py index fae48e3c..7a60649a 100644 --- a/src/gurobi_optimods/min_cost_flow.py +++ b/src/gurobi_optimods/min_cost_flow.py @@ -6,11 +6,11 @@ import logging import gurobipy as gp +import gurobipy_pandas as gppd # noqa: F401 import numpy as np import pandas as pd -from gurobipy import GRB import scipy.sparse as sp -import gurobipy_pandas as gppd # noqa: F401 +from gurobipy import GRB try: import networkx as nx diff --git a/src/gurobi_optimods/mwis.py b/src/gurobi_optimods/mwis.py index c5c7628c..12d5d580 100644 --- a/src/gurobi_optimods/mwis.py +++ b/src/gurobi_optimods/mwis.py @@ -3,9 +3,8 @@ -------------------------------- """ -import numpy as np - import gurobipy as gp +import numpy as np from gurobipy import GRB from gurobi_optimods.utils import optimod diff --git a/src/gurobi_optimods/portfolio.py b/src/gurobi_optimods/portfolio.py index 8b7ae68c..128273e6 100644 --- a/src/gurobi_optimods/portfolio.py +++ b/src/gurobi_optimods/portfolio.py @@ -5,10 +5,11 @@ from dataclasses import dataclass from typing import Optional + import gurobipy as gp -from gurobipy import GRB import numpy as np import pandas as pd +from gurobipy import GRB from gurobi_optimods.utils import optimod diff --git a/src/gurobi_optimods/qubo.py b/src/gurobi_optimods/qubo.py index 22fe0f90..755c3692 100644 --- a/src/gurobi_optimods/qubo.py +++ b/src/gurobi_optimods/qubo.py @@ -7,8 +7,8 @@ from dataclasses import dataclass import gurobipy as gp -from gurobipy import GRB import numpy as np +from gurobipy import GRB from gurobi_optimods.utils import optimod diff --git a/tests/test_min_cost_flow.py b/tests/test_min_cost_flow.py index ebadecc6..5add75c2 100644 --- a/tests/test_min_cost_flow.py +++ b/tests/test_min_cost_flow.py @@ -13,9 +13,9 @@ import gurobi_optimods.min_cost_flow as mcf from .test_graph_utils import ( + check_solution_networkx, check_solution_pandas, check_solution_scipy, - check_solution_networkx, ) diff --git a/tests/test_mwis.py b/tests/test_mwis.py index 2be64c9e..beb8e941 100644 --- a/tests/test_mwis.py +++ b/tests/test_mwis.py @@ -1,8 +1,8 @@ import unittest - from itertools import combinations -import scipy.sparse as sp + import numpy as np +import scipy.sparse as sp from numpy.testing import assert_array_equal from gurobi_optimods.mwis import maximum_weighted_independent_set diff --git a/tests/test_portfolio.py b/tests/test_portfolio.py index 3489b81e..d41dd9d0 100644 --- a/tests/test_portfolio.py +++ b/tests/test_portfolio.py @@ -1,8 +1,9 @@ -from contextlib import redirect_stdout import io import os import tempfile import unittest +from contextlib import redirect_stdout + import numpy as np import pandas as pd from numpy.testing import assert_allclose, assert_array_equal diff --git a/tests/test_qubo.py b/tests/test_qubo.py index 1c61f24b..c035ff78 100644 --- a/tests/test_qubo.py +++ b/tests/test_qubo.py @@ -1,7 +1,8 @@ import unittest + import numpy as np -from numpy.testing import assert_array_equal import scipy.sparse as sp +from numpy.testing import assert_array_equal from gurobi_optimods.qubo import solve_qubo diff --git a/tests/test_workforce.py b/tests/test_workforce.py index c3f06276..ca819125 100644 --- a/tests/test_workforce.py +++ b/tests/test_workforce.py @@ -3,11 +3,11 @@ from textwrap import dedent import pandas as pd -from pandas.api.types import is_object_dtype, is_datetime64_any_dtype, is_numeric_dtype +from pandas.api.types import is_datetime64_any_dtype, is_numeric_dtype, is_object_dtype from pandas.testing import assert_frame_equal -from gurobi_optimods.workforce import solve_workforce_scheduling from gurobi_optimods.datasets import load_workforce +from gurobi_optimods.workforce import solve_workforce_scheduling def read_csv(text):