Abjad / abjad

Abjad is a Python API for building LilyPond files. Use Abjad to make PDFs of music notation.
https://abjad.github.io
GNU General Public License v3.0
234 stars 41 forks source link

NamedPitchClass.__sub__ is symmetrical #1482

Closed egginabucket closed 1 year ago

egginabucket commented 1 year ago

When subtracting PitchClass from PitchClass and an interval of P4 is expected, P5 is returned and vice versa.

trevorbaca commented 1 year ago

@egginabucket Please add a small example.

egginabucket commented 1 year ago

Sorry for the issues earlier, I was in a rush :( example:

>>> abjad.NamedPitchClass('g') - abjad.NamedPitchClass('c')
NamedInversionEquivalentIntervalClass('+P4')

>>> abjad.NamedPitchClass('c') - abjad.NamedPitchClass('g')
NamedInversionEquivalentIntervalClass('+P4')
trevorbaca commented 1 year ago

The behavior you're seeing is correct.

Try subtracting pitches, rather than pitch-classes, to see a different behavior.

egginabucket commented 1 year ago

Thank you, I solved my problem using PitchClass.number. This just seemed like unusual behaviour at the time.

trevorbaca commented 1 year ago

I think you were probably thinking in pitches instead of pitch-classes.