Skip to content

Commit

Permalink
fix the new flake8 issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Kvieta1990 committed Sep 6, 2023
1 parent d745028 commit 5501bbf
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 32 deletions.
4 changes: 2 additions & 2 deletions addie/post_process_m/event_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ def merge_banks(main_window):


def save_file_raw(main_window, file_name):
if type(file_name) == list:
if file_name.isinstance(list):
save_directory = QFileDialog.getExistingDirectory(main_window,
'Save Banks',
main_window.current_folder)
Expand Down Expand Up @@ -791,7 +791,7 @@ def save_file_merged(main_window, file_name, auto=False):


def save_file_stog(main_window, file_name):
if type(file_name) == list:
if file_name.isinstance(list):
save_directory = QFileDialog.getExistingDirectory(main_window,
'Save StoG Files',
main_window.current_folder)
Expand Down
56 changes: 28 additions & 28 deletions addie/processing/mantid/launch_reduction.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ def run_mantid(parent):
elif "AlignAndFocusArgs" in key:
af_tmp = {}
for key_af, item_af in item.items():
if type(item_af) == list:
if item_af.isinstance(list):
try:
list_tmp = [float(entry_tmp) for entry_tmp in item_af]
except ValueError:
Expand Down Expand Up @@ -743,8 +743,8 @@ def check_all_decimal(input_list):

def check_all_number(input_list):
for item in input_list:
cond1 = type(item) == int
cond2 = type(item) == float
cond1 = item.isinstance(int)
cond2 = type.isinstance(float)
if not (cond1 or cond2):
return False
return True
Expand Down Expand Up @@ -775,7 +775,7 @@ def final_validator(final_dict):

# Check 'Sample' entry.
if "Runs" in final_dict["Sample"]:
if type(final_dict["Sample"]["Runs"]) == str:
if final_dict["Sample"]["Runs"].isinstance(str):
run_num_tmp = re.split("-|,| ", final_dict["Sample"]["Runs"])
if not check_all_decimal(run_num_tmp):
log_error(2, '["Sample"]["Run"]')
Expand All @@ -788,15 +788,15 @@ def final_validator(final_dict):
return False
if "Background" in final_dict["Sample"]:
if "Runs" in final_dict["Sample"]["Background"] and "Background" in final_dict["Sample"]["Background"]:
if type(final_dict["Sample"]["Background"]["Runs"]) == str:
if final_dict["Sample"]["Background"]["Runs"].isinstance(str):
bkg_run_num = re.split("-|,| ", final_dict["Sample"]["Background"]["Runs"])
if not check_all_decimal(bkg_run_num):
log_error(2, '["Sample"]["Background"]["Runs"]')
return False
else:
log_error(2, '["Sample"]["Background"]["Runs"]')
return False
if type(final_dict["Sample"]["Background"]["Background"]) == dict:
if final_dict["Sample"]["Background"]["Background"].isinstance(dict):
if "Runs" in final_dict["Sample"]["Background"]["Background"]:
bkg_run_num = re.split("-|,| ", final_dict["Sample"]["Background"]["Background"]["Runs"])
if not check_all_decimal(bkg_run_num):
Expand All @@ -817,7 +817,7 @@ def final_validator(final_dict):
else:
if "Background" in final_dict["Normalization"]:
if "Runs" in final_dict["Normalization"]["Background"]:
if type(final_dict["Normalization"]["Background"]["Runs"]) == str:
if final_dict["Normalization"]["Background"]["Runs"].isinstance(str):
bkg_run_num = re.split("-|,| ", final_dict["Normalization"]["Background"]["Runs"])
if not check_all_decimal(bkg_run_num):
log_error(2, '["Normalization"]["Background"]["Runs"]')
Expand All @@ -834,24 +834,24 @@ def final_validator(final_dict):
log_error(1, '["Sample"]["Background"]')
return False
if "Material" in final_dict["Sample"]:
if not type(final_dict["Sample"]["Material"]) == str:
if not final_dict["Sample"]["Material"].isinstance(str):
log_error(2, '["Sample"]["Material"]')
return False
else:
log_error(1, '["Sample"]["Material"]')
if "MassDensity" in final_dict["Sample"]:
cond1 = final_dict["Sample"]["MassDensity"]
cond2 = type(final_dict["Sample"]["MassDensity"]) == int
cond3 = type(final_dict["Sample"]["MassDensity"]) == float
cond2 = final_dict["Sample"]["MassDensity"].isinstance(int)
cond3 = final_dict["Sample"]["MassDensity"].isinstance(float)
if not (cond1 and (cond2 or cond3)):
log_error(2, '["Sample"]["MassDensity"]')
return False
else:
log_error(1, '["Sample"]["MassDensity"]')
if "PackingFraction" in final_dict["Sample"]:
cond1 = final_dict["Sample"]["PackingFraction"]
cond2 = type(final_dict["Sample"]["PackingFraction"]) == int
cond3 = type(final_dict["Sample"]["PackingFraction"]) == float
cond2 = final_dict["Sample"]["PackingFraction"].isinstance(int)
cond3 = final_dict["Sample"]["PackingFraction"].isinstance(float)
if not (cond1 and (cond2 or cond3)):
log_error(2, '["Sample"]["PackingFraction"]')
return False
Expand All @@ -860,14 +860,14 @@ def final_validator(final_dict):
if "Geometry" in final_dict["Sample"]:
if "Radius" in final_dict["Sample"]["Geometry"] and "Height" in final_dict["Sample"]["Geometry"]:
cond1 = final_dict["Sample"]["Geometry"]["Radius"]
cond2 = type(final_dict["Sample"]["Geometry"]["Radius"]) == int
cond3 = type(final_dict["Sample"]["Geometry"]["Radius"]) == float
cond2 = final_dict["Sample"]["Geometry"]["Radius"].isinstance(int)
cond3 = final_dict["Sample"]["Geometry"]["Radius"].isinstance(float)
if not (cond1 and (cond2 or cond3)):
log_error(2, '["Sample"]["Geometry"]["Radius"]')
return False
cond1 = final_dict["Sample"]["Geometry"]["Height"]
cond2 = type(final_dict["Sample"]["Geometry"]["Height"]) == int
cond3 = type(final_dict["Sample"]["Geometry"]["Height"]) == float
cond2 = final_dict["Sample"]["Geometry"]["Height"].isinstance(int)
cond3 = final_dict["Sample"]["Geometry"]["Height"].isinstance(float)
if not (cond1 and (cond2 or cond3)):
log_error(2, '["Sample"]["Geometry"]["Height"]')
return False
Expand All @@ -883,7 +883,7 @@ def final_validator(final_dict):

# Check 'Normalization' entry.
if "Runs" in final_dict["Normalization"]:
if type(final_dict["Normalization"]["Runs"]) == str:
if final_dict["Normalization"]["Runs"].isinstance(str):
run_num_tmp = re.split("-|,| ", final_dict["Normalization"]["Runs"])
if not check_all_decimal(run_num_tmp):
log_error(2, '["Normalization"]["Run"]')
Expand All @@ -896,7 +896,7 @@ def final_validator(final_dict):
return False
if "Background" in final_dict["Normalization"]:
if "Runs" in final_dict["Normalization"]["Background"]:
if type(final_dict["Normalization"]["Background"]["Runs"]) == str:
if final_dict["Normalization"]["Background"]["Runs"].isinstance(str):
bkg_run_num = re.split("-|,| ", final_dict["Normalization"]["Background"]["Runs"])
if not check_all_decimal(bkg_run_num):
log_error(2, '["Normalization"]["Background"]["Runs"]')
Expand All @@ -911,24 +911,24 @@ def final_validator(final_dict):
log_error(1, '["Normalization"]["Background"]')
return False
if "Material" in final_dict["Normalization"]:
if not type(final_dict["Normalization"]["Material"]) == str:
if not final_dict["Normalization"]["Material"].isinstance(str):
log_error(2, '["Normalization"]["Material"]')
return False
else:
log_error(1, '["Normalization"]["Material"]')
if "MassDensity" in final_dict["Normalization"]:
cond1 = final_dict["Normalization"]["MassDensity"]
cond2 = type(final_dict["Normalization"]["MassDensity"]) == int
cond3 = type(final_dict["Normalization"]["MassDensity"]) == float
cond2 = final_dict["Normalization"]["MassDensity"].isinstance(int)
cond3 = final_dict["Normalization"]["MassDensity"].isinstance(float)
if not (cond1 and (cond2 or cond3)):
log_error(2, '["Normalization"]["MassDensity"]')
return False
else:
log_error(1, '["Normalization"]["MassDensity"]')
if "PackingFraction" in final_dict["Normalization"]:
cond1 = final_dict["Normalization"]["PackingFraction"]
cond2 = type(final_dict["Normalization"]["PackingFraction"]) == int
cond3 = type(final_dict["Normalization"]["PackingFraction"]) == float
cond2 = final_dict["Normalization"]["PackingFraction"].isinstance(int)
cond3 = final_dict["Normalization"]["PackingFraction"].isinstance(float)
if not (cond1 and (cond2 or cond3)):
log_error(2, '["Normalization"]["PackingFraction"]')
return False
Expand All @@ -937,14 +937,14 @@ def final_validator(final_dict):
if "Geometry" in final_dict["Normalization"]:
if "Radius" in final_dict["Normalization"]["Geometry"] and "Height" in final_dict["Normalization"]["Geometry"]:
cond1 = final_dict["Normalization"]["Geometry"]["Radius"]
cond2 = type(final_dict["Normalization"]["Geometry"]["Radius"]) == int
cond3 = type(final_dict["Normalization"]["Geometry"]["Radius"]) == float
cond2 = final_dict["Normalization"]["Geometry"]["Radius"].isinstance(int)
cond3 = final_dict["Normalization"]["Geometry"]["Radius"].isinstance(float)
if not (cond1 and (cond2 or cond3)):
log_error(2, '["Normalization"]["Geometry"]["Radius"]')
return False
cond1 = final_dict["Normalization"]["Geometry"]["Height"]
cond2 = type(final_dict["Normalization"]["Geometry"]["Height"]) == int
cond3 = type(final_dict["Normalization"]["Geometry"]["Height"]) == float
cond2 = final_dict["Normalization"]["Geometry"]["Height"].isinstance(int)
cond3 = final_dict["Normalization"]["Geometry"]["Height"].isinstance(float)
if not (cond1 and (cond2 or cond3)):
log_error(2, '["Normalization"]["Geometry"]["Height"]')
return False
Expand All @@ -960,7 +960,7 @@ def final_validator(final_dict):

# Check "Merging" entry
if "QBinning" in final_dict["Merging"]:
if type(final_dict["Merging"]["QBinning"]) == list:
if final_dict["Merging"]["QBinning"].isinstance(list):
cond1 = len(final_dict["Merging"]["QBinning"]) == 3
cond2 = check_all_number(final_dict["Merging"]["QBinning"])
if not (cond1 and cond2):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ def load(self):

if "AbsMSParameters" in _source_row_entry["Sample"]:
ele_size_val = _source_row_entry["Sample"]["AbsMSParameters"]["ElementSize"]
if type(ele_size_val) == list:
if ele_size_val.isinstance(list):
ele_size_val = ",".join([str(item) for item in ele_size_val])
else:
ele_size_val = str(ele_size_val)
Expand Down
2 changes: 1 addition & 1 deletion tests/utilities/test_customtreeview.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ def test_get_selected_items(qtbot, custom_tree_view):
items = custom_tree_view.get_selected_items()
items_list = [str(item.text()) for item in items]
assert items_list == [main_item]
assert type(items) == list
assert items.isinstance(list)

3 comments on commit 5501bbf

@github-actions
Copy link

Choose a reason for hiding this comment

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

GitLab pipeline for addie-dev has been submitted for this commit: "https://code.ornl.gov/sns-hfir-scse/deployments/addie-deploy/-/pipelines/447633"

@github-actions
Copy link

Choose a reason for hiding this comment

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

GitLab pipeline for addie-qa has been submitted for this commit: "https://code.ornl.gov/sns-hfir-scse/deployments/addie-deploy/-/pipelines/447819"

@github-actions
Copy link

Choose a reason for hiding this comment

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

GitLab pipeline for addie has been submitted for this commit: "https://code.ornl.gov/sns-hfir-scse/deployments/addie-deploy/-/pipelines/447850"

Please sign in to comment.