Repository navigation
Serialize scipy.sparse matrices across the sandbox boundary - #60
Merged
Merged
Conversation
`query` and `query_function` now round-trip scipy.sparse matrices and arrays. CSR, CSC and COO keep their native index arrays so the matrix comes back exactly as the student built it, including their own ordering of entries; other formats are returned as COO. Previously a sparse value came back as NOT_SERIALIZABLE, so questions whose graded output is a sparse matrix couldn't be run. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
eliotwrobson
marked this pull request as ready for review
November 20, 2026 06:41
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
queryandquery_functionnow serialize scipy.sparse matrices and arrays back to the grader. CSR, CSC and COO keep their nativedata/indices/indptr(orrow/col) arrays, so the matrix round-trips exactly as the student built it; other formats are returned as COO. Previously a sparse value came back asNOT_SERIALIZABLE.This unblocks converting legacy questions whose graded output is a sparse matrix read directly from student code (e.g. CS357's
11-Sparse/DBLP-matrix-normalization, which checksmodified_A.indices/.indptr/.data), without changing the student's task.scipyis added to the dev/test dependency group (it is already in the full image viarequirements-full.txt); the import stays lazy, sojson_utilsstill loads with no scientific stack on the:liteimage.Testing
json.dumps/loadsto exercise the real transport.test_sparse_matrix_queryscenario runs the full sandbox: student code builds sparse matrices, the test queries them back (and a function that returns one) and checks values and index arrays.🤖 Generated with Claude Code