Skip to content

Add pandas + matplotlib data-visualization example#33

Draft
TomNaessens wants to merge 6 commits into
masterfrom
enhancement/add-pandas-matplotlib-example
Draft

Add pandas + matplotlib data-visualization example#33
TomNaessens wants to merge 6 commits into
masterfrom
enhancement/add-pandas-matplotlib-example

Conversation

@TomNaessens
Copy link
Copy Markdown
Contributor

@TomNaessens TomNaessens commented May 28, 2026

Summary

Adds a new example exercise under tested/data-visualization/ that demonstrates a TESTed Python exercise combining CSV reading with pandas, data aggregation, and chart generation with matplotlib. The Pokémon-themed data set is meant to be relatable for students.

The exercise asks students to implement six functions across four small CSV files (pokemon.csv, starters.csv, eeveelutions.csv, legendary.csv): load_pokemon, number_of_pokemon, all_types, strongest_pokemon, strongest_per_type, and plot_top_pokemon. The suite has 5 tabs with 29 test cases — 16 standard-DSL tests for the analytic functions and 13 Python-specific expression blocks that inspect properties of the returned matplotlib.figure.Figure (title, axis labels, bar count, bar heights, x-tick labels) via a context-shared fig variable.

The four CSV files live in workdir/ so the judge auto-mounts them at test time — no files: directive needed in the suite.

Dependency note

The exercise needs matplotlib (and pandas) inside the dodona-tested Docker image. pandas is already in the upstream Dockerfile; matplotlib is not yet there. A separate change to dodona-edu/docker-images is needed before this exercise can run on the live platform. Verification for this PR was done locally against a dodona-tested image with pandas and matplotlib layered on top.

PRs are open in dodona-edu/docker-images#404 to support that soon, but we won't do those now sinze we have to increase the disk size first.

Test plan

  • DSL validation passes (python3 -m tested.dsl -i evaluation/suite.yaml)
  • Reference solution passes 29/29 tests
  • Trivially wrong solution (# wrong) is rejected on all 61 generated tests
  • Description renders in both English and Dutch with HTML tables (no Markdown pipe tables) and is legible in light/dark mode
  • Reviewer renders the description on a staging Dodona instance to confirm formatting
  • matplotlib is added to the dodona-tested image before the exercise is exposed to students

🤖 Generated with Claude Code

Demonstrates a TESTed Python exercise that combines CSV reading with
pandas, data aggregation, and chart generation with matplotlib. The
suite has 5 tabs (29 tests): 16 standard-DSL tests for the analytic
functions and 13 Python-specific expressions inspecting properties of
the returned matplotlib Figure (title, axis labels, bar count, bar
heights, tick labels). Four Pokémon CSV files of varying size live in
workdir/ so the judge auto-mounts them at test time.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@TomNaessens TomNaessens added the enhancement New feature or request label May 28, 2026
@TomNaessens TomNaessens self-assigned this May 28, 2026
@TomNaessens TomNaessens marked this pull request as draft May 28, 2026 08:35
TomNaessens and others added 4 commits May 28, 2026 10:39
- New description/boilerplate/boilerplate file pre-fills the editor
  with function stubs and an __main__ block that calls every function
  on pokemon.csv and renders the bar chart. Students replace the
  NotImplementedError stubs and immediately see results when they
  press Run in the sandbox.
- solution/solution.py gains the same __main__ block so the teacher
  preview matches the student-facing scaffold.
- description/media/ now ships the four CSVs and both description
  files link to them so users can grab the data into the sandbox.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Following the tested/files convention: runtime data files live in
workdir/, not in description/media/. Removed the four CSV copies and
dropped the now-broken `[file](media/foo.csv)` links from both
descriptions, with a short note that the files are already pre-loaded
in the sandbox.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Reverts the previous cleanup: data files for TESTed exercises need to
live in BOTH workdir/ (so the judge can mount them at test time) and
description/media/ (so the description's [name](media/foo.csv) links
render and let users open the file). The two copies stay in sync.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Papyros imports student code under module name "sandbox"; TESTed
imports it as "submission"; "__main__" never matches in either
context, so the previous `if __name__ == "__main__":` block was dead
code on Dodona. Using `if __name__ == "sandbox":` makes the demo
fire only when the student presses Run in the sandbox, while
remaining invisible to the judge (still 29/29 with reference). Both
descriptions updated to mention the construct explicitly.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@TomNaessens TomNaessens requested a review from chvp May 28, 2026 11:28
@TomNaessens TomNaessens marked this pull request as ready for review May 28, 2026 11:28
@TomNaessens TomNaessens enabled auto-merge May 28, 2026 11:40
@TomNaessens
Copy link
Copy Markdown
Contributor Author

Tested in Firefox:

image image

Tabs are shown to the student in Dodona's feedback panel; English
reaches a wider audience than Dutch even though the exercise itself is
bilingual. "Aantal Pokémon" -> "Number of Pokémon", "Sterkste" ->
"Strongest", "Sterkste per type" -> "Strongest per type", "Grafiek"
-> "Chart". ("Types" was already language-neutral.)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@TomNaessens TomNaessens marked this pull request as draft May 29, 2026 07:41
auto-merge was automatically disabled May 29, 2026 07:41

Pull request was converted to draft

@TomNaessens
Copy link
Copy Markdown
Contributor Author

Drafted until we have a working judge side of matplotlib running & evaluation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant