From eff8aea11672f5a22403ccd81fab1f7535399ce5 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Fri, 24 May 2024 09:27:07 -0700 Subject: [PATCH] aider: Plot the results using `pylab`, importing it at the beginning of the script and modifying the `history` function to display an area graph of `aider_lines` and `total_lines` over time. # Aider chat conversation: USER: is pylab to plot the results. x-axis is commit number. area graph showing aider_lines and total_lines over time ASSISTANT: To plot the results using `pylab`, we need to: 1. Import `pylab` at the beginning of the script. 2. Modify the `history` function to collect the data and plot it. Here are the *SEARCH/REPLACE* blocks: scripts/blame.py ```python <<<<<<< SEARCH from pathlib import Path ======= from pathlib import Path import pylab as plt >>>>>>> REPLACE ``` scripts/blame.py ```python <<<<<<< SEARCH dump(results) ======= dump(results) # Plotting the results x = [i for i, _, _, _ in results] aider_lines = [aider_lines for _, aider_lines, _, _ in results] total_lines = [total_lines for _, _, total_lines, _ in results] plt.fill_between(x, aider_lines, label='Aider Lines', color='skyblue', alpha=0.5) plt.fill_between(x, total_lines, label='Total Lines', color='lightgreen', alpha=0.5) plt.xlabel('Commit Number') plt.ylabel('Lines of Code') plt.title('Aider Lines and Total Lines Over Time') plt.legend() plt.show() >>>>>>> REPLACE ``` --- scripts/blame.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/scripts/blame.py b/scripts/blame.py index d91076c1a..a2a193b59 100755 --- a/scripts/blame.py +++ b/scripts/blame.py @@ -4,6 +4,7 @@ import tempfile import sys import subprocess from pathlib import Path +import pylab as plt from aider.dump import dump def get_lines_with_commit_hash(filename, aider_commits, git_dname, verbose=False): @@ -134,6 +135,19 @@ def history(): dump(results) + # Plotting the results + x = [i for i, _, _, _ in results] + aider_lines = [aider_lines for _, aider_lines, _, _ in results] + total_lines = [total_lines for _, _, total_lines, _ in results] + + plt.fill_between(x, aider_lines, label='Aider Lines', color='skyblue', alpha=0.5) + plt.fill_between(x, total_lines, label='Total Lines', color='lightgreen', alpha=0.5) + plt.xlabel('Commit Number') + plt.ylabel('Lines of Code') + plt.title('Aider Lines and Total Lines Over Time') + plt.legend() + plt.show() +