Skip to content

Commit

Permalink
PEP8
Browse files Browse the repository at this point in the history
  • Loading branch information
endolith committed Apr 14, 2024
1 parent ee10c4f commit 6a99c8d
Show file tree
Hide file tree
Showing 15 changed files with 56 additions and 35 deletions.
6 changes: 4 additions & 2 deletions tests/test_approval.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import random

import numpy as np
import pytest
from hypothesis import given
from hypothesis.strategies import integers, tuples
from hypothesis.extra.numpy import arrays
from hypothesis.strategies import integers, tuples

from elsim.methods import approval, combined_approval


Expand Down Expand Up @@ -182,7 +184,7 @@ def test_invalid(method):
if __name__ == "__main__":
# Run unit tests, in separate process to avoid warnings about cached
# modules, printing output line by line in realtime
from subprocess import Popen, PIPE
from subprocess import PIPE, Popen
with Popen(['pytest',
'--tb=short', # shorter traceback format
'--hypothesis-show-statistics',
Expand Down
3 changes: 2 additions & 1 deletion tests/test_black.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import pytest
from hypothesis import given
from hypothesis.strategies import integers, lists, permutations

from elsim.methods import black


Expand Down Expand Up @@ -152,7 +153,7 @@ def test_legit_winner_none(election):
if __name__ == "__main__":
# Run unit tests, in separate process to avoid warnings about cached
# modules, printing output line by line in realtime
from subprocess import Popen, PIPE
from subprocess import PIPE, Popen
with Popen(['pytest',
'--tb=short', # shorter traceback format
'--hypothesis-show-statistics',
Expand Down
4 changes: 3 additions & 1 deletion tests/test_borda.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import random

import numpy as np
import pytest
from hypothesis import given
from hypothesis.strategies import integers, lists, permutations

from elsim.methods import borda


Expand Down Expand Up @@ -184,7 +186,7 @@ def test_legit_winner_none(election):
if __name__ == "__main__":
# Run unit tests, in separate process to avoid warnings about cached
# modules, printing output line by line in realtime
from subprocess import Popen, PIPE
from subprocess import PIPE, Popen
with Popen(['pytest',
'--tb=short', # shorter traceback format
'--hypothesis-show-statistics',
Expand Down
5 changes: 3 additions & 2 deletions tests/test_condorcet.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import numpy as np
from numpy.testing import assert_array_equal
import pytest
from hypothesis import given
from hypothesis.strategies import integers, lists, permutations
from numpy.testing import assert_array_equal

from elsim.methods import (condorcet, condorcet_from_matrix,
ranked_election_to_matrix)

Expand Down Expand Up @@ -304,7 +305,7 @@ def test_ranked_election_to_matrix(election):
if __name__ == "__main__":
# Run unit tests, in separate process to avoid warnings about cached
# modules, printing output line by line in realtime
from subprocess import Popen, PIPE
from subprocess import PIPE, Popen
with Popen(['pytest',
'--tb=short', # shorter traceback format
'--hypothesis-show-statistics',
Expand Down
6 changes: 4 additions & 2 deletions tests/test_coombs.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import random

import numpy as np
import pytest
from hypothesis.strategies import integers, permutations, lists
from hypothesis import given
from hypothesis.strategies import integers, lists, permutations

from elsim.methods import coombs


Expand Down Expand Up @@ -219,7 +221,7 @@ def test_legit_winner_none(election):
if __name__ == "__main__":
# Run unit tests, in separate process to avoid warnings about cached
# modules, printing output line by line in realtime
from subprocess import Popen, PIPE
from subprocess import PIPE, Popen
with Popen(['pytest',
'--tb=short', # shorter traceback format
'--hypothesis-show-statistics',
Expand Down
11 changes: 6 additions & 5 deletions tests/test_elections.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import numpy as np
from numpy.testing import (assert_array_equal, assert_array_less,
assert_allclose)
import pytest
from elsim.elections import (random_utilities, impartial_culture,
normal_electorate, normed_dist_utilities)
from numpy.testing import (assert_allclose, assert_array_equal,
assert_array_less)

from elsim.elections import (impartial_culture, normal_electorate,
normed_dist_utilities, random_utilities)


def test_random_utilities():
Expand Down Expand Up @@ -134,7 +135,7 @@ def test_invalid_random_state(func):
if __name__ == "__main__":
# Run unit tests, in separate process to avoid warnings about cached
# modules, printing output line by line in realtime
from subprocess import Popen, PIPE
from subprocess import PIPE, Popen
with Popen(['pytest',
'--tb=short', # shorter traceback format
'--hypothesis-show-statistics',
Expand Down
4 changes: 3 additions & 1 deletion tests/test_fptp.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import random

import numpy as np
import pytest
from hypothesis import given
from hypothesis.strategies import integers, lists, permutations

from elsim.methods import fptp


Expand Down Expand Up @@ -222,7 +224,7 @@ def test_legit_winner_none_single_mark(election):
if __name__ == "__main__":
# Run unit tests, in separate process to avoid warnings about cached
# modules, printing output line by line in realtime
from subprocess import Popen, PIPE
from subprocess import PIPE, Popen
with Popen(['pytest',
'--tb=short', # shorter traceback format
'--hypothesis-show-statistics',
Expand Down
4 changes: 2 additions & 2 deletions tests/test_irv.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import numpy as np
import pytest
from hypothesis.strategies import integers, permutations, lists
from hypothesis import given
from hypothesis.strategies import integers, lists, permutations

from elsim.methods import irv

Expand Down Expand Up @@ -285,7 +285,7 @@ def test_legit_winner_none(election):
if __name__ == "__main__":
# Run unit tests, in separate process to avoid warnings about cached
# modules, printing output line by line in realtime
from subprocess import Popen, PIPE
from subprocess import PIPE, Popen
with Popen(['pytest',
'--tb=short', # shorter traceback format
'--hypothesis-show-statistics',
Expand Down
7 changes: 4 additions & 3 deletions tests/test_methods.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pytest
from elsim.methods import (black, borda, fptp, runoff, irv, coombs, approval,
combined_approval, utility_winner, score)

from elsim.methods import (approval, black, borda, combined_approval, coombs,
fptp, irv, runoff, score, utility_winner)


@pytest.mark.parametrize("method", [black, borda, fptp, runoff, irv, coombs,
Expand Down Expand Up @@ -37,7 +38,7 @@ def test_ranked_method_unanimity(method):
if __name__ == "__main__":
# Run unit tests, in separate process to avoid warnings about cached
# modules, printing output line by line in realtime
from subprocess import Popen, PIPE
from subprocess import PIPE, Popen
with Popen(['pytest',
'--tb=short', # shorter traceback format
'--hypothesis-show-statistics',
Expand Down
4 changes: 2 additions & 2 deletions tests/test_runoff.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import numpy as np
import pytest
from hypothesis.strategies import integers, permutations, lists
from hypothesis import given
from hypothesis.strategies import integers, lists, permutations

from elsim.methods import runoff

Expand Down Expand Up @@ -202,7 +202,7 @@ def test_legit_winner_none(election):
if __name__ == "__main__":
# Run unit tests, in separate process to avoid warnings about cached
# modules, printing output line by line in realtime
from subprocess import Popen, PIPE
from subprocess import PIPE, Popen
with Popen(['pytest',
'--tb=short', # shorter traceback format
'--hypothesis-show-statistics',
Expand Down
6 changes: 4 additions & 2 deletions tests/test_score.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import random

import numpy as np
import pytest
from hypothesis import given
from hypothesis.strategies import integers, tuples
from hypothesis.extra.numpy import arrays
from hypothesis.strategies import integers, tuples

from elsim.methods import score


Expand Down Expand Up @@ -169,7 +171,7 @@ def test_invalid(method):
if __name__ == "__main__":
# Run unit tests, in separate process to avoid warnings about cached
# modules, printing output line by line in realtime
from subprocess import Popen, PIPE
from subprocess import PIPE, Popen
with Popen(['pytest',
'--tb=short', # shorter traceback format
'--hypothesis-show-statistics',
Expand Down
4 changes: 3 additions & 1 deletion tests/test_sntv.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import random

import numpy as np
import pytest
from hypothesis import given
from hypothesis.strategies import integers, lists, permutations

from elsim.methods import sntv


Expand Down Expand Up @@ -292,7 +294,7 @@ def test_defaults(election):
if __name__ == "__main__":
# Run unit tests, in separate process to avoid warnings about cached
# modules, printing output line by line in realtime
from subprocess import Popen, PIPE
from subprocess import PIPE, Popen
with Popen(['pytest',
'--tb=short', # shorter traceback format
'--hypothesis-show-statistics',
Expand Down
11 changes: 7 additions & 4 deletions tests/test_star.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import random

import numpy as np
from numpy.testing import assert_array_equal
import pytest
from hypothesis import given
from elsim.methods import star, matrix_from_scores
import test_score
from hypothesis import given
from numpy.testing import assert_array_equal

from elsim.methods import matrix_from_scores, star

score_ballots = test_score.score_ballots


Expand Down Expand Up @@ -630,7 +633,7 @@ def test_matrix_from_scores_properties(election, method):
if __name__ == "__main__":
# Run unit tests, in separate process to avoid warnings about cached
# modules, printing output line by line in realtime
from subprocess import Popen, PIPE
from subprocess import PIPE, Popen
with Popen(['pytest',
'--tb=short', # shorter traceback format
'--hypothesis-show-statistics',
Expand Down
10 changes: 5 additions & 5 deletions tests/test_strategies.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import numpy as np
from numpy.testing import assert_array_equal
import pytest
from hypothesis import given
from hypothesis.strategies import integers, tuples, floats
from hypothesis.extra.numpy import arrays
from elsim.strategies import (approval_optimal, vote_for_k,
honest_normed_scores)
from hypothesis.strategies import floats, integers, tuples
from numpy.testing import assert_array_equal

from elsim.strategies import approval_optimal, honest_normed_scores, vote_for_k


def test_approval_optimal():
Expand Down Expand Up @@ -114,7 +114,7 @@ def test_honest_normed_scores_properties(utilities, max_score):
if __name__ == "__main__":
# Run unit tests, in separate process to avoid warnings about cached
# modules, printing output line by line in realtime
from subprocess import Popen, PIPE
from subprocess import PIPE, Popen
with Popen(['pytest',
'--tb=short', # shorter traceback format
'--hypothesis-show-statistics',
Expand Down
6 changes: 4 additions & 2 deletions tests/test_utility_winner.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import random

import numpy as np
import pytest
from hypothesis import given
from hypothesis.strategies import integers, tuples, floats
from hypothesis.extra.numpy import arrays
from hypothesis.strategies import floats, integers, tuples

from elsim.methods import utility_winner


Expand Down Expand Up @@ -101,7 +103,7 @@ def test_legit_winner_no_tiebreaker(election):
if __name__ == "__main__":
# Run unit tests, in separate process to avoid warnings about cached
# modules, printing output line by line in realtime
from subprocess import Popen, PIPE
from subprocess import PIPE, Popen
with Popen(['pytest',
'--tb=short', # shorter traceback format
'--hypothesis-show-statistics',
Expand Down

0 comments on commit 6a99c8d

Please sign in to comment.