Skip to content
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

Tw/reeds cols #187

Merged
merged 5 commits into from
Aug 3, 2023
Merged

Tw/reeds cols #187

merged 5 commits into from
Aug 3, 2023

Conversation

WilliamsTravis
Copy link
Collaborator

@WilliamsTravis WilliamsTravis commented Jul 21, 2023

There were potential problems in the remote county file read and the reprojection step (both potential network-related problem since pyproj uses a network connection too), so this tweak allows the user to pass their own local region file through add_reeds_cols. This also has the potential to significantly speed up the routine, depending on how the user treats this file.

I also turned off a CRS warning when finding the centroid for the outliers later. This might be a bit contentious, but since these are used to handle what is likely just handful of outliers (sc points that fall outside the boundaries of regions) it seems like a trivial warning. The best way would be to reproject the files into a local area projection, but that could take significantly more runtime and it would be difficult to find the most appropriate system for each region.

I also tweaked the function to add a dictionary option for the 'data_fp' argument in 'extra_data' so the user can do everything in one python script without having to write jsons.

Copy link
Collaborator

@ppinchuk ppinchuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great little change! Always love additional flexibility for end-users.
Just a few comments to help up keep our documentation clean and up-to-date.
Thanks for this, Travis!

By default, ``None``.
The first key is "data_fp", and it points either a dictionary of
new field/new value pairs or to the path where the extra data is being
extracted from. This must be a dictionary, an HDF5, or JSON
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we update this text to something like

"The first key is "data_fp", and it points either a dictionary of new field/new value pairs or to the path where the extra data is being extracted from. The latter must be an HDF5 or JSON file (i.e., if not a dictionary, it must end in ".h5" or ".json")."

Basically I'm just trying to avoid saying "dictionary" so many times

of the input ``data_frame``. For HDF5 data, the datasets must be 1D
datasets, and they will be merged with the input ``data_frame``
on ``merge_col`` (column must be in the HDF5 file meta). By default,
``None``.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add documentation for the regions input parameter at the end of this docstring? It doesn't have to be anything long or fancy, but this is the text that gets put into the documentation for this function, so it's important that we have all of our parameters documents.

if data_fp.endswith(".json"):
if isinstance(data_fp, dict):
extra_data = data_fp
elif str(data_fp).endswith(".json"):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this cast to str (and the one below) really necessary? This value should either be a string or a dictionary, and we already check for a dictionary above. Any other kind of input should error out here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be a Posix Path, can add to the docs.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah gotcha. I don't think you need to update the docs then, unless you really want to

@codecov-commenter
Copy link

codecov-commenter commented Jul 21, 2023

Codecov Report

Merging #187 (32a95e0) into main (cdde308) will increase coverage by 0.00%.
The diff coverage is 95.45%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #187   +/-   ##
=======================================
  Coverage   81.36%   81.36%           
=======================================
  Files         113      113           
  Lines       13369    13381   +12     
=======================================
+ Hits        10878    10888   +10     
- Misses       2491     2493    +2     
Flag Coverage Δ
unittests 81.36% <95.45%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
reVX/utilities/reeds_cols.py 97.29% <92.30%> (-1.32%) ⬇️
reVX/utilities/region_classifier.py 75.53% <100.00%> (+0.53%) ⬆️
tests/test_reeds_cols.py 96.38% <100.00%> (ø)

... and 6 files with indirect coverage changes

@ppinchuk
Copy link
Collaborator

@WilliamsTravis I went ahead and made some of the requested updates and then merged code to fix the tests. Once they all pass, this branch should be good to merge.

One thing I ended up doing is changing the dictionary key name from data_fp to source. This will show up in the updated documentation, but would be good to be aware of it for your config files

@ppinchuk ppinchuk merged commit 00aedee into main Aug 3, 2023
5 checks passed
@ppinchuk ppinchuk deleted the tw/reeds_cols branch August 3, 2023 16:03
github-actions bot pushed a commit that referenced this pull request Aug 3, 2023
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants