Skip to content
Snippets Groups Projects
Commit 01570051 authored by Christoph Groth's avatar Christoph Groth
Browse files

make string representations of named lattices and related objects useful by...

make string representations of named lattices and related objects useful by making them much more compact
parent 4630433b
No related branches found
No related tags found
No related merge requests found
......@@ -75,7 +75,9 @@ class Site(tuple):
return 'Site({0}, {1})'.format(repr(self.family), repr(self.tag))
def __str__(self):
return '{1} of {0}'.format(str(self.family), str(self.tag))
sf = self.family
return '<Site {1} of {0}>'.format(str(sf.name if sf.name else sf),
str(self.tag))
@property
def pos(self):
......@@ -113,7 +115,11 @@ class SiteFamily(object):
return self.canonical_repr
def __str__(self):
return '{0} object {1}'.format(self.__class__, self.name)
if self.name:
msg = '<{0} site family {1}>'
else:
msg = '<unnamed {0} site family>'
return msg.format(self.__class__.__name__, self.name)
def __hash__(self):
return self.hash
......@@ -344,6 +350,13 @@ class HoppingKind(object):
repr(self.family_a),
', ' + repr(self.family_b) if self.family_a != self.family_b else '')
def __str__(self):
return '{0}({1}, {2}{3})'.format(
self.__class__.__name__, str(tuple(self.delta)),
str(self.family_a),
', ' + str(self.family_b) if self.family_a != self.family_b else '')
################ Support for Hermitian conjugation
......
......@@ -101,6 +101,10 @@ class Polyatomic(object):
self.reduced_vecs, self.transf = lll.lll(prim_vecs)
self.voronoi = ta.dot(lll.voronoi(self.reduced_vecs), self.transf)
def __str__(self):
sl_names = ', '.join(str(sl.name) for sl in self.sublattices)
return '<Polyatomic lattice with sublattices {0}>'.format(sl_names)
def shape(self, function, start):
"""Return a key for all the lattice sites inside a given shape.
......@@ -429,12 +433,10 @@ class Monatomic(builder.SiteFamily, Polyatomic):
self.lattice_dim = len(prim_vecs)
if name != '':
msg = "Monatomic lattice {0}, vectors {1}, origin {2}"
self.cached_str = msg.format(name,
short_array_str(self._prim_vecs),
short_array_str(self.offset))
msg = "<Monatomic lattice {0}>"
self.cached_str = msg.format(name)
else:
msg = "unnamed Monatomic lattice, vectors {0}, origin [{1}]"
msg = "<unnamed Monatomic lattice, vectors {0}, origin [{1}]>"
self.cached_str = msg.format(short_array_str(self._prim_vecs),
short_array_str(self.offset))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment