Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion music21/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
'''
from __future__ import annotations

__version__ = '10.0.1b1'
__version__ = '10.0.1b2'

def get_version_tuple(vv):
v = vv.split('.')
Expand Down
2 changes: 1 addition & 1 deletion music21/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<class 'music21.base.Music21Object'>

>>> music21.VERSION_STR
'10.0.1b1'
'10.0.1b2'

Alternatively, after doing a complete import, these classes are available
under the module "base":
Expand Down
24 changes: 16 additions & 8 deletions music21/sorting.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,26 @@
'''
from __future__ import annotations

from collections import namedtuple
from math import inf as INFINITY
from music21 import exceptions21
import typing as t

from music21.common.types import OffsetQL
from music21 import exceptions21

class SortingException(exceptions21.Music21Exception):
pass


class SortTuple(namedtuple('SortTuple', (
'atEnd', 'offset', 'priority', 'classSortOrder', 'isNotGrace', 'insertIndex'
))):
_SortTupleBase = t.NamedTuple('SortTuple', [ # type: ignore[name-match]
('atEnd', int),
('offset', OffsetQL),
('priority', int),
('classSortOrder', int),
('isNotGrace', int),
('insertIndex', int),
])

class SortTuple(_SortTupleBase):
'''
Derived class of namedTuple which allows for comparisons with pure ints/fractions.

Expand Down Expand Up @@ -255,9 +263,9 @@ def sub(self, other):
raise SortingException('Cannot add attributes from a different class')

outList = [min(getattr(self, attr), getattr(other, attr))
if attr in ('atEnd', 'isNotGrace')
else (getattr(self, attr) - getattr(other, attr))
for attr in self._fields] # _fields are the namedtuple attributes
if attr in ('atEnd', 'isNotGrace')
else (getattr(self, attr) - getattr(other, attr))
for attr in self._fields] # _fields are the namedtuple attributes

return self.__class__(*outList)

Expand Down