diff --git a/desktop_env/evaluators/metrics/table.py b/desktop_env/evaluators/metrics/table.py index e2c105c..82ad0ac 100644 --- a/desktop_env/evaluators/metrics/table.py +++ b/desktop_env/evaluators/metrics/table.py @@ -144,7 +144,10 @@ def compare_table(result: str, expected: str = None, **options) -> float: metric: bool = sheet1.equals(sheet2) logger.debug("Sheet1: \n%s", str(sheet1)) logger.debug("Sheet2: \n%s", str(sheet2)) - logger.debug("Sheet1 =v= Sheet2: \n%s", str(sheet1==sheet2)) + try: + logger.debug("Sheet1 =v= Sheet2: \n%s", str(sheet1==sheet2)) + except: + logger.debug("Sheet1 =/v= Sheet2") logger.debug("Assertion: %s =v= %s - %s", r["sheet_idx0"], r["sheet_idx1"], metric) # }}} Compare Sheet Data by Internal Value # diff --git a/desktop_env/evaluators/metrics/utils.py b/desktop_env/evaluators/metrics/utils.py index 55a6e8e..0747726 100644 --- a/desktop_env/evaluators/metrics/utils.py +++ b/desktop_env/evaluators/metrics/utils.py @@ -119,22 +119,15 @@ def load_charts(xlsx_file: Workbook, sheet_name: str, **options) -> Dict[str, An for ch in charts: series: List[str] = [] for ser in ch.series: - value_num = ser.val.numRef.f \ - if hasattr(ser.val, "numRef") and hasattr(ser.val.numRef, "f") \ - else "" - value_str = ser.val.strRef.f \ - if hasattr(ser.val, "strRef") and hasattr(ser.val.strRef, "f") \ - else "" - categ_num = ser.cat.numRef.f \ - if hasattr(ser.cat, "numRef") and hasattr(ser.cat.numRef, "f") \ - else "" - categ_str = ser.cat.strRef.f \ - if hasattr(ser.cat, "strRef") and hasattr(ser.cat.strRef, "f") \ - else "" - series.append("{:},{:},{:},{:}".format(value_num, value_str - , categ_num, categ_str - ) - ) + if hasattr(ser.val, "numRef") and hasattr(ser.val.numRef, "f"): + value_str: str = ser.val.numRef.f + elif hasattr(ser.val, "strRef") and hasattr(ser.val.strRef, "f"): + value_str: str = ser.val.strRef.f + if hasattr(ser.cat, "numRef") and hasattr(ser.cat.numRef, "f"): + categ_str: str = ser.cat.numRef.f + elif hasattr(ser.cat, "strRef") and hasattr(ser.cat.strRef, "f"): + categ_str: str = ser.cat.strRef.f + series.append("{:},{:}".format(value_str, categ_str)) series: str = ";".join(series) # TODO: maybe more aspects, like chart type diff --git a/evaluation_examples/examples/sheetcopilot/035f41ba-6653-43ab-aa63-c86d449d62e5.json b/evaluation_examples/examples/sheetcopilot/035f41ba-6653-43ab-aa63-c86d449d62e5.json index a267101..1f309e8 100644 --- a/evaluation_examples/examples/sheetcopilot/035f41ba-6653-43ab-aa63-c86d449d62e5.json +++ b/evaluation_examples/examples/sheetcopilot/035f41ba-6653-43ab-aa63-c86d449d62e5.json @@ -1,7 +1,7 @@ { "id": "035f41ba-6653-43ab-aa63-c86d449d62e5", "snapshot": "libreoffice_calc", - "instruction": "Help me fill in the Gross profit column and set the results as accounting type. Then under column A named \"Year_Profit\" in a new sheet, display the Year Column in Sheet 1 as text appended by a \"_\" with the corresponding Gross Profit value.", + "instruction": "Help me fill in the Gross profit column. Then under column A named \"Year_Profit\" in a new sheet, display the Year Column in Sheet 1 as text appended by a \"_\" with the corresponding Gross Profit value.", "source": "SheetCopilot@92", "config": [ { diff --git a/evaluation_examples/examples/sheetcopilot/26a8440e-c166-4c50-aef4-bfb77314b46b.json b/evaluation_examples/examples/sheetcopilot/26a8440e-c166-4c50-aef4-bfb77314b46b.json index edf3dc3..4e96b4d 100644 --- a/evaluation_examples/examples/sheetcopilot/26a8440e-c166-4c50-aef4-bfb77314b46b.json +++ b/evaluation_examples/examples/sheetcopilot/26a8440e-c166-4c50-aef4-bfb77314b46b.json @@ -73,10 +73,10 @@ "rules": [ { "type": "sheet_data", - "sheet_idx0": 0, - "sheet_idx1": "EI0" + "sheet_idx0": "RNSheet2", + "sheet_idx1": "ENSheet2" } ] } } -} \ No newline at end of file +} diff --git a/evaluation_examples/examples/sheetcopilot/28047f4a-d877-4bea-95f7-e42b1c919957.json b/evaluation_examples/examples/sheetcopilot/28047f4a-d877-4bea-95f7-e42b1c919957.json index c1fb986..3ab267e 100644 --- a/evaluation_examples/examples/sheetcopilot/28047f4a-d877-4bea-95f7-e42b1c919957.json +++ b/evaluation_examples/examples/sheetcopilot/28047f4a-d877-4bea-95f7-e42b1c919957.json @@ -1,7 +1,7 @@ { "id": "28047f4a-d877-4bea-95f7-e42b1c919957", "snapshot": "libreoffice_calc", - "instruction": "Summarize the sales for each product and illustrate it with a bar chart in a new sheet.", + "instruction": "Summarize the sales for each product and illustrate it with a bar chart in a new sheet (Sheet2).", "source": "SheetCopilot@108", "config": [ { @@ -54,7 +54,7 @@ { "type": "sleep", "parameters": { - "seconds": 0.5 + "seconds": 2.0 } } ], @@ -73,16 +73,16 @@ "rules": [ { "type": "chart", - "sheet_idx0": 0, - "sheet_idx1": "EI0", + "sheet_idx0": "RNSheet2", + "sheet_idx1": "ENSheet2", "chart_props": [ "type" ] }, { "type": "pivot_table", - "sheet_idx0": 0, - "sheet_idx1": "EI0", + "sheet_idx0": "RNSheet2", + "sheet_idx1": "ENSheet2", "pivot_props": [ "col_fields", "filter", @@ -93,4 +93,4 @@ ] } } -} \ No newline at end of file +} diff --git a/evaluation_examples/examples/sheetcopilot/30e3e107-1cfb-46ee-a755-2cd080d7ba6a.json b/evaluation_examples/examples/sheetcopilot/30e3e107-1cfb-46ee-a755-2cd080d7ba6a.json index dd32682..ad9c17f 100644 --- a/evaluation_examples/examples/sheetcopilot/30e3e107-1cfb-46ee-a755-2cd080d7ba6a.json +++ b/evaluation_examples/examples/sheetcopilot/30e3e107-1cfb-46ee-a755-2cd080d7ba6a.json @@ -73,21 +73,40 @@ "rules": [ { "type": "sheet_data", - "sheet_idx0": 0, - "sheet_idx1": "EI0" + "sheet_idx0": "RNSheet2", + "sheet_idx1": "ENSheet2" }, { "type": "pivot_table", - "sheet_idx0": 0, - "sheet_idx1": "EI0", + "sheet_idx0": "RNSheet2", + "sheet_idx1": "ENSheet2", "pivot_props": [ "col_fields", "filter", "row_fields", "data_fields" ] + }, + { + "type": "check_cell", + "sheet_idx": "RNSheet2", + "coordinate": "A1", + "props": { + "bgcolor": { + "method": "eq", + "ref": "FF0000FF" + }, + "font_color": { + "method": "eq", + "ref": "FFFFFFFF" + }, + "font_bold": { + "method": "eq", + "ref": true + } + } } ] } } -} \ No newline at end of file +} diff --git a/evaluation_examples/examples/sheetcopilot/42e0a640-4f19-4b28-973d-729602b5a4a7.json b/evaluation_examples/examples/sheetcopilot/42e0a640-4f19-4b28-973d-729602b5a4a7.json index e608701..2f33e42 100644 --- a/evaluation_examples/examples/sheetcopilot/42e0a640-4f19-4b28-973d-729602b5a4a7.json +++ b/evaluation_examples/examples/sheetcopilot/42e0a640-4f19-4b28-973d-729602b5a4a7.json @@ -73,10 +73,10 @@ "rules": [ { "type": "sheet_data", - "sheet_idx0": 0, - "sheet_idx1": "EI0" + "sheet_idx0": "RNSheet2", + "sheet_idx1": "ENSheet2" } ] } } -} \ No newline at end of file +} diff --git a/evaluation_examples/examples/sheetcopilot/447b9505-7a2f-4863-9dd1-69395482eb4b.json b/evaluation_examples/examples/sheetcopilot/447b9505-7a2f-4863-9dd1-69395482eb4b.json index c53bb07..58b3286 100644 --- a/evaluation_examples/examples/sheetcopilot/447b9505-7a2f-4863-9dd1-69395482eb4b.json +++ b/evaluation_examples/examples/sheetcopilot/447b9505-7a2f-4863-9dd1-69395482eb4b.json @@ -1,7 +1,7 @@ { "id": "447b9505-7a2f-4863-9dd1-69395482eb4b", "snapshot": "libreoffice_calc", - "instruction": "Divide the values through column C to P by 1 million and put the results along with the year headers in a new sheet. Set the results type as accounting.", + "instruction": "Divide the values through column C to P by 1 million and put the results along with the year headers in a new sheet.", "source": "SheetCopilot@28", "config": [ { @@ -54,7 +54,7 @@ { "type": "sleep", "parameters": { - "seconds": 0.5 + "seconds": 10 } } ], @@ -73,10 +73,11 @@ "rules": [ { "type": "sheet_data", - "sheet_idx0": 0, - "sheet_idx1": "EI0" + "sheet_idx0": "RNSheet2", + "sheet_idx1": "ENSheet2", + "precision": 2 } ] } } -} \ No newline at end of file +} diff --git a/evaluation_examples/examples/sheetcopilot/4de54231-e4b5-49e3-b2ba-61a0bec721c0.json b/evaluation_examples/examples/sheetcopilot/4de54231-e4b5-49e3-b2ba-61a0bec721c0.json index bb8ea76..3a29eea 100644 --- a/evaluation_examples/examples/sheetcopilot/4de54231-e4b5-49e3-b2ba-61a0bec721c0.json +++ b/evaluation_examples/examples/sheetcopilot/4de54231-e4b5-49e3-b2ba-61a0bec721c0.json @@ -1,7 +1,7 @@ { "id": "4de54231-e4b5-49e3-b2ba-61a0bec721c0", "snapshot": "libreoffice_calc", - "instruction": "I have compute the acceleration in row 2 and I want you to fill out other rows for column B and E. Next concatenate the values from columns A to D, including their headers (the pattern is \"Header: cell value, ..., Header: cell value\"), into a new column named \"Combined Data\" for all rows.", + "instruction": "I have compute the acceleration in row 2 and I want you to fill out other rows for column B and D. Next concatenate the values from columns A to D, including their headers (the pattern is \"Header: cell value, ..., Header: cell value\"), into a new column named \"Combined Data\" for all rows. In the new column, only keep 2 decimal digits.", "source": "SheetCopilot@147", "config": [ { @@ -79,4 +79,4 @@ ] } } -} \ No newline at end of file +} diff --git a/evaluation_examples/examples/sheetcopilot/51719eea-10bc-4246-a428-ac7c433dd4b3.json b/evaluation_examples/examples/sheetcopilot/51719eea-10bc-4246-a428-ac7c433dd4b3.json index 4098230..90faf05 100644 --- a/evaluation_examples/examples/sheetcopilot/51719eea-10bc-4246-a428-ac7c433dd4b3.json +++ b/evaluation_examples/examples/sheetcopilot/51719eea-10bc-4246-a428-ac7c433dd4b3.json @@ -1,7 +1,7 @@ { "id": "51719eea-10bc-4246-a428-ac7c433dd4b3", "snapshot": "libreoffice_calc", - "instruction": "Calculate revenue and generate a Pivot Table in a new sheet that summarizes the revenue of each product. In the same sheet, create a bar chart to display the table with data labels on top of the bars.", + "instruction": "Calculate revenue in a new column and generate a Pivot Table in a new sheet (Sheet2) that summarizes the revenue of each product.", "source": "SheetCopilot@7", "config": [ { @@ -71,18 +71,10 @@ }, "options": { "rules": [ - { - "type": "chart", - "sheet_idx0": 0, - "sheet_idx1": "EI0", - "chart_props": [ - "type" - ] - }, { "type": "pivot_table", - "sheet_idx0": 0, - "sheet_idx1": "EI0", + "sheet_idx0": "RNSheet2", + "sheet_idx1": "ENSheet2", "pivot_props": [ "col_fields", "filter", @@ -93,4 +85,4 @@ ] } } -} \ No newline at end of file +} diff --git a/evaluation_examples/examples/sheetcopilot/535364ea-05bd-46ea-9937-9f55c68507e8.json b/evaluation_examples/examples/sheetcopilot/535364ea-05bd-46ea-9937-9f55c68507e8.json index 34a5c0c..8bf2502 100644 --- a/evaluation_examples/examples/sheetcopilot/535364ea-05bd-46ea-9937-9f55c68507e8.json +++ b/evaluation_examples/examples/sheetcopilot/535364ea-05bd-46ea-9937-9f55c68507e8.json @@ -1,7 +1,7 @@ { "id": "535364ea-05bd-46ea-9937-9f55c68507e8", "snapshot": "libreoffice_calc", - "instruction": "Create two tables in a new sheet showing the total revenue for each product and sales channel. Plot a horizontal bar chart for the former and a pie chart for the latter in the new sheet.", + "instruction": "Create two tables in a new sheet showing the total revenue for each product and sales channel.", "source": "SheetCopilot@180", "config": [ { @@ -71,18 +71,10 @@ }, "options": { "rules": [ - { - "type": "chart", - "sheet_idx0": 0, - "sheet_idx1": "EI0", - "chart_props": [ - "type" - ] - }, { "type": "pivot_table", - "sheet_idx0": 0, - "sheet_idx1": "EI0", + "sheet_idx0": "RNSheet2", + "sheet_idx1": "ENSheet2", "pivot_props": [ "col_fields", "filter", @@ -93,4 +85,4 @@ ] } } -} \ No newline at end of file +}