Skip to content

Commit

Permalink
Fix ElementarySpace repr
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakob-Unfried committed Nov 25, 2024
1 parent 93568eb commit 3f7d455
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions cyten/spaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,22 +549,23 @@ def _repr(self, show_symmetry: bool):
basis_perm = 'None'
else:
basis_perm = format_like_list(self._basis_perm)
elements = [f'ElementarySpace(']
elements = []
if show_symmetry:
elements.append(f'{self.symmetry!r}')
elements.extend([
f'sectors={format_like_list(self.symmetry.sector_str(a) for a in self.sectors)}',
f'multiplicities={format_like_list(self.multiplicities)}',
f'basis_perm={basis_perm}',
f'is_dual={self.is_dual}',
')'
f'is_dual={self.is_dual}'
])
one_line = ', '.join(elements)
one_line = f'ElementarySpace(' + ', '.join(elements) + ')'
if len(one_line) <= printoptions.linewidth:
return one_line
if all(len(l) <= printoptions.linewidth for l in elements) and len(elements) <= printoptions.maxlines_spaces:
elements[1:-1] = [f'{indent}{line},' for line in elements[1:-1]]
return '\n'.join(elements)
line_lengths_ok = all(len(l) <= printoptions.linewidth for l in elements)
num_lines_ok = (len(elements) + 2) <= printoptions.maxlines_spaces
if line_lengths_ok and num_lines_ok:
elements = [f'{indent}{line},' for line in elements]
return f'ElementarySpace(\n' +'\n'.join(elements) + '\n)'
# 2) Try showing summarized data
elements = [f'<ElementarySpace:']
if show_symmetry:
Expand Down

0 comments on commit 3f7d455

Please sign in to comment.