refactor: Extract color assignment logic into a separate function

This commit is contained in:
Paul Gauthier (aider) 2024-08-15 09:50:50 -07:00
parent 04e816ff2e
commit 5ccdebf2c0

View file

@ -6,6 +6,17 @@ from matplotlib import rc
from aider.dump import dump # noqa: 401
def get_model_color(model):
if "-4o" in model and "gpt-4o-mini" not in model:
return "purple"
elif "gpt-4" in model:
return "red"
elif "gpt-3.5" in model:
return "green"
else:
return "lightblue"
def plot_over_time(yaml_file):
with open(yaml_file, "r") as file:
data = yaml.safe_load(file)
@ -49,14 +60,7 @@ def plot_over_time(yaml_file):
spine.set_edgecolor("#DDDDDD")
spine.set_linewidth(0.5)
colors = [
(
"purple"
if "-4o" in model and "gpt-4o-mini" not in model
else "red" if "gpt-4" in model else "green" if "gpt-3.5" in model else "lightblue"
)
for model in models
]
colors = [get_model_color(model) for model in models]
# Separate data points by color
purple_points = [(d, r) for d, r, c in zip(dates, pass_rates, colors) if c == "purple"]