-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'improve_coding_style' into 'devel'
Improve coding style See merge request loads-kernel/loads-kernel!67
- Loading branch information
Showing
75 changed files
with
6,043 additions
and
5,678 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[flake8] | ||
# Use less conservative limit for max. line length, we all have wider screens today. | ||
max-line-length = 127 | ||
max-complexity = 15 | ||
# E741 - allow ambiguous variable names such as 'l'. | ||
# W503 - line breaks should occur before the binary operator (this will become best-practise in the furture) | ||
ignore = E741, W503 | ||
|
||
# Exclude some directories | ||
exclude = | ||
./virtualenv | ||
|
||
# Deactivate too-complex warning(s) | ||
per-file-ignores = | ||
./loadskernel/trim_conditions.py:C901 | ||
./loadskernel/solution_sequences.py:C901 | ||
./loadskernel/plotting_extra.py:C901 | ||
./doc/jcl_template.py:E261 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# This workflow will install and then lint the code with Flake8 and Pylint. | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | ||
|
||
name: Coding style | ||
|
||
on: | ||
push: | ||
branches: ['master', 'devel'] | ||
pull_request: | ||
branches: '*' | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
Flake8: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
# Add multiple Python versions here to run tests on new(er) versions. | ||
python-version: ["3.8"] | ||
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: Lint with flake8 | ||
run: | | ||
# stop the build if there are Python syntax errors or undefined names | ||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | ||
# The GitHub editor is 127 chars wide | ||
flake8 . --count --statistics | ||
Pylint: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
# Add multiple Python versions here to run tests on new(er) versions. | ||
python-version: ["3.8"] | ||
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 pylint | ||
# Install the package itself to make sure that all imports work. | ||
pip install . | ||
- name: Analysing the code with pylint | ||
run: | | ||
pylint $(git ls-files '*.py') --fail-under=7.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# This workflow will install and then lint the code with Flake8 and Pylint. | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | ||
|
||
name: Regression Tests | ||
|
||
on: | ||
push: | ||
branches: ['master', 'devel'] | ||
pull_request: | ||
branches: '*' | ||
|
||
jobs: | ||
pip-installation: | ||
# This stage only tests if the installation is possible. | ||
# The evironment created herein will be discared and re-created in the test stage. | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
# Add multiple Python versions here to run tests on new(er) versions. | ||
python-version: ["3.8"] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Build and install | ||
run: | | ||
python -m pip install --upgrade pip | ||
# Install with -e (in editable mode) to allow the tracking of the test coverage | ||
pip install -e . | ||
# Check result of installation | ||
which loads-kernel | ||
which model-viewer | ||
which loads-compare | ||
Jupyter: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
# Add multiple Python versions here to run tests on new(er) versions. | ||
python-version: ["3.8"] | ||
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 jupyter-book | ||
pip install . | ||
- name: Assemble the tutorials to a jupyter book and build htlm pages | ||
run: | | ||
jupyter-book build ./doc/tutorials | ||
# Put the html into a 2nd-level sub-folder and use 1st-level subfolder for uploading | ||
mkdir ./doc/html | ||
mv ./doc/tutorials/_build/html ./doc/html/tutorials | ||
- name: Upload Jupyter book as an artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: tutorials | ||
path: ./doc/html | ||
if-no-files-found: ignore | ||
- name: Upload Jupyter book for pages | ||
# This is not a normal artifact but one that can be deployed to the GitHub pages in the next step | ||
uses: actions/upload-pages-artifact@v3 | ||
with: | ||
name: github-pages # This name may not be changed according to the documentation | ||
path: ./doc/html | ||
if-no-files-found: ignore | ||
|
||
deploy-pages: | ||
# Add a dependency to the build job | ||
needs: Jupyter | ||
|
||
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment | ||
permissions: | ||
pages: write # to deploy to Pages | ||
id-token: write # to verify the deployment originates from an appropriate source | ||
|
||
# Deploy to the github-pages environment | ||
environment: | ||
name: github-pages | ||
url: ${{ steps.deployment.outputs.page_url }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Setup GitHub Pages | ||
uses: actions/configure-pages@v4 | ||
- name: Deploy to Pages | ||
id: deployment | ||
uses: actions/deploy-pages@v4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[MESSAGES CONTROL] | ||
# Disable the message, report, category or checker with the given id(s). | ||
# C0103 - doesn't conform to snake_case naming style | ||
# C0114/5/6 - Missing docstring | ||
# W0105 - pointless-string-statement, disable it if you're using those strings as documentation, instead of comments. | ||
disable=C0103,C0114,C0115,C0116,W0105 | ||
|
||
# Set same max. line length as with Flake8 | ||
max-line-length=127 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,24 @@ | ||
''' | ||
This is a template for an EFCS. For each aircraft, an EFCS must be written which maps the pilot | ||
commands to control surface deflections Ux2. This is because every aircraft has different control | ||
surfaces (e.g. one or two elevators, multiple ailerons, etc.) | ||
This is a template for an EFCS. For each aircraft, an EFCS must be written which maps the pilot | ||
commands to control surface deflections Ux2. This is because every aircraft has different control | ||
surfaces (e.g. one or two elevators, multiple ailerons, etc.) | ||
''' | ||
import numpy as np | ||
|
||
class Efcs: | ||
|
||
class Efcs(): | ||
|
||
def __init__(self): | ||
self.keys = ['dummy'] | ||
self.Ux2 = np.array([0.0]) | ||
|
||
def cs_mapping(self, commands): | ||
""" | ||
Do nothing in particular, this is just a dummy EFCS. | ||
command_xi = commands[0] | ||
command_xi = commands[0] | ||
command_eta = commands[1] | ||
command_zeta = commands[2] | ||
... | ||
""" | ||
|
||
|
||
return self.Ux2 | ||
|
||
return self.Ux2 |
Oops, something went wrong.