Commit bab68fe7 authored by Joseph Weston's avatar Joseph Weston

add basic pretty printing for finalized systems

Closes #270.
parent c02c1c03
Pipeline #15390 passed with stages
in 67 minutes and 5 seconds
......@@ -70,6 +70,20 @@ class System(metaclass=abc.ABCMeta):
return DiscreteSymmetry()
def __str__(self):
items = [
# (format, extractor, skip if info not present)
('{} sites', self.graph.num_nodes, False),
('{} hoppings', self.graph.num_edges, False),
('parameters: {}', tuple(self.parameters), True),
# Skip some information when it's not present (parameters)
details = [fmt.format(info) for fmt, info, skip in items
if (info or not skip)]
details = ', and '.join((', '.join(details[:-1]), details[-1]))
return '<{} with {}>'.format(self.__class__.__name__, details)
# Add a C-implemented function as an unbound method to class System.
System.hamiltonian_submatrix = _system.HamiltonianSubmatrix()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment