Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Static turn annotations analysis test fix #3374

Merged
merged 2 commits into from
Jan 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_compile_results(self):

with testing_utils.tempdir() as tmpdir:

# Define desired stdout
# Define expected stdout

# Paths
analysis_config_folder = os.path.join(
Expand Down Expand Up @@ -100,7 +100,7 @@ def test_compile_results(self):
actual_stdout = output.getvalue()

# Check the output against what it should be
desired_stdout = f"""\
expected_stdout = f"""\
Got 4 folders to read.
Average task completion time (seconds) was: 187.5
Returning master dataframe with 48 annotations.
Expand Down Expand Up @@ -136,20 +136,22 @@ def test_compile_results(self):
Fleiss' kappa for none_all_good is: -0.410.\
"""
actual_stdout_lines = actual_stdout.split('\n')
for desired_line in desired_stdout.split('\n'):
if desired_line not in actual_stdout_lines:
for expected_line in expected_stdout.split('\n'):
if not any(
expected_line in actual_line for actual_line in actual_stdout_lines
):
raise ValueError(
f'\n\tThe following line:\n\n{desired_line}\n\n\twas not found '
f'\n\tThe following line:\n\n{expected_line}\n\n\twas not found '
f'in the actual stdout:\n\n{actual_stdout}'
)

# Check that the saved results file is what it should be
sort_columns = ['hit_id', 'worker_id', 'conversation_id', 'turn_idx']
desired_results_path = os.path.join(
analysis_config_folder, 'desired_results.csv'
expected_results_path = os.path.join(
analysis_config_folder, 'expected_results.csv'
)
desired_results = (
pd.read_csv(desired_results_path)
expected_results = (
pd.read_csv(expected_results_path)
.drop('folder', axis=1)
.sort_values(sort_columns)
.reset_index(drop=True)
Expand All @@ -165,9 +167,9 @@ def test_compile_results(self):
.sort_values(sort_columns)
.reset_index(drop=True)
)
if not actual_results.equals(desired_results):
if not actual_results.equals(expected_results):
raise ValueError(
f'\n\n\tDesired results:\n{desired_results.to_csv()}'
f'\n\n\tExpected results:\n{expected_results.to_csv()}'
f'\n\n\tActual results:\n{actual_results.to_csv()}'
)

Expand Down