Skip to content

Commit

Permalink
feat: flake8 Job (#13)
Browse files Browse the repository at this point in the history
* feat: Pylint Job

* only test for python 3.10

* Move direct scirpts out of src

* use flake8

* set max line length to 120

* fixe format
  • Loading branch information
HokageM authored Dec 7, 2023
1 parent f492208 commit cb70bf6
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 5 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/flake8.yml
Original file line number Diff line number Diff line change
@@ -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')
Original file line number Diff line number Diff line change
Expand Up @@ -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])):
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/irlwpython/MaxEntropyIRL.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#

import numpy as np
import matplotlib.pyplot as plt

from irlwpython.FigurePrinter import FigurePrinter

Expand Down Expand Up @@ -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)),
Expand Down
3 changes: 2 additions & 1 deletion src/irlwpython/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down

0 comments on commit cb70bf6

Please sign in to comment.