Skip to content

Commit

Permalink
removed the error codes (#600)
Browse files Browse the repository at this point in the history
Co-authored-by: Chen Wang <[email protected]>
  • Loading branch information
Rashmil-1999 and longshuicy authored Jun 28, 2024
1 parent fbf3ce9 commit a5493fc
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[flake8]
max-line-length = 180
extend-ignore = E203,E501,E711,E712,E721,E731,E741,F401,F403,F405,F541,F841,W291
extend-ignore = E203,E731,E741,F401,F403,F405,F541,F841,W291
exclude = __init__.py
4 changes: 1 addition & 3 deletions pyincore/utils/evaluateexpression.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ def evaluate(expression: str, parameters: dict = {}):
if "__" in name or name in INVALID_NAMES:
raise NameError(f"The use of '{name}' is not allowed.")
for parameter in parameters:
if type(parameter) == "str" and (
"__" in parameter or parameter in INVALID_NAMES
):
if type(parameter) is str and ("__" in parameter or parameter in INVALID_NAMES):
raise NameError(f"Using '{parameter}' is not allowed.")

# TODO figure out a better way of doing this. Can we import the packages here directly?
Expand Down
2 changes: 1 addition & 1 deletion pyincore/utils/geoutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def degree_to_decimal(degree: int):
int: A decimal value.
"""
if degree == 0.0 or degree == None or degree == "":
if degree == 0.0 or degree is None or degree == "":
decimal = "NA"
else:
degree = str(int(degree))
Expand Down
2 changes: 1 addition & 1 deletion pyincore/utils/networkutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ def validate_network_node_ids(
node_list = list(set(node_list))

for node in link_node_list:
if node in node_list == False:
if node in node_list is False:
validate = False

return validate
Expand Down
14 changes: 7 additions & 7 deletions tests/pyincore/models/test_dfr3curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ def test_calculate_limit_state_probability(
)
def test_calculate_repair_rates(repair_set, args, expected):
result = repair_set.calculate_repair_rates(**args)
if type(result["PF_0"]) == numpy.ndarray:
if type(result["PF_0"]) is numpy.ndarray:
assert numpy.allclose(result["PF_0"], expected, rtol=1e-03, atol=1e-03)
elif type(result["PF_0"]) == numpy.float64:
elif type(result["PF_0"]) is numpy.float64:
assert result["PF_0"] == expected
else:
assert False
Expand All @@ -182,9 +182,9 @@ def test_calculate_repair_rates(repair_set, args, expected):
def test_calculate_inverse_repair_rates(repair_set, args, expected):
result = repair_set.calculate_inverse_repair_rates(**args)
print(result)
if type(result["PF_0"]) == numpy.ndarray:
if type(result["PF_0"]) is numpy.ndarray:
assert numpy.allclose(result["PF_0"], expected, rtol=1e-03, atol=1e-03)
elif type(result["PF_0"]) == numpy.float64:
elif type(result["PF_0"]) is numpy.float64:
assert result["PF_0"] == expected
else:
assert False
Expand All @@ -203,9 +203,9 @@ def test_calculate_inverse_repair_rates(repair_set, args, expected):
)
def test_calculate_restoration_rates(restoration_set, args, expected):
result = restoration_set.calculate_restoration_rates(**args)
if type(result["PF_0"]) == numpy.ndarray:
if type(result["PF_0"]) is numpy.ndarray:
assert numpy.allclose(result["PF_0"], expected, rtol=1e-03, atol=1e-03)
elif type(result["PF_0"]) == numpy.float64:
elif type(result["PF_0"]) is numpy.float64:
assert result["PF_0"] == expected
else:
assert False
Expand All @@ -224,7 +224,7 @@ def test_calculate_restoration_rates(restoration_set, args, expected):
def test_calculate_pipeline_restoration_rates(restoration_set, args, expected):
result = restoration_set.calculate_restoration_rates(**args)
print(result)
if type(result["RT"]) == numpy.ndarray:
if type(result["RT"]) is numpy.ndarray:
assert numpy.allclose(result["RT"], expected, rtol=1e-03, atol=1e-03)
else:
assert result["RT"] == expected
Expand Down
4 changes: 2 additions & 2 deletions tests/pyincore/test_dataservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def test_get_dataset_blob(datasvc):
dataset_id = "5a284f0ac7d30d13bc0819c4"
fname = datasvc.get_dataset_blob(dataset_id, join=True)

if type(fname) != str:
if type(fname) is not str:
errors.append("doesn't return the correct filename!")
# check if file or folder exists locally, which means successfully downloaded
if not os.path.exists(fname):
Expand Down Expand Up @@ -158,7 +158,7 @@ def test_get_file_blob(datasvc):
dataset_id = "5a284f24c7d30d13bc081adb"
fname = datasvc.get_file_blob(dataset_id)

if type(fname) != str:
if type(fname) is not str:
errors.append("doesn't return the correct filename!")
# check if file or folder exists locally, which means successfully downloaded
if not os.path.exists(fname):
Expand Down
2 changes: 1 addition & 1 deletion tests/pyincore/test_semanticservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def test_get_semantic_type_by_name(semanticsvc):
# find semantic type by name which exists
semantic_types = semanticsvc.get_semantic_type_by_name(semantic_type_exists)
# Checks semantic dictionary is not empty
assert type(semantic_types) == dict and bool(
assert type(semantic_types) is dict and bool(
dict
), f"Should find one semantic type as {semantic_type_exists} exists"
# find semantic type by name which does not exist
Expand Down

0 comments on commit a5493fc

Please sign in to comment.