Skip to content

Commit

Permalink
Apply new pre-commit hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
fbriol committed Aug 12, 2022
1 parent cfeda0b commit f9bb3f8
Show file tree
Hide file tree
Showing 9 changed files with 176 additions and 127 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/conda-upload.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ name: Anaconda Upload

on:
push:
branches: "*"
pull_request:
branches: master
tags:
- '*'

jobs:
boa:
Expand Down
27 changes: 24 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
rev: v4.3.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: debug-statements
- id: double-quote-string-fixer
- id: mixed-line-ending
args: [--fix=lf]
exclude: docs/make.bat
- id: check-yaml
exclude: conda/meta.yaml
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v14.0.0
rev: v14.0.6
hooks:
- id: clang-format
args: ["--style", "Mozilla", "-i"]
args: ["--style", "Mozilla"]
- repo: https://github.com/codespell-project/codespell
rev: "v2.1.0"
hooks:
Expand All @@ -27,3 +28,23 @@ repos:
additional_dependencies: [pyyaml]
types: [file]
files: CMakeLists.txt
- repo: https://github.com/pre-commit/mirrors-yapf
rev: v0.32.0
hooks:
- id: yapf
files: \.py(?:i)?
- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.10.1
hooks:
- id: isort
name: isort (python)
- repo: https://github.com/asottile/pyupgrade
rev: "v2.37.3"
hooks:
- id: pyupgrade
args: [--py36-plus]
- repo: https://gitlab.com/pycqa/flake8
rev: 5.0.4
hooks:
- id: flake8
exclude: tests
7 changes: 4 additions & 3 deletions examples/fes_slev.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
"""
import argparse
import datetime
import numpy as np

import matplotlib.pyplot as plt
import numpy as np
import pyfes


Expand Down Expand Up @@ -53,9 +54,9 @@ def main():
args = usage()

# Create handler
short_tide = pyfes.Handler("ocean", "memory", args.ocean.name)
short_tide = pyfes.Handler('ocean', 'memory', args.ocean.name)
if args.load is not None:
radial_tide = pyfes.Handler("radial", "memory", args.load.name)
radial_tide = pyfes.Handler('radial', 'memory', args.load.name)
else:
radial_tide = None

Expand Down
42 changes: 20 additions & 22 deletions examples/fes_uv.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
"""
import argparse
import datetime
import numpy as np

import matplotlib.pyplot as plt
import numpy as np
import pyfes


Expand All @@ -29,23 +30,20 @@ def usage():
"""
parser = argparse.ArgumentParser(
description='Program example using the Python API for FES.')
parser.add_argument(
'northward_velocity',
help='Path to the configuration file that contains '
'the definition of grids to use to compute the '
'northward velocity (V-component)',
type=argparse.FileType('r'))
parser.add_argument(
'eastward_velocity',
help='Path to the configuration file that contains '
'the definition of grids to use to compute the '
'eastward velocity (U-component)',
type=argparse.FileType('r'))
parser.add_argument(
'--date',
help='Date of calculation of the velocities tide.',
default=datetime.datetime.now(),
type=argparse.FileType('r'))
parser.add_argument('northward_velocity',
help='Path to the configuration file that contains '
'the definition of grids to use to compute the '
'northward velocity (V-component)',
type=argparse.FileType('r'))
parser.add_argument('eastward_velocity',
help='Path to the configuration file that contains '
'the definition of grids to use to compute the '
'eastward velocity (U-component)',
type=argparse.FileType('r'))
parser.add_argument('--date',
help='Date of calculation of the velocities tide.',
default=datetime.datetime.now(),
type=argparse.FileType('r'))
return parser.parse_args()


Expand All @@ -56,9 +54,9 @@ def main():
args = usage()

# Create handler
eastward_velocity = pyfes.Handler("ocean", "memory",
eastward_velocity = pyfes.Handler('ocean', 'memory',
args.eastward_velocity.name)
northward_velocity = pyfes.Handler("ocean", "memory",
northward_velocity = pyfes.Handler('ocean', 'memory',
args.northward_velocity.name)

# Creating a grid that will be used to interpolate the tide
Expand All @@ -83,13 +81,13 @@ def main():
u_tide = u_tide.reshape((size, size))
u_tide = np.ma.masked_where(np.isnan(u_tide), u_tide)
plt.figure(1)
plt.title("eastward velocity")
plt.title('eastward velocity')
plt.pcolormesh(u_tide)

v_tide = v_tide.reshape((size, size))
v_tide = np.ma.masked_where(np.isnan(v_tide), v_tide)
plt.figure(2)
plt.title("northward velocity")
plt.title('northward velocity')
plt.pcolormesh(v_tide)

plt.show()
Expand Down
7 changes: 4 additions & 3 deletions examples/tide_gauge.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"""
import argparse
import datetime

import numpy as np
import pyfes

Expand Down Expand Up @@ -51,8 +52,8 @@ def main():
args = usage()

# Create handler
short_tide = pyfes.Handler("ocean", "io", args.ocean.name)
radial_tide = pyfes.Handler("radial", "io", args.load.name)
short_tide = pyfes.Handler('ocean', 'io', args.ocean.name)
radial_tide = pyfes.Handler('radial', 'io', args.load.name)

# Creating the time series
dates = np.array([
Expand All @@ -68,7 +69,7 @@ def main():
load, load_lp, _ = radial_tide.calculate(lons, lats, dates)

for idx, date in enumerate(dates):
print("%s %9.3f %9.3f %9.3f %9.3f %9.3f %9.3f %9.3f" %
print('%s %9.3f %9.3f %9.3f %9.3f %9.3f %9.3f %9.3f' %
(date, lats[idx], lons[idx], tide[idx], lp[idx], tide[idx] +
lp[idx], tide[idx] + lp[idx] + load[idx], load[idx]))

Expand Down
25 changes: 25 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[flake8]
exclude = docs,tests
max-line-length = 80
ignore =
# Assigning lambda expression
E731
# Ambiguous variable names
E741
# line break before binary operator
W503
# line break after binary operator
W504
# whitespace before :
E203

[isort]
combine_as_imports=True
force_grid_wrap=0
force_sort_within_sections=True
force_to_top=typing
include_trailing_comma=True
line_length=80
multi_line_output=3
skip=
build
Loading

0 comments on commit f9bb3f8

Please sign in to comment.