Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added isort, ran isort on all files #1351

Merged
merged 8 commits into from
Jun 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ jobs:
run: |
python -m pip install mypy
python run_mypy.py
- name: Check imports are sorted
run: |
python -m pip install isort
python -m isort --check-only
- name: Check that all strategies are indexed
run: |
python run_strategy_indexer.py
Expand Down
7 changes: 7 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[settings]
default_section = THIRDPARTY
multi_line_output = 3
include_trailing_comma = True
force_grid_wrap = 0
combine_as_imports = True
line_length = 88
2 changes: 1 addition & 1 deletion .prepare-commit-msg.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
# Any issue numbers created by this hook (or entered manually in the correct)
# format will now be clickable links in the log view.

import sys
import re
import sys
from subprocess import check_output

# By default, the hook will check to see if the branch name starts with
Expand Down
1 change: 1 addition & 0 deletions axelrod/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# isort:skip_file
DEFAULT_TURNS = 200

# The order of imports matters!
Expand Down
4 changes: 2 additions & 2 deletions axelrod/classifier.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import warnings
from typing import (
Any,
Callable,
Expand All @@ -11,9 +12,8 @@
TypeVar,
Union,
)
import warnings
import yaml

import yaml
from axelrod.player import Player

ALL_CLASSIFIERS_PATH = "data/all_classifiers.yml"
Expand Down
6 changes: 3 additions & 3 deletions axelrod/compute_finite_state_machine_memory.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from axelrod.action import Action
from collections import defaultdict, namedtuple
from typing import DefaultDict, Iterator, Dict, Tuple, Set, List
from typing import DefaultDict, Dict, Iterator, List, Set, Tuple

from axelrod.action import Action

C, D = Action.C, Action.D

Expand Down Expand Up @@ -263,4 +264,3 @@ def get_memory_from_transitions(
if len(next_action_set) == 1:
return 0
return 1

1 change: 1 addition & 0 deletions axelrod/deterministic_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from typing import List, Tuple

from axelrod import Classifiers

from .action import Action
from .player import Player

Expand Down
1 change: 1 addition & 0 deletions axelrod/evolvable_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from pickle import dumps, loads
from random import randrange
from typing import Dict, List

from .player import Player


Expand Down
5 changes: 2 additions & 3 deletions axelrod/fingerprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@
from tempfile import mkstemp
from typing import Any, List, Union

import axelrod as axl
import dask.dataframe as dd
import matplotlib.pyplot as plt
import numpy as np
import tqdm
from mpl_toolkits.axes_grid1 import make_axes_locatable

import axelrod as axl
from axelrod import Player
from axelrod.interaction_utils import (
compute_final_score_per_turn,
read_interactions_from_file,
)
from axelrod.strategy_transformers import DualTransformer, JossAnnTransformer
from mpl_toolkits.axes_grid1 import make_axes_locatable

Point = namedtuple("Point", "x y")

Expand Down
4 changes: 2 additions & 2 deletions axelrod/match.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
from math import ceil, log

import axelrod.interaction_utils as iu
from axelrod import DEFAULT_TURNS
from axelrod import DEFAULT_TURNS, Classifiers
from axelrod.action import Action
from axelrod import Classifiers
from axelrod.game import Game

from .deterministic_cache import DeterministicCache

C, D = Action.C, Action.D
Expand Down
2 changes: 1 addition & 1 deletion axelrod/moran.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import matplotlib.pyplot as plt
import numpy as np
from axelrod import EvolvablePlayer, DEFAULT_TURNS, Game, Player
from axelrod import DEFAULT_TURNS, EvolvablePlayer, Game, Player

from .deterministic_cache import DeterministicCache
from .graph import Graph, complete_graph
Expand Down
1 change: 0 additions & 1 deletion axelrod/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from typing import Any, Dict

import numpy as np

from axelrod.action import Action
from axelrod.game import DefaultGame
from axelrod.history import History
Expand Down
4 changes: 2 additions & 2 deletions axelrod/plot.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import pathlib
from distutils.version import LooseVersion
from typing import List, Union

import matplotlib
import matplotlib.pyplot as plt
import matplotlib.transforms as transforms
import pathlib
import tqdm
from numpy import arange, median, nan_to_num

from .result_set import ResultSet
from .load_data_ import axl_filename
from .result_set import ResultSet

titleType = List[str]
namesType = List[str]
Expand Down
3 changes: 1 addition & 2 deletions axelrod/random_.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import random

import numpy as np
from numpy.random import choice

from axelrod.action import Action
from numpy.random import choice

C, D = Action.C, Action.D

Expand Down
9 changes: 4 additions & 5 deletions axelrod/result_set.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
from collections import Counter, namedtuple
import csv
import itertools
import warnings
from collections import Counter, namedtuple
from multiprocessing import cpu_count
from typing import List
import warnings

import dask as da
import dask.dataframe as dd
import numpy as np
import tqdm
from axelrod.action import Action

import dask as da
import dask.dataframe as dd

from . import eigen

C, D = Action.C, Action.D
Expand Down
1 change: 1 addition & 0 deletions axelrod/strategies/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# isort:skip_file
from ..classifier import Classifiers
from ._strategies import *
from ._filters import passes_filterset
Expand Down
1 change: 1 addition & 0 deletions axelrod/strategies/_strategies.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
ReactivePlayer,
MemoryOnePlayer
)
# isort:skip_file
"""
from .adaptive import Adaptive
from .adaptor import AdaptorBrief, AdaptorLong
Expand Down
1 change: 0 additions & 1 deletion axelrod/strategies/adaptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from axelrod.action import Action
from axelrod.player import Player
from axelrod.random_ import random_choice

from numpy import heaviside

C, D = Action.C, Action.D
Expand Down
9 changes: 6 additions & 3 deletions axelrod/strategies/ann.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
from typing import List, Tuple

import numpy as np
import numpy.random as random
from axelrod.action import Action
from axelrod.evolvable_player import (
EvolvablePlayer,
InsufficientParametersError,
crossover_lists,
)
from axelrod.load_data_ import load_weights
from axelrod.evolvable_player import EvolvablePlayer, InsufficientParametersError, crossover_lists
from axelrod.player import Player


C, D = Action.C, Action.D
nn_weights = load_weights()

Expand Down Expand Up @@ -347,4 +351,3 @@ def __init__(self) -> None:
num_features=num_features,
num_hidden=num_hidden,
weights=weights)

2 changes: 1 addition & 1 deletion axelrod/strategies/axelrod_first.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"""

import random
from typing import Dict, List, Tuple, Optional
from typing import Dict, List, Optional, Tuple

from axelrod.action import Action
from axelrod.player import Player
Expand Down
6 changes: 5 additions & 1 deletion axelrod/strategies/cycler.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
from typing import List, Tuple

from axelrod.action import Action, actions_to_str, str_to_actions
from axelrod.evolvable_player import EvolvablePlayer, InsufficientParametersError, crossover_lists
from axelrod.evolvable_player import (
EvolvablePlayer,
InsufficientParametersError,
crossover_lists,
)
from axelrod.player import Player

C, D = Action.C, Action.D
Expand Down
9 changes: 7 additions & 2 deletions axelrod/strategies/finite_state_machines.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import itertools
from random import randrange
from typing import Any, List, Sequence, Tuple, Union

import numpy.random as random
from numpy.random import choice
from axelrod.action import Action
from axelrod.evolvable_player import EvolvablePlayer, InsufficientParametersError, copy_lists
from axelrod.evolvable_player import (
EvolvablePlayer,
InsufficientParametersError,
copy_lists,
)
from axelrod.player import Player
from numpy.random import choice

C, D = Action.C, Action.D
actions = (C, D)
Expand Down
11 changes: 8 additions & 3 deletions axelrod/strategies/gambler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@
import random
from typing import Any

from axelrod.action import Action, str_to_actions, actions_to_str
from axelrod.action import Action, actions_to_str, str_to_actions
from axelrod.load_data_ import load_pso_tables
from axelrod.player import Player

from axelrod.random_ import random_choice

from .lookerup import EvolvableLookerUp, LookupTable, LookerUp, Plays, create_lookup_table_keys
from .lookerup import (
EvolvableLookerUp,
LookerUp,
LookupTable,
Plays,
create_lookup_table_keys,
)

C, D = Action.C, Action.D
tables = load_pso_tables("pso_gambler.csv", directory="data")
Expand Down
11 changes: 8 additions & 3 deletions axelrod/strategies/hmm.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
from random import randrange
import numpy.random as random
from numpy.random import choice

import numpy.random as random
from axelrod.action import Action
from axelrod.evolvable_player import EvolvablePlayer, InsufficientParametersError, copy_lists, crossover_lists
from axelrod.evolvable_player import (
EvolvablePlayer,
InsufficientParametersError,
copy_lists,
crossover_lists,
)
from axelrod.player import Player
from axelrod.random_ import random_choice, random_vector
from numpy.random import choice

C, D = Action.C, Action.D

Expand Down
10 changes: 6 additions & 4 deletions axelrod/strategies/lookerup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
from typing import Any, TypeVar

import numpy.random as random
from numpy.random import choice

from axelrod.action import Action, actions_to_str, str_to_actions
from axelrod.evolvable_player import EvolvablePlayer, InsufficientParametersError, crossover_dictionaries
from axelrod.evolvable_player import (
EvolvablePlayer,
InsufficientParametersError,
crossover_dictionaries,
)
from axelrod.player import Player

from numpy.random import choice

C, D = Action.C, Action.D
actions = (C, D)
Expand Down
4 changes: 2 additions & 2 deletions axelrod/strategies/meta.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import random

import numpy as np
from numpy.random import choice

from axelrod.action import Action
from axelrod.classifier import Classifiers
from axelrod.player import Player
from axelrod.strategies import TitForTat
from axelrod.strategy_transformers import NiceTransformer
from numpy.random import choice

from ._strategies import all_strategies
from .hunter import (
AlternatorHunter,
Expand Down
1 change: 0 additions & 1 deletion axelrod/strategies/revised_downing.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,3 @@ def strategy(self, opponent: Player) -> Action:
else:
move = D
return move

6 changes: 3 additions & 3 deletions axelrod/strategy_transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
See the various Meta strategies for another type of transformation.
"""

from collections import Iterable
import copy
import inspect
from importlib import import_module
import random
from collections import Iterable
from importlib import import_module
from typing import Any

from axelrod.strategies.sequence_player import SequencePlayer
from numpy.random import choice

from axelrod.strategies.sequence_player import SequencePlayer
from .action import Action
from .player import Player
from .random_ import random_choice
Expand Down
1 change: 0 additions & 1 deletion axelrod/tests/integration/test_filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import axelrod as axl
from axelrod.tests.property import strategy_lists

from hypothesis import example, given, settings
from hypothesis.strategies import integers

Expand Down
1 change: 0 additions & 1 deletion axelrod/tests/integration/test_matches.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import axelrod as axl
from axelrod.tests.property import strategy_lists

from hypothesis import given, settings
from hypothesis.strategies import integers

Expand Down
Loading