Skip to content

Commit

Permalink
Issue bspaans#85: Convert 12 statements to the usage of augmented ass…
Browse files Browse the repository at this point in the history
…ignments

Augmented assignment statements became available with Python 2.
https://docs.python.org/3/whatsnew/2.0.html#augmented-assignment

Thus improve 12 source code places accordingly.

Signed-off-by: Markus Elfring <[email protected]>
  • Loading branch information
elfring committed Nov 3, 2021
1 parent f131620 commit 9e2b17a
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions mingus/core/chords.py
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,7 @@ def add_result(short, poly=False):

# Recognizing polychords
if tries == 1 and not no_polychords:
polychords = polychords + determine_polychords(seventh, shorthand)
polychords += determine_polychords(seventh, shorthand)

# Recognizing sevenths
for triad in triads:
Expand Down Expand Up @@ -1333,7 +1333,7 @@ def determine_polychords(chord, shorthand=False):
polychords.append("%s|%s" % (chord1, chord2))
if shorthand:
for p in polychords:
p = p + " polychord"
p += " polychord"
return polychords


Expand Down
4 changes: 2 additions & 2 deletions mingus/core/intervals.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,10 @@ def augment_or_diminish_until_the_interval_is_right(note1, note2, interval):
# These are some checks to see if we have generated too much #'s or too much
# b's. In these cases we need to convert #'s to b's and vice versa.
if val > 6:
val = val % 12
val %= 12
val = -12 + val
elif val < -6:
val = val % -12
val %= -12
val = 12 + val

# Rebuild the note
Expand Down
2 changes: 1 addition & 1 deletion mingus/core/progressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def tuple_to_string(prog_tuple):
if acc > 6:
acc = 0 - acc % 6
elif acc < -6:
acc = acc % 6
acc %= 6
while acc < 0:
roman = "b" + roman
acc += 1
Expand Down
4 changes: 2 additions & 2 deletions mingus/extra/fft.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ def find_frequencies(data, freq=44100, bits=16):

# Scale by the length (n) and square the value to get the amplitude
p = [(abs(x) / float(n)) ** 2 * 2 for x in p[0:uniquePts]]
p[0] = p[0] / 2
p[0] /= 2
if n % 2 == 0:
p[-1] = p[-1] / 2
p[-1] /= 2

# Generate the frequencies and zip with the amplitudes
s = freq / float(n)
Expand Down
2 changes: 1 addition & 1 deletion mingus/midi/midi_track.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,5 +281,5 @@ def int_to_varbyte(self, value):

# Set the first bit on every one but the last bit.
for i in range(len(bytes) - 1):
bytes[i] = bytes[i] | 0x80
bytes[i] |= 0x80
return pack("%sB" % len(bytes), *bytes)
4 changes: 2 additions & 2 deletions mingus_examples/pygame-piano/pygame-piano.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def play_note(note):
# Getting the x coordinate of a white key can be done automatically

w = WHITE_KEYS.index(note.name) * white_key_width
w = w + octave_offset
w += octave_offset

# Add a list containing the x coordinate, the tick at the current time
# and of course the note itself to playing_w
Expand All @@ -145,7 +145,7 @@ def play_note(note):
w = 151
else:
w = 187
w = w + octave_offset
w += octave_offset
playing_b.append([w, tick, note])

# To find out what sort of chord is being played we have to look at both the
Expand Down
4 changes: 2 additions & 2 deletions scripts/api_doc_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,11 @@ def generate_callable_wikidocs(self, module_string, element_string, evaled, is_c
self.classes.append(docs)
elif _is_class(type(evaled)):
self.classes.append('\n.. class:: ' + element_string + '\n\n')
module_string = module_string + "." + element_string
module_string += "." + element_string
self.process_element_recursively(module_string, evaled, True)
elif hasattr(evaled, '__module__') and evaled.__module__ is not None and evaled.__module__.startswith(module_string):
self.classes.append('\n.. class:: ' + element_string + '\n\n')
module_string = module_string + "." + element_string
module_string += "." + element_string
self.process_element_recursively(module_string, evaled, True)
else:
pass
Expand Down

0 comments on commit 9e2b17a

Please sign in to comment.