Skip to content

Commit f6f7301

Browse files
authored
Lint Tidal (#386)
- Enforce PyLint and add type hints
1 parent 81c60e3 commit f6f7301

12 files changed

+925
-522
lines changed

.github/workflows/pylint.yml

+4
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,7 @@ jobs:
3636
- name: Run Pylint on mhkit/acoustics/
3737
run: |
3838
pylint mhkit/acoustics/
39+
40+
- name: Run Pylint on mhkit/tidal
41+
run: |
42+
pylint mhkit/tidal/

examples/metocean_example.ipynb

+8-8
Large diffs are not rendered by default.

examples/tidal_example.ipynb

+15-7
Large diffs are not rendered by default.

examples/tidal_performance_example.ipynb

+3-3
Large diffs are not rendered by default.

mhkit/tests/tidal/test_io.py

+26-11
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,16 @@ def test_request_noaa_data_basic(self):
7474
and verify that the returned DataFrame and metadata have the
7575
correct shape and columns.
7676
"""
77+
options = {
78+
"proxy": None,
79+
"write_json": None,
80+
}
7781
data, metadata = tidal.io.noaa.request_noaa_data(
7882
station="s08010",
7983
parameter="currents",
8084
start_date="20180101",
8185
end_date="20180102",
82-
proxy=None,
83-
write_json=None,
86+
options=options,
8487
)
8588
self.assertTrue(np.all(data.columns == ["s", "d", "b"]))
8689
self.assertEqual(data.shape, (183, 3))
@@ -92,14 +95,17 @@ def test_request_noaa_data_basic_xarray(self):
9295
and verify that the returned DataFrame and metadata have the
9396
correct shape and columns.
9497
"""
98+
options = {
99+
"proxy": None,
100+
"write_json": None,
101+
"to_pandas": False,
102+
}
95103
data = tidal.io.noaa.request_noaa_data(
96104
station="s08010",
97105
parameter="currents",
98106
start_date="20180101",
99107
end_date="20180102",
100-
proxy=None,
101-
write_json=None,
102-
to_pandas=False,
108+
options=options,
103109
)
104110
# Check if the variable sets are equal
105111
data_variables = list(data.variables)
@@ -117,13 +123,16 @@ def test_request_noaa_data_write_json(self):
117123
and can be loaded back into a dictionary.
118124
"""
119125
test_json_file = "test_noaa_data.json"
126+
options = {
127+
"proxy": None,
128+
"write_json": test_json_file,
129+
}
120130
_, _ = tidal.io.noaa.request_noaa_data(
121131
station="s08010",
122132
parameter="currents",
123133
start_date="20180101",
124134
end_date="20180102",
125-
proxy=None,
126-
write_json=test_json_file,
135+
options=options,
127136
)
128137
self.assertTrue(os.path.isfile(test_json_file))
129138

@@ -142,29 +151,35 @@ def test_request_noaa_data_invalid_dates(self):
142151
Test the request_noaa_data function with an invalid date format
143152
and verify that it raises a ValueError.
144153
"""
154+
options = {
155+
"proxy": None,
156+
"write_json": None,
157+
}
145158
with self.assertRaises(ValueError):
146159
tidal.io.noaa.request_noaa_data(
147160
station="s08010",
148161
parameter="currents",
149162
start_date="2018-01-01", # Invalid date format
150163
end_date="20180102",
151-
proxy=None,
152-
write_json=None,
164+
options=options,
153165
)
154166

155167
def test_request_noaa_data_end_before_start(self):
156168
"""
157169
Test the request_noaa_data function with the end date before
158170
the start date and verify that it raises a ValueError.
159171
"""
172+
options = {
173+
"proxy": None,
174+
"write_json": None,
175+
}
160176
with self.assertRaises(ValueError):
161177
tidal.io.noaa.request_noaa_data(
162178
station="s08010",
163179
parameter="currents",
164180
start_date="20180102",
165181
end_date="20180101", # End date before start date
166-
proxy=None,
167-
write_json=None,
182+
options=options,
168183
)
169184

170185

mhkit/tidal/__init__.py

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
"""
2+
MHKiT Tidal Module
3+
4+
The tidal module contains a set of functions to calculate quantities of
5+
interest for tidal energy converters (TEC). The tidal module uses timeseries
6+
data of velocity and direction.
7+
"""
8+
19
from mhkit.tidal import graphics
210
from mhkit.tidal import io
311
from mhkit.tidal import resource

0 commit comments

Comments
 (0)