Package: matt
MattMatt is a free software (licensed under theGNU GPL v3 (or later)) maths test program.
"Matt" (or "MATT") is a recursive acronym for "MATT Arithmetic Training Test".InstallationMatt depends on:termcolorpyxdgcolorama(windows only)There are 2 methods of installation: via poetry and via pip:Installation viapoetryPoetry should handle the installation of dependencies.
To install, first clone the git repository, then run:poetryinstallInstallation via pipPip should handle the installation of dependencies.
To install, run:python3-mpipinstallmattUsageRunpython3 -m matt -hfor help.
Matt accepts the following arguments:--difficultyor-dto set the difficulty (in the format "<namespace>:<number>").
Thedefaultnamespace is reserved for the default difficulties.
If unspecified the default isdefault:1.--operationsor-oto set the available operations.
Operations are separated by commas, the available operations are:+: Addition-: Subtraction*: Multiplication/: DivisionOne can also use custom operators defined in the configuration.Example:-o +,-to enable only addition and subtraction.--minimumor-mto set the minumum, default (if not specified in difficulty): 0.--maximumor-Mto set the maximum, default (if not specified in difficulty): 10.--question-amountor-qto set the amount of questions, the default is 10.NOTE: The maximum must be more than the minimum.ConfigMatt has a configuration file, it is written in Python,
and located at$XDG_CONFIG_HOME/matt/config.py.
By default$XDG_CONFIG_HOMEis set to~/.config,
so if you have not set it then it is probably~/.config/matt/config.py.The configuration can define custom difficulties and custom operations.Matt's builtin difficulties/operations are defined inmatt/defaults.py,
and they are defined in the same way as custom ones so you can look there for further examples
and details on Matt's defaults.Defining custom difficultiesThe configuration can provide adifficultyfunction that accepts 2 parameters:namespace(str): The namespace of the difficulty.number(int): The number of the difficulty.Thedifficultyfunction must return a dict or None (although if it simply returns None then it is useless).The dict can have the following keys:minimum(int): the minimum numbermaximum(int): the maximum numberoperations(a list of strs (typing.List[str])): a list of allowed operationsA simple example is:fromtypingimportUniondefdifficulty(namespace:str,number:int)->Union[dict,None]:ifnamespace=="manual":ifnumber==1:return{"operations":["+","-"],"maximum":20,"minimum":10}returnNoneIt is also possible to create a dynamic maximum,
like the following example, which creates a difficulty called "automatic",
whose maximum is the number * 10:fromtypingimportUniondefdifficulty(namespace:str,number:int)->Union[dict,None]:ifnamespace=="automatic":return{"operations":["+","-","*","/"],"maximum":number*10}returnNoneDefining custom operationsThe configuration can provide aoperationsdict to define custom operations.
The keys are the names of the operations,
and the values are dicts which can contain the following keys:format(function): a function which takes 2 numbers and returns a str.
The str is usually a string which contains both values and the operation,
it is used to ask the user about the answer.
Unlessformat_full_overrideorformat_colour_overrideare set to True,
it is sent to the user prepended withWhat is, and appended with?.
an example of a function used forformatis (this example would be for the+operation):lambdan1,n2:f"{n1}+{n2}"If this is not set then the default is<n1> <operation> <n2>.function(function): a function which takes 2 numbers,
and returns the correct answer for those 2 numbers. This must be defined.
Example (for a strange operation that is the result of addition - 1):lambdan1,n2:n1+n2-1format_full_override(bool): if this is True thenWhat is/?are not added to the string.format_colour_override(bool): if this is True then the string is not coloured.An example which defines an operation called!that is the result of addition -1,
and an operation called++that is the same as addition but just gives the user the answer:fromoperatorimportaddoperations:dict={"!":{"function":lambdan1,n2:n1+n2-1},"++":{"function":add,"format":lambdan1,n2:f"Type{n1+n2}! ","format_full_override":True}}