example_code package¶
Submodules¶
example_code.addable module¶
example_code.euclid module¶
example_code.expression_tools module¶
example_code.graphs module¶
A simple tree implementation with basic pre- and post-visitors.
- class example_code.graphs.TreeNode(value, *children)[source]¶
Bases:
objectA basic tree implementation.
A tree is simply a collection of connected TreeNodes.
- Parameters:
value – An arbitrary value associated with this node.
children – The TreeNodes which are the children of this node.
- example_code.graphs.postvisitor(tree, fn)[source]¶
Traverse tree in postorder applying a function to every node.
- Parameters:
tree (TreeNode) – The tree to be visited.
fn (function(node, *fn_children)) – A function to be applied at each node. The function should take the node to be visited as its first argument, and the results of visiting its children as any further arguments.
- example_code.graphs.previsitor(tree, fn, fn_parent=None)[source]¶
Traverse tree in preorder applying a function to every node.
- Parameters:
tree (TreeNode) – The tree to be visited.
fn (function(node, fn_parent)) – A function to be applied at each node. The function should take the node to be visited as its first argument, and the result of visiting its parent as the second.
example_code.groups module¶
A module implementing the basic functionality of mathematical groups.
This version of the module uses inheritance.
- class example_code.groups.CyclicGroup(n)[source]¶
Bases:
GroupA cyclic group represented by integer addition modulo n.
- operation(a, b)[source]¶
Perform the group operation on two values.
The group operation is addition modulo n.
- symbol = 'C'¶
- class example_code.groups.Element(group, value)[source]¶
Bases:
objectAn element of the specified group.
- Parameters:
group (Group) – The group of which this is an element.
value – The value of this entity. Valid values depend on the group.
- class example_code.groups.GeneralLinearGroup(n)[source]¶
Bases:
GroupThe general linear group represented by n x n matrices.
- operation(a, b)[source]¶
Perform the group operation on two values.
The group operation is matrix multiplication.
- symbol = 'G'¶
- class example_code.groups.Group(n)[source]¶
Bases:
objectA base class containing methods common to many groups.
Each subclass represents a family of parametrised groups.
- Parameters:
n (int) – The primary group parameter, such as order or degree. The precise meaning of n changes from subclass to subclass.
example_code.groups_abc module¶
A module implementing the basic functionality of mathematical groups.
This version of the module uses inheritance and defines the base class as an
abc.ABC.
- class example_code.groups_abc.CyclicGroup(n)[source]¶
Bases:
GroupA cyclic group represented by integer addition modulo n.
- operation(a, b)[source]¶
Perform the group operation on two values.
The group operation is addition modulo n.
- symbol = 'C'¶
- class example_code.groups_abc.Element(group, value)[source]¶
Bases:
objectAn element of the specified group.
- Parameters:
group (Group) – The group of which this is an element.
value – The value of this entity. Valid values depend on the group.
- class example_code.groups_abc.GeneralLinearGroup(n)[source]¶
Bases:
GroupThe general linear group represented by n x n matrices.
- operation(a, b)[source]¶
Perform the group operation on two values.
The group operation is matrix multiplication.
- symbol = 'G'¶
- class example_code.groups_abc.Group(n)[source]¶
Bases:
ABCA base class containing methods common to many groups.
Each subclass represents a family of parametrised groups.
- Parameters:
n (int) – The primary group parameter, such as order or degree. The precise meaning of n changes from subclass to subclass.
- abstract property symbol¶
Represent the group name as a character.
example_code.groups_basic module¶
A module implementing the basic functionality of mathematical groups.
- class example_code.groups_basic.CyclicGroup(order)[source]¶
Bases:
objectA cyclic group represented by addition modulo group order.
example_code.hello module¶
example_code.linked_list module¶
example_code.polynomial module¶
example_code.shapes module¶
A module containing some very simple shape classes to illustrate the use of
super().
example_code.simple_classes module¶
A very elementary set of classes and objects for one of the week 3 quiz questions.
- example_code.simple_classes.g()¶
