Skip to content

Issue using partitura.score.merge_parts with elements without explicit staff info #223

@CarlosCancino-Chacon

Description

@CarlosCancino-Chacon

There seems to be an issue merging parts by staff (i.e., using reassign="staff") if the certain non-note elements do not have staff information.

This is a minimal example to reproduce the issue (see attached MusicXML file):

import partitura as pt

score = pt.load_musicxml("28.xml")
part = pt.score.merge_parts(score.parts, reassign="staff")

Running this code results in the following error message:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-7-922f1ddd307d> in <module>
----> 1 part = pt.score.merge_parts(score.parts, reassign="staff")

~/Repos/partitura/partitura/score.py in merge_parts(parts, reassign)
   4705                 elif reassign == "staff":
   4706                     if isinstance(e, (GenericNote, Words, Direction)):
-> 4707                         e.staff = e.staff + sum(maximum_staves[:p_ind])
   4708                     elif isinstance(
   4709                         e, Clef

The solution should be fairly straightforward: simply assign staff number 1 to the elements that do not contain information, so that e.staff is always an integer.

28.xml.zip

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions