-
Notifications
You must be signed in to change notification settings - Fork 16
Make validation class pass the linter #578
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
Merged
Merged
Changes from 14 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
cddfb38
move parameter checking to be separate from other validation
sgsmob 9794653
remove vestigial checks
sgsmob 76c043f
add pylintrc
sgsmob 02692f9
refactor of validator for lint compliance
sgsmob cc34365
change order of super().__init__() call to preserve error function me…
sgsmob f9e9900
trailing newline to pylintrc
sgsmob feafbed
add TODO for last lint error
sgsmob 727fe7a
Merge branch 'main' of github.com:cmu-delphi/covidcast-indicators int…
sgsmob f6653aa
get validation pylint compliant
sgsmob 49bc1b2
Merge branch 'main' of github.com:cmu-delphi/covidcast-indicators int…
sgsmob 48b75a8
fix bug with missing argument to refactored function
sgsmob 331dd15
tests for utils
sgsmob 29c2f12
constants capitalization
sgsmob 1750b13
tests for datafetching
sgsmob 4382ab5
change super().__init__() call to get the correct error message printed
sgsmob 484d3aa
move check increment to outside the loop:
sgsmob File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,22 @@ | ||
|
||
[MESSAGES CONTROL] | ||
|
||
disable=logging-format-interpolation, | ||
too-many-locals, | ||
too-many-arguments, | ||
# Allow pytest functions to be part of a class. | ||
no-self-use, | ||
# Allow pytest classes to have one test. | ||
too-few-public-methods | ||
|
||
[BASIC] | ||
|
||
# Allow arbitrarily short-named variables. | ||
variable-rgx=[a-z_][a-z0-9_]* | ||
argument-rgx=[a-z_][a-z0-9_]* | ||
attr-rgx=[a-z_][a-z0-9_]* | ||
|
||
[DESIGN] | ||
|
||
# Don't complain about pytest "unused" arguments. | ||
ignored-argument-names=(_.*|run_as_module) |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,47 @@ | ||
"""Utility functions for validation.""" | ||
from datetime import datetime | ||
import pandas as pd | ||
|
||
# Recognized geo types. | ||
GEO_REGEX_DICT = { | ||
'county': r'^\d{5}$', | ||
'hrr': r'^\d{1,3}$', | ||
'msa': r'^\d{5}$', | ||
'dma': r'^\d{3}$', | ||
'state': r'^[a-zA-Z]{2}$', | ||
'national': r'^[a-zA-Z]{2}$' | ||
} | ||
|
||
|
||
def relative_difference_by_min(x, y): | ||
""" | ||
Calculate relative difference between two numbers. | ||
""" | ||
return (x - y) / min(x, y) | ||
|
||
|
||
def aggregate_frames(frames_list): | ||
"""Aggregates a list of data frames into a single frame. | ||
|
||
Parameters | ||
---------- | ||
frames_list: List[Tuple(str, re.match, pd.DataFrame)] | ||
triples of filenames, filename matches with the geo regex, and the data from the file | ||
|
||
Returns | ||
------- | ||
A pd.DataFrame concatenation of all data frames in `frames_list` with additional columns for | ||
geo_type, time_value, and signal derived from the corresponding re.match. | ||
""" | ||
all_frames = [] | ||
for _, match, data_df in frames_list: | ||
df = data_df.copy() | ||
# Get geo_type, date, and signal name as specified by CSV name. | ||
df['geo_type'] = match.groupdict()['geo_type'] | ||
df['time_value'] = datetime.strptime( | ||
match.groupdict()['date'], "%Y%m%d").date() | ||
df['signal'] = match.groupdict()['signal'] | ||
|
||
all_frames.append(df) | ||
|
||
return pd.concat(all_frames).reset_index(drop=True) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The super init changes the output of
Validator.exit()
so that only the error message is printed. This isn't a concern here since you have the incoming validator report PR; just wanted you to be aware that the goal is to include thecheck_data_id
(unique error-data combo identifier), expression, and message in error output.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.
I thought I had fixed this by moving the call to
super().__init__()
to the top of the function, but you are correct that it squashes the full error message. I have changed this to take all the arguments which produces the same output as before.