Skip to content

SageMath generators

Steven Clontz edited this page Jul 26, 2022 · 1 revision

Writing SageMath

Here are two recommended resources:

One note: the "working directory" for running your generators is the location of bank.xml. So, for example, if you have a bank at /my/great/bank/bank.xml, you are editing a generator at /my/great/bank/outcomes/foo/generator.sage, and you want to load some common custom code at /my/great/bank/library/common.sage, you should use the line load("library/common.sage") in your generator.

The CheckIt Module

When authoring SageMath generators, CheckIt supplies a CheckIt module with several helpful tools.

CheckIt.vars

Given one or more latex_names of strings, returns a tuple of Sage variables. random_order names them so that they appear in expressions in a random order.

Usage: a,b,c = CheckIt.vars('a','\\beta','C') # a,\beta,C will be displayed in a random order when combined into an expression.

CheckIt.shuffled_equation

Represents the equation sum(terms)==0, but with terms shuffled randomly to each side.

Usage: CheckIt.shuffled_equation(x^2,y^2) might return x^2+y^2=0, x^2=-y^2, etc.