Skip to content

Commit

Permalink
消除空白行
Browse files Browse the repository at this point in the history
  • Loading branch information
wokron committed Aug 31, 2024
1 parent fd8e712 commit 7f4ebda
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions scripts/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ def general_test(test_files: list[pathlib.Path], preprocess_fn, run_fn, compare_


def compare(test_result_file: pathlib.Path, output_file: pathlib.Path):
def convert_to_float(text):

def is_not_empty_line(text: str):
return len(text.strip()) > 0

def convert_to_float(text: str):
try:
val = float(text)
except ValueError:
Expand All @@ -88,9 +92,11 @@ def convert_to_float(text):
return val

with open(test_result_file, "r") as f:
test_results = map(convert_to_float, f.readlines())
test_results = map(convert_to_float, filter(is_not_empty_line, f.readlines()))
with open(output_file, "r") as f:
expected_results = map(convert_to_float, f.readlines())
expected_results = map(
convert_to_float, filter(is_not_empty_line, f.readlines())
)

is_success = True
try:
Expand Down

0 comments on commit 7f4ebda

Please sign in to comment.