Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
gilbertohasnofb committed Jan 17, 2024
1 parent a6854f9 commit 3368569
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 24 deletions.
9 changes: 5 additions & 4 deletions auxjad/core/CrossFader.py
Original file line number Diff line number Diff line change
Expand Up @@ -1712,10 +1712,11 @@ def __init__(self,

def __repr__(self) -> str:
r"""Returns interpreter representation of both contents."""
string = abjad.lilypond(self._fader_out)
string += '\n'
string += abjad.lilypond(self._fader_in)
return string
strings = (
abjad.lilypond(self._fader_out),
abjad.lilypond(self._fader_in),
)
return '\n'.join(strings)

def __len__(self) -> int:
r"""Returns the sum of the number of notes of both contents."""
Expand Down
20 changes: 9 additions & 11 deletions auxjad/core/Repeater.py
Original file line number Diff line number Diff line change
Expand Up @@ -806,19 +806,17 @@ def _repeat_volta(self,
return
repeat = abjad.Repeat(repeat_count=n)
abjad.attach(repeat, dummy_contents)
strings = [
r'\tweak RehearsalMark.self-alignment-X #RIGHT',
r'\tweak RehearsalMark.break-visibility #begin-of-line-invisible',
r'\mark \markup{\box "' + str(n) + '×"}',
]
if n > 2 or (n == 2 and self._include_2x_volta_text):
strings = [
r"\tweak RehearsalMark.self-alignment-X #RIGHT",
r"\tweak RehearsalMark.break-visibility "
+ r"#begin-of-line-invisible",
r'\mark \markup{\box "' + str(n) + r'×"}'
]
for string in strings:
abjad.attach(abjad.LilyPondLiteral(string,
format_slot='after',
),
abjad.select(dummy_contents).leaf(-1),
)
abjad.attach(
abjad.LilyPondLiteral(string, format_slot='after'),
abjad.select(dummy_contents).leaf(-1),
)
dummy_container = abjad.Container([abjad.mutate.copy(dummy_contents)])
self._current_window = dummy_container[:]
dummy_container[:] = []
Expand Down
8 changes: 5 additions & 3 deletions auxjad/makers/GeneticAlgorithmMusicMaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -989,9 +989,11 @@ def __repr__(self) -> str:
r"""Returns interpreter representation of :attr:`target`'s of both
instances of the genetic algorithm (pitches and attack points).
"""
string = 'pitches: ' + repr(self._pitch_ga._target) + '\n'
string += 'attack_points: ' + repr(self._attack_point_ga._target)
return string
strings = (
f'pitches: {repr(self._pitch_ga._target)}',
f'attack_points: {repr(self._attack_point_ga._target)}',
)
return '\n'.join(strings)

def __len__(self) -> int:
r"""Returns the number of genes in each individual."""
Expand Down
12 changes: 6 additions & 6 deletions docs/image-generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@
contents = textwrap.dedent(contents)
if r'\new' in contents:
f.write(contents)
elif contents[0] == r'{' and contents[-1] == r'}':
elif contents[0] == '{' and contents[-1] == '}':
f.write(r'\new Staff' + '\n')
f.write(contents)
else: # wrap in {} otherwise
contents = textwrap.indent(contents, ' ')
f.write(r'\new Staff' + '\n')
f.write(r'{' + '\n')
f.write('{\n')
f.write(contents)
f.write('\n' + r'}')
f.write('\n}')

# generating lilypond files from example-n.rst files
for read_file in os.listdir('./examples'):
Expand All @@ -112,12 +112,12 @@
contents = textwrap.dedent(contents)
if r'\new' in contents:
f.write(contents)
elif contents[0] == r'{' and contents[-1] == r'}':
elif contents[0] == '{' and contents[-1] == '}':
f.write(r'\new Staff' + '\n')
f.write(contents)
else: # wrap in {} otherwise
contents = textwrap.indent(contents, ' ')
f.write(r'\new Staff' + '\n')
f.write(r'{' + '\n')
f.write('{\n')
f.write(contents)
f.write('\n' + r'}')
f.write('\n}')

0 comments on commit 3368569

Please sign in to comment.