diff --git a/.github/workflows/flake8.yml b/.github/workflows/flake8.yml new file mode 100644 index 0000000..f7c2a87 --- /dev/null +++ b/.github/workflows/flake8.yml @@ -0,0 +1,23 @@ +name: Pylint + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.10"] + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 + - name: Analysing the code with flake8 + run: | + flake8 $(git ls-files 'src/**.py') diff --git a/src/irlwpython/scripts/direct_train_deep_max_entropy_irl.py b/scripts/direct_train_deep_max_entropy_irl.py similarity index 99% rename from src/irlwpython/scripts/direct_train_deep_max_entropy_irl.py rename to scripts/direct_train_deep_max_entropy_irl.py index 212a7e8..eddd8cd 100644 --- a/src/irlwpython/scripts/direct_train_deep_max_entropy_irl.py +++ b/scripts/direct_train_deep_max_entropy_irl.py @@ -124,7 +124,7 @@ def get_demonstrations(self, env): env_high = env.observation_space.high env_distance = (env_high - env_low) / self.one_feature - raw_demo = np.load(file="../expert_demo/expert_demo.npy") + raw_demo = np.load(file="../src/irlwpython/expert_demo/expert_demo.npy") demonstrations = np.zeros((len(raw_demo), len(raw_demo[0]), 3)) for x in range(len(raw_demo)): for y in range(len(raw_demo[0])): diff --git a/src/irlwpython/scripts/direct_train_deep_max_entropy_rl.py b/scripts/direct_train_deep_max_entropy_rl.py similarity index 100% rename from src/irlwpython/scripts/direct_train_deep_max_entropy_rl.py rename to scripts/direct_train_deep_max_entropy_rl.py diff --git a/setup.cfg b/setup.cfg index b390e37..28d9d26 100644 --- a/setup.cfg +++ b/setup.cfg @@ -112,7 +112,7 @@ formats = bdist_wheel [flake8] # Some sane defaults for the code style checker flake8 -max_line_length = 88 +max_line_length = 120 extend_ignore = E203, W503 # ^ Black-compatible # E203 and W503 have edge cases handled by black diff --git a/src/irlwpython/MaxEntropyIRL.py b/src/irlwpython/MaxEntropyIRL.py index a692377..58d50d8 100644 --- a/src/irlwpython/MaxEntropyIRL.py +++ b/src/irlwpython/MaxEntropyIRL.py @@ -5,7 +5,6 @@ # import numpy as np -import matplotlib.pyplot as plt from irlwpython.FigurePrinter import FigurePrinter @@ -135,7 +134,8 @@ def train(self, theta_learning_rate, episode_count=30000): score_avg = np.mean(scores) print('{} episode score is {:.2f}'.format(episode, score_avg)) self.printer.save_plot_as_png(episodes, scores, - f"src/irlwpython/learning_curves/maxent_{episode_count}_{episode}_qtable.png") + f"src/irlwpython/learning_curves/" + f"maxent_{episode_count}_{episode}_qtable.png") self.printer.save_heatmap_as_png(learner.reshape((20, 20)), f"src/irlwpython/heatmap/learner_{episode}_flat.png") self.printer.save_heatmap_as_png(self.theta.reshape((20, 20)), diff --git a/src/irlwpython/main.py b/src/irlwpython/main.py index c04cb1b..91721e8 100644 --- a/src/irlwpython/main.py +++ b/src/irlwpython/main.py @@ -32,7 +32,8 @@ def parse_args(args): version=f"IRLwPython {__version__}", ) parser.add_argument('algorithm', metavar='ALGORITHM', type=str, - help='Currently supported training algorithm: [max-entropy, max-entropy-deep, max-entropy-deep-rl]') + help='Currently supported training algorithm: ' + '[max-entropy, max-entropy-deep, max-entropy-deep-rl]') parser.add_argument('--training', action='store_true', help="Enables training of model.") parser.add_argument('--testing', action='store_true', help="Enables testing of previously created model.")