diff --git a/desktop_env/evaluators/metrics/table.py b/desktop_env/evaluators/metrics/table.py index 294e2e5..873e808 100644 --- a/desktop_env/evaluators/metrics/table.py +++ b/desktop_env/evaluators/metrics/table.py @@ -16,7 +16,8 @@ from openpyxl.worksheet.datavalidation import DataValidation from openpyxl.worksheet.worksheet import Worksheet from .utils import _match_value_to_rule, _read_cell_style, read_cell_value -from .utils import load_charts, load_sparklines, load_rows_or_cols, load_xlsx_styles +from .utils import load_charts, load_sparklines, load_rows_or_cols, load_xlsx_styles\ + , load_filters, load_pivot_tables # from openpyxl.utils import coordinate_to_tuple @@ -303,6 +304,29 @@ def compare_table(result: str, expected: str = None, **options) -> float: logger.debug("Assertion: %s[cols] == %s[cols] - %s", r["sheet_idx0"], r["sheet_idx1"], metric) # }}} Check Row Properties # + elif r["type"] == "filter": + # Compare Filters {{{ # + # sheet_idx0: 0 == "RI0" == "RNSheet1" | "EI0" == "ENSheet1" + # sheet_idx1: as sheet_idx0 + + filters1: Dict[str, Any] = load_filters(*parse_idx(r["sheet_idx0"], xlworkbookr, xlworkbooke), **r) + filters2: Dict[str, Any] = load_filters(*parse_idx(r["sheet_idx1"], xlworkbookr, xlworkbooke), **r) + metric: bool = filters1==filters2 + logger.debug("Assertion: %s[filter] == %s[filter] - %s", r["sheet_idx0"], r["sheet_idx1"], metric) + # }}} Compare Filters # + + elif r["type"] == "pivot_table": + # Compare Pivot Tables {{{ # + # sheet_idx0: 0 == "RI0" == "RNSheet1" | "EI0" == "ENSheet1" + # sheet_idx1: as sheet_idx0 + # pivot_props: list of str, see utils.load_pivot_tables + + pivots1: Dict[str, Any] = load_pivot_tables(*parse_idx(r["sheet_idx0"], xlworkbookr, xlworkbooke), **r) + pivots2: Dict[str, Any] = load_pivot_tables(*parse_idx(r["sheet_idx1"], xlworkbookr, xlworkbooke), **r) + metric: bool = pivots1==pivots2 + logger.debug("Assertion: %s[pivot]==%s[pivot] - %s", r["sheet_idx0"], r["sheet_idx1"], metric) + # }}} Compare Pivot Tables # + elif r["type"] == "check_cell": # Check Cell Properties {{{ # # sheet_idx: 0 == "RI0" == "RNSheet1" | "EI0" == "ENSheet1"