4
0

+ Fixed Floating test suite.

This commit is contained in:
SAVELIY BAKTURIN
2026-03-08 18:08:25 +00:00
parent 351b7fb8c5
commit 885757f752
4 changed files with 129 additions and 14 deletions

View File

@@ -6,6 +6,7 @@ import enum
import signal
from typing import List, Optional, Tuple, Union, Callable, TypeVar, Any, Dict, Set, Iterable
from decimal import Decimal
from abc import abstractmethod, ABC
T = TypeVar('T')
@@ -398,31 +399,33 @@ class Result:
def __get_total_by_category(self, category: str) -> int:
total = 0
for test, verdict in zip(self.__tests, self.__verdicts):
for test, _ in zip(self.__tests, self.__verdicts):
if category in test.categories():
total += 1
return total
def __get_result_by_category(self, category: str) -> float:
def __get_result_by_category(self, category: str) -> Decimal:
total = self.__get_total_by_category(category)
passed = self.__get_passed_by_category(category)
return passed / total
if total == 0:
return Decimal(0.0)
return Decimal(passed) / Decimal(total)
def __calculate_total(self, coefficients: Dict[str, float]) -> float:
total = 0.0
def __calculate_total(self, coefficients: Dict[str, float]) -> Decimal:
total = Decimal(0.0)
for category, coefficient in coefficients.items():
result = self.__get_result_by_category(category)
total += result * coefficient
total += result * Decimal(coefficient)
return total
def __get_results_by_categories(self, categories: Iterable[str]) -> Dict[str, float]:
results: Dict[str, float] = {}
def __get_results_by_categories(self, categories: Iterable[str]) -> Dict[str, str]:
results: Dict[str, str] = {}
for category in categories:
results[category] = self.__get_result_by_category(category)
results[category] = str(self.__get_result_by_category(category))
return results
@@ -464,7 +467,7 @@ class Result:
j: Dict[str, Any] = {}
j["result"] = self.__calculate_total(coefficients)
j["result"] = str(self.__calculate_total(coefficients))
j["categories"] = self.__get_results_by_categories(categories)
j["tests"] = self.__get_results()