-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added [dev] optional to package (pip install ".[dev]") - Added tools formatting & linting to the [dev] optional - Added script that runs these tools and applies fixes whenever able - Added CI that checks code using these tools - Adjusted code to pass checks (no functional changes)
- Loading branch information
1 parent
b00793e
commit a4444e6
Showing
10 changed files
with
482 additions
and
136 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,33 @@ | ||
name: ci | ||
|
||
on: [push, pull_request] | ||
|
||
env: | ||
PACKAGE: virtual_ship | ||
|
||
jobs: | ||
codetools: | ||
runs-on: ubuntu-20.04 | ||
strategy: | ||
matrix: | ||
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/[email protected] | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: install | ||
run: pip install ".[dev]" | ||
- name: flake8 | ||
run: flake8 ./$PACKAGE | ||
- name: pydocstyle | ||
run: pydocstyle ./$PACKAGE | ||
- name: sort-all | ||
run: | | ||
find ./$PACKAGE -type f -name '__init__.py' -print0 | xargs -0 sort-all | ||
[[ -z $(git status -s) ]] | ||
git checkout -- . | ||
- name: black | ||
run: black --diff --check ./$PACKAGE | ||
- name: isort | ||
run: isort --check-only --diff ./$PACKAGE |
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,38 @@ | ||
#!/bin/sh | ||
|
||
# Runs all codetools and attempts to apply fixes wherever possible. | ||
# Not suitable for the CI as that should not make any changes. | ||
|
||
set -e | ||
|
||
# Set working directory to the directory of this script. | ||
cd "$(dirname "$0")" | ||
|
||
PACKAGE=virtual_ship | ||
|
||
echo "--------------" | ||
echo "flake8" | ||
echo "--------------" | ||
flake8 ./$PACKAGE | ||
# darglint is ran as a plugin for flake8. | ||
|
||
echo "--------------" | ||
echo "pydocstyle" | ||
echo "--------------" | ||
pydocstyle ./$PACKAGE | ||
|
||
echo "--------------" | ||
echo "sort-all" | ||
echo "--------------" | ||
find ./$PACKAGE -type f -name '__init__.py' -print0 | xargs -0 sort-all | ||
|
||
echo "--------------" | ||
echo "black" | ||
echo "--------------" | ||
black ./$PACKAGE | ||
|
||
echo "--------------" | ||
echo "isort" | ||
echo "--------------" | ||
isort ./$PACKAGE | ||
|
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 @@ | ||
"""Code for the Virtual Ship Classroom, where Marine Scientists can combine Copernicus Marine Data with an OceanParcels ship to go on a virtual expedition.""" |
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 |
---|---|---|
@@ -1,13 +1,21 @@ | ||
"""costs function.""" | ||
|
||
|
||
def costs(config, total_time): | ||
'''Calculates cost of the virtual ship (in US$)''' | ||
""" | ||
Calculate the cost of the virtual ship (in US$). | ||
:param config: The cruise configuration. | ||
:param total_time: Time cruised in seconds. | ||
:returns: The calculated cost of the cruise. | ||
""" | ||
ship_cost_per_day = 30000 | ||
drifter_deploy_cost = 2500 | ||
argo_deploy_cost = 15000 | ||
|
||
ship_cost = ship_cost_per_day/24 * total_time//3600 | ||
ship_cost = ship_cost_per_day / 24 * total_time // 3600 | ||
argo_cost = len(config.argo_deploylocations) * argo_deploy_cost | ||
drifter_cost = len(config.drifter_deploylocations) * drifter_deploy_cost | ||
|
||
cost = ship_cost + argo_cost + drifter_cost | ||
return cost |
Oops, something went wrong.