CPJKU / partitura

A python package for handling modern staff notation of music
https://partitura.readthedocs.io
Apache License 2.0
227 stars 15 forks source link

handle none type doc order #328

Closed sildater closed 10 months ago

sildater commented 11 months ago

(reopen PR to correct branch)

The current matchfile_from_alignment from alignment uses the document order of notes in line 361 (exportmatch,py)

snote_sort_info[snote.id] = (onset_beats, snote.doc_order)

to later on sort by this value in line 460 ff

sort_stime = np.array(sort_stime)
sort_stime_idx = np.lexsort((sort_stime[:, 1], sort_stime[:, 0]))
note_lines = np.array(note_lines)[sort_stime_idx]

doc_order is a standard note property but it's only used for musicxml files so far. Scores/parts imported from match/mei/kern/midi do not have this property and the sorting breaks. A doc_order property shouldn't be a hard requirement though, so the doc_order extraction is now:

snote_sort_info[snote.id] = (onset_beats, snote.doc_order if snote.doc_order is not None else 0)
codecov-commenter commented 11 months ago

Codecov Report

Attention: 19 lines in your changes are missing coverage. Please review.

Files Coverage Δ
partitura/io/__init__.py 81.53% <100.00%> (ø)
partitura/io/exportmatch.py 79.79% <100.00%> (ø)
partitura/io/importkern.py 85.36% <ø> (+0.21%) :arrow_up:
partitura/io/importmidi.py 87.50% <100.00%> (ø)
partitura/io/importnakamura.py 85.71% <100.00%> (ø)
tests/test_tonal_tension.py 100.00% <ø> (ø)
partitura/io/musescore.py 41.93% <0.00%> (+14.46%) :arrow_up:
tests/test_musescore.py 75.00% <45.45%> (-25.00%) :arrow_down:
partitura/performance.py 84.97% <84.28%> (+5.97%) :arrow_up:

:loudspeaker: Thoughts on this report? Let us know!.