harbor run -t openthoughts/tasktrove-exp-rpt-issue-issue-2946harbor download openthoughts/tasktrove-exp-rpt-issue-issue-2946Summary
Bug/Feature request (clarity)
Before state (what you might see now) Note: The following files are intentionally in a suboptimal/broken state to motivate a fix. You will replace or modify them in /app/.
data_asia.csv (before)
year,min,max
2015,1.0,2.8
2016,1.1,3.0
2017,1.3,3.2
plot_minmax_scatter.py (before)
#!/usr/bin/env python3
import csv
import matplotlib.pyplot as plt
# Not explicitly using default style
mins = []
maxs = []
with open('data_asia.csv', newline='') as f:
reader = csv.DictReader(f)
for row in reader:
mins.append(float(row['min']))
maxs.append(float(row['max']))
plt.scatter(mins, maxs)
plt.xlabel('Min GDP')
plt.ylabel('Max GDP')
plt.title('Min vs Max GDP (Asia subset)')
plt.savefig('asia_minmax_scatter.png')
plot_max_by_year.py (before)
#!/usr/bin/env python3
import csv
import matplotlib.pyplot as plt
with open('data_asia.csv', newline='') as f:
reader = csv.DictReader(f)
data = [(row['year'], float(row['max'])) for row in reader]
years = [int(y) for y, _ in data]
max_vals = [v for _, v in data]
plt.plot(years, max_vals)
plt.savefig('asia_max_by_year.png')
benchmark.sh (before)
#!/bin/bash
set -e
echo "Starting benchmark"
./plot_minmax_scatter.py
./plot_max_by_year.py
echo "Done"
What you must do (exact files to create/modify in /app/)
What “correct” behavior looks like (goal you should achieve)
Notes
Files to create/modify (in /app/)
Code blocks (for reference – you will replace these with the final, correct versions in /app/)
data_asia.csv (final desired content example)
year,min,max
2015,1.0,2.8
2016,1.1,3.0
2017,1.3,3.2
2018,1.4,3.5
2019,1.5,3.7
2020,0.9,3.0
plot_minmax_scatter.py (final correct content)
#!/usr/bin/env python3
import csv
import matplotlib.pyplot as plt
plt.style.use('default')
mins = []
maxs = []
with open('data_asia.csv', newline='') as f:
reader = csv.DictReader(f)
for row in reader:
try:
mins.append(float(row['min']))
maxs.append(float(row['max']))
except (KeyError, ValueError):
continue
plt.scatter(mins, maxs)
plt.xlabel('Min GDP')
plt.ylabel('Max GDP')
plt.title('Min vs Max GDP (Asia subset)')
plt.tight_layout()
plt.savefig('asia_minmax_scatter.png')
plot_max_by_year.py (final correct content)
#!/usr/bin/env python3
import csv
import matplotlib.pyplot as plt
plt.style.use('default')
data = []
with open('data_asia.csv', newline='') as f:
reader = csv.DictReader(f)
for row in reader:
try:
y = int(row['year'])
mx = float(row['max'])
data.append((y, mx))
except (KeyError, ValueError):
continue
data.sort(key=lambda t: t[0])
if data:
years, max_vals = zip(*data)
else:
years, max_vals = [], []
plt.plot(years, max_vals, marker='o')
plt.xlabel('Year')
plt.ylabel('Max GDP')
plt.title('Max GDP by Year (Asia subset)')
plt.grid(True, linestyle='--', alpha=0.3)
plt.tight_layout()
plt.savefig('asia_max_by_year.png')
benchmark.sh (final correct content)
#!/usr/bin/env bash
set -euo pipefail
LOG="benchmark.log"
> "$LOG" # truncate previous log
echo "Benchmark run: $(date)" >> "$LOG"
# Time each plotting step; append timing lines to benchmark.log
if ! command -v time >/dev/null 2>&1; then
echo "Error: 'time' command not found" >&2
exit 1
fi
/usr/bin/time -a -f "plot_minmax_scatter: %e" -o "$LOG" python3 plot_minmax_scatter.py
/usr/bin/time -a -f "plot_max_by_year: %e" -o "$LOG" python3 plot_max_by_year.py
How to run (once /app/ is prepared)
This completes a self-contained, Linux-cli-friendly micro-benchmark that adheres to the described deliverables and verification criteria.