Skip to content

Commit

Permalink
PEP8 Linting
Browse files Browse the repository at this point in the history
  • Loading branch information
kenkehoe committed Jul 17, 2024
1 parent b78d8c7 commit a803c2b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 13 deletions.
16 changes: 10 additions & 6 deletions act/qc/qc_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ def __init__(self, ds):
self._ds = ds

def create_qc_summary(self, cleanup_qc=False):

"""
Method to convert embedded quality control to summary QC that utilzes
flag values instead of flag masks and summarizes the assessments to only
Expand All @@ -39,12 +38,14 @@ def create_qc_summary(self, cleanup_qc=False):
'Suspect',
'Indeterminate',
'Incorrect',
'Bad',]
'Bad',
]
standard_meanings = [
"Data suspect, further analysis recommended",
"Data suspect, further analysis recommended",
"Data incorrect, use not recommended",
"Data incorrect, use not recommended",]
"Data incorrect, use not recommended",
]

return_ds = self._ds.copy()

Expand All @@ -69,7 +70,8 @@ def create_qc_summary(self, cleanup_qc=False):
test_number=0,
test_meaning='Passing all quality control tests',
test_assessment='Passing',
flag_value=True,)
flag_value=True,
)

for ii, assessment in enumerate(standard_assessments):
if assessment not in assessments:
Expand All @@ -86,13 +88,15 @@ def create_qc_summary(self, cleanup_qc=False):
index=np.where(qc_ma.mask),
test_meaning=standard_meanings[ii],
test_assessment=assessment,
flag_value=True)
flag_value=True,
)

if added:
history = return_ds.attrs['history']
history += (
" ; Quality control summary implemented by ACT at "
f"{datetime.datetime.utcnow().isoformat()} UTC.")
f"{datetime.datetime.utcnow().isoformat()} UTC."
)
return_ds.attrs['history'] = history

return return_ds
3 changes: 1 addition & 2 deletions tests/qc/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@


def pytest_addoption(parser):
parser.addoption(
"--runbig", action="store_true", default=False, help="Run big tests")
parser.addoption("--runbig", action="store_true", default=False, help="Run big tests")


def pytest_configure(config):
Expand Down
28 changes: 23 additions & 5 deletions tests/qc/test_qc_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,14 @@ def test_qc_summary_multiple_assessment_names():
ds[qc_var_name].values = qc_data

index_5 = np.arange(50, 150)
ds.qcfilter.add_test(var_name, index=index_5, test_meaning='Testing Suspect', test_assessment='Suspect')
ds.qcfilter.add_test(
var_name, index=index_5, test_meaning='Testing Suspect', test_assessment='Suspect'
)

index_6 = np.arange(130, 210)
ds.qcfilter.add_test(var_name, index=index_6, test_meaning='Testing Incorrect', test_assessment='Incorrect')
ds.qcfilter.add_test(
var_name, index=index_6, test_meaning='Testing Incorrect', test_assessment='Incorrect'
)

result = ds.qcfilter.create_qc_summary()

Expand All @@ -76,7 +80,8 @@ def test_qc_summary_multiple_assessment_names():
'Suspect',
'Indeterminate',
'Incorrect',
'Bad',]
'Bad',
]

qc_ma = result.qcfilter.get_masked_data(var_name, rm_assessments='Indeterminate')
assert np.sum(np.where(qc_ma.mask)[0]) == 14370
Expand Down Expand Up @@ -116,8 +121,21 @@ def test_qc_summary_big_data():
return

# Set number of files from each directory to test.
skip_sites = ['shb', 'wbu', 'dna', 'rld', 'smt', 'nic', 'isp',
'dmf', 'nac', 'rev', 'yeu', 'zrh', 'osc']
skip_sites = [
'shb',
'wbu',
'dna',
'rld',
'smt',
'nic',
'isp',
'dmf',
'nac',
'rev',
'yeu',
'zrh',
'osc',
]
skip_datastream_codes = ['mmcrmom']
num_files = 3
testing_files = []
Expand Down

0 comments on commit a803c2b

Please sign in to comment.