The Fourth and Fifth tasks are done
This commit is contained in:
parent
69ff8c30a1
commit
a6c451d866
28 changed files with 1077 additions and 15 deletions
|
@ -87,12 +87,27 @@ def format_matrix(matrix):
|
|||
formatted.append(" ".join(f"{float(num):10.3e}" for num in row.split()))
|
||||
return "\n".join(formatted)
|
||||
|
||||
def parse_matrix_output(output, label):
|
||||
def parse_matrix_output(output, label, end_label):
|
||||
"""Extracts and formats a labeled matrix from program output"""
|
||||
parts = output.split(f"{label}:\n")
|
||||
if len(parts) > 1:
|
||||
matrix_lines = parts[1].strip().split(end_label)[0].split("\n")
|
||||
return format_matrix("\n".join(matrix_lines)) # Убираем Task = ... строку
|
||||
return ""
|
||||
|
||||
def result_matrix_output(output):
|
||||
parts = output.split("Result matrix:\n")
|
||||
if len(parts) > 1:
|
||||
matrix_lines = parts[1].strip().split("\n")
|
||||
return format_matrix("\n".join(matrix_lines[:-1])) # Убираем Task = ... строку
|
||||
return format_matrix("\n".join(matrix_lines[:-1]))
|
||||
return ""
|
||||
|
||||
def initial_matrix_output(output):
|
||||
parts = output.split("Initial matrix:\n")
|
||||
if len(parts) > 1:
|
||||
parts = parts[1].split("Result")
|
||||
matrix_lines = parts[0].strip().split("\n")
|
||||
return format_matrix("\n".join(matrix_lines))
|
||||
return ""
|
||||
|
||||
def transpose_matrix(matrix):
|
||||
|
@ -121,8 +136,8 @@ def run_test(test_suite, test):
|
|||
result = run_command(cmd)
|
||||
|
||||
# Extract both initial and result matrices
|
||||
initial_matrix = parse_matrix_output(result.stdout, "Initial matrix")
|
||||
result_matrix = parse_matrix_output(result.stdout, "Result matrix")
|
||||
initial_matrix = initial_matrix_output(result.stdout)
|
||||
result_matrix = result_matrix_output(result.stdout)
|
||||
|
||||
# Compute expected transposed matrix
|
||||
expected_transposed = transpose_matrix(initial_matrix)
|
||||
|
@ -134,13 +149,15 @@ def run_test(test_suite, test):
|
|||
return
|
||||
|
||||
print(color_text(f"[PASS] Test '{test.name}' passed.", Fore.GREEN))
|
||||
|
||||
if test.k == 0:
|
||||
# Cleanup test file
|
||||
try:
|
||||
os.remove(filename)
|
||||
except (FileNotFoundError, PermissionError):
|
||||
print(color_text(f"[WARNING] Could not delete {filename}, Windows may be locking it.", Fore.RED))
|
||||
|
||||
# Cleanup test file
|
||||
try:
|
||||
os.remove(filename)
|
||||
except (FileNotFoundError, PermissionError):
|
||||
print(color_text(f"[WARNING] Could not delete {filename}, Windows may be locking it.", Fore.RED))
|
||||
|
||||
|
||||
def main():
|
||||
print(color_text("[CLEAN] Cleaning project...", Fore.BLUE))
|
||||
run_command("make clean", exit_on_error=True)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue