CPJKU / partitura

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

Humdrum editorials/ part splits cause Nans in duration features #369

Open gg-g opened 2 months ago

gg-g commented 2 months ago

Python: 3.12.4 Partitura: 1.5.0 (develop branch)

When loading BWV 875b:

import numpy as np
import pandas as pd
import partitura as pt

score = pt.load_kern('testdata/875b.krn')

note_array = score.note_array(
    include_pitch_spelling=True,
    include_metrical_position=True
)
df = pd.DataFrame(note_array)
df[df.isna().any(axis=1)]

duration_beat and duration_quarter are NaN for

image

During import I also get warnings:

partitura/io/importkern.py:277: UserWarning: Part P2 already exists. Adding to previous Part.
partitura/io/importkern.py:277: UserWarning: Part P1 already exists. Adding to previous Part.

The first NaN seems to be caused by the editorials in measure 9

=8  =8  =8
*   *strophe    *
*   *^  *
*   *S/sic  *S/ossia    *
16DL    16f#xxL 8f#xx   8cc]L
16d 16dxxJ  .   .
*   *v  *v  *
*   *Xstrophe   *
16e-    4g  8b-J
manoskary commented 2 months ago

Thanks Gregory for your issue and for reporting those errors, I am on it!! I will work on a solution ASAP.

manoskary commented 2 months ago

Update on the issue

The editorial comments where not supported previously and as a result they could cause error during parsing. We will follow a similar approach to Verovio Humdrum Viewer where only the original version is kept and alternative passages are discarded. The PR #370 addresses such issues, it will be merged soon to the develop branch and will be included in main with the latest release. If you encounter other error please reach out!