ver Dec27thv2

updated a task config
updated documents
fixed the options feature of evaluator
updated with new properties of charts
current load_charts should be ok, I think
This commit is contained in:
David Chang
2023-12-27 17:51:41 +08:00
parent 54bf8ff9d1
commit 4e5920264a
4 changed files with 26 additions and 3 deletions

View File

@@ -79,6 +79,7 @@ class DesktopEnv(gym.Env):
self.metric: Metric = getattr(metrics, self.evaluator["func"])
self.result_getter: Getter = getattr(getters, "get_{:}".format(self.evaluator["result"]["type"]))
self.expected_getter: Getter = getattr(getters, "get_{:}".format(self.evaluator["expected"]["type"]))
self.metric_options: Dict[str, Any] = self.evaluator.get("options", {})
# Initialize emulator and controller
print("Initializing...")
@@ -165,6 +166,7 @@ class DesktopEnv(gym.Env):
self.metric: Metric = getattr(metrics, self.evaluator["func"])
self.result_getter: Getter = getattr(getters, "get_{:}".format(self.evaluator["result"]["type"]))
self.expected_getter: Getter = getattr(getters, "get_{:}".format(self.evaluator["expected"]["type"]))
self.metric_options = self.evaluator.get("options", {})
self.setup_controller.reset_cache_dir(self.cache_dir)
@@ -237,7 +239,7 @@ class DesktopEnv(gym.Env):
result = self.result_getter(self, self.evaluator["result"])
expected = self.expected_getter(self, self.evaluator["expected"])
metric: float = self.metric(result, expected)
metric: float = self.metric(result, expected, **self.metric_options)
return metric

View File

@@ -130,4 +130,4 @@ if __name__ == '__main__':
path1 = "../../../../../任务数据/LibreOffice Calc/Create_column_charts_using_statistics_gold.xlsx"
path2 = "../../../../../任务数据/LibreOffice Calc/Create_column_charts_using_statistics_gold2.xlsx"
print(compare_with_charts(path1, path2, chart_props=["title"]))
print(compare_with_charts(path1, path2, chart_props=["type"]))

View File

@@ -48,6 +48,13 @@ def load_sparklines(xlsx_file: str) -> Dict[str, str]:
sparklines_dict[sparkline["x14:sparkline"]["xm:sqref"]] = sparkline["x14:sparkline"]["xm:f"]
return sparklines_dict
# Available Chart Properties:
# title: str
# anchor: ["oneCell" | "twoCell" | "absolute", col0, row0, col1, row1]
# width: number
# height: number
# type: "scatterChart" | "lineChart" | "barChart"
# xtitle, ytitle, ztitle: str
def load_charts(xlsx_file: str, **options) -> Dict[str, Any]:
"""
Args:
@@ -100,6 +107,15 @@ def load_charts(xlsx_file: str, **options) -> Dict[str, Any]:
info["width"] = ch.width
if "height" in chart_props:
info["height"] = ch.height
if "type" in chart_props:
info["type"] = ch.tagname
if "xtitle" in chart_props:
info["xtitle"] = ch.x_axis.title.tx.rich.p[0].r[0].t
if "ytitle" in chart_props:
info["ytitle"] = ch.y_axis.title.tx.rich.p[0].r[0].t
if "ztitle" in chart_props:
info["ztitle"] = ch.z_axis.title.tx.rich.p[0].r[0].t
chart_set[series] = info
return chart_set
@@ -139,4 +155,4 @@ if __name__ == "__main__":
#df1 = pd.read_excel(path1)
#print(df1)
print(load_charts(path1, chart_props=["title", "width", "height"]))
print(load_charts(path1, chart_props=["title", "xtitle", "ytitle", "type"]))

View File

@@ -37,6 +37,11 @@
"type": "cloud_file",
"path": "https://101.43.24.67/s/SLL4CgyMiyre3Ss/download/Create_column_charts_using_statistics_gold.xlsx",
"dest": "Create_column_charts_using_statistics_gold.xlsx"
},
"options": {
"chart_props": [
"type"
]
}
}
}