-
Notifications
You must be signed in to change notification settings - Fork 415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial code for wind field reconstruction from vorticity and divergence #3266
base: main
Are you sure you want to change the base?
Conversation
@DWesl I am trying to fix the linting and flake8 errors this week so that I can be set up for a formal code review. I am stuck with the flake8 and linting errors as for each error I fix and another 10 pop up. On the example code I checked in apparently cfgrib is not an engine I can use because eccodes is not used. |
Yeah, that happens sometimes. If the problem is making the changes locally then waiting for GitHub to provide test results, you can look through the workflows in If the problem is it reporting lots of little nitpicky things, you could copy the new functions to a new file, run an auto-formatter on it (
I suspect that means |
Yes the lint , ruff and flake8 errors are all very nitpicky. The thing is I have pep8 and pycodestyle, pylint (not ruff I could not install it) and when I run my changes through these 3 I get no errors at all. But when it goes through MetPy I get a gazillion errors - some of them very trivial and each one I fix brings about others. yes I will convert my GRIB file to netCDF as it's not worth modifying what MetPy will need as part of it's installation. |
Interesting. My experience with pylint is it finds more things than flake8, which implies they have a few plugins. I don't remember offhand whether flake8 runs pycodestyle checks by default or only if you install a plugin, but I do remember the It looks like the linting requirements are pure python aside from ruff's dependency on Rust, which is rather less ubiquitous than the usual C, C++, or even Fortran dependencies, so installing everything between the first and last lines of the file should get you a For ruff, given the newness of Rust, I am somewhat surprised they do not have CI just make the changes on your PR or as a PR against the branch in your PR. You should still be able to put your functions in a new file, run EDIT: On looking at the current errors, you are past most of those easy problems. The currently-flagged problems are extra spaces in and around docstrings, and writing docstring summaries in declarative rather than the imperative mood (removing the "s" at the end of the verb should fix this). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few suggestions for the lint and coverage problems, as requested on winash12#2 here. The comments might make more sense when viewed on the "Files Changed" tab of the PR.
xindex = np.linspace(i_x_ll, i_x_ur, num=x * y, endpoint=False, dtype=np.int32) | ||
yindex = np.linspace(i_y_ur, i_y_ll, num=y * x, endpoint=False, dtype=np.int32) | ||
xindex = xindex.reshape((y, x), order='F') | ||
yindex = yindex.reshape((y, x), order='C') | ||
return [xindex, yindex] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What problems are you experiencing with np.mgrid
and np.meshgrid
that you cannot use those? They look like they do something similar.
|
||
|
||
def test_get_vectorized_array_indices(): | ||
"""Tests the vectorized array indices for two different bounding boxes. """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"""Tests the vectorized array indices for two different bounding boxes. """ | |
"""Tests the vectorized array indices for two different bounding boxes.""" |
|
||
|
||
def test_bounding_box_mask(): | ||
""" Test the mask of a bounding box. """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
""" Test the mask of a bounding box. """ | |
"""Test the mask of a bounding box.""" |
|
||
|
||
def test_find_bounding_box_indices(): | ||
"""Tests the bounding box indices for 2 different cases. """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"""Tests the bounding box indices for 2 different cases. """ | |
"""Tests the bounding box indices for 2 different cases.""" |
"""Returns the vectorization indices for inner for loop in the | ||
wind field reconstruction method. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"""Returns the vectorization indices for inner for loop in the | |
wind field reconstruction method. | |
"""Return the vector indices for the wind field reconstruction method. |
It doesn't like the "s" on the verb, and thinks the summary is too long.
"""Returns the array indices of a bounding box.""" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"""Returns the array indices of a bounding box.""" | |
"""Return the array indices of a bounding box.""" | |
It wants imperative (telling the computer to do something) rather than declarative (saying what the computer does)
vorticity, wind_components,rotational_wind_from_inversion, | ||
divergent_wind_from_inversion) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is complaining because you started the setup for the tests but didn't add the tests for these functions. Adding the tests or removing the import will make the warning go away. Adding the tests should increase the coverage Codecov reports for the functions.
print(crs) | ||
vort = vorticity(u, v, longitude=lons, latitude=lats, crs=crs) | ||
|
||
sys.exit() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They'll want you to change these lines back before the merge; among other things, they cause the tests to fail with a SystemExit
error rather than passing.
Description Of Changes
Checklist