-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error in some cases in replace_refs
#389
Comments
Thank you for raising this issue and the code to reproduce it! When I run it I get an error due to the |
I don't know how what I did with this code, but it does not work indeed! Removing the So far, it seems that the issue happens when the |
Found it! The issue seems to be caused by Here is an updated (normally working) script to reproduce the error: from pathlib import Path
import partitura as pt
import partitura.score
score_path = Path("/home/gerel/Documents/datasets/nasap-dataset/Schubert/Wanderer_fantasie/xml_score.musicxml")
score = pt.load_musicxml(score_path).parts[0]
score = pt.score.unfold_part_maximal(score)
# Setup window
start_measure = score.measures[0]
end_measure = score.measures[1]
# Create ScoreVariant
sv = pt.score.ScoreVariant(score)
sv.add_segment(start_measure.start, end_measure.end)
new_score = sv.create_variant_part() To debug, I overrode the def __setattr__(self, key, value):
if hasattr(self, "_ref_attrs") and key in self._ref_attrs and isinstance(value, list) and None in value:
print(f"{key} set to {value}")
super().__setattr__(key, value) and we can see that calling |
When dealing with
ScoreVariant
object, it seems to callreplace_refs
at some point. However, when a reference for an object is not found, it tries to print a warning specifying the start and end of the objecto_el
. However, it seems that sometimes,o_el
isNone
for some reason, and therefore the code raises aAttributeError: 'NoneType' object has no attribute 'start'
.Commenting out the following two warnings resolves the issue.
partitura/partitura/utils/generic.py
Lines 239 to 247 in 76f18c1
partitura/partitura/utils/generic.py
Lines 255 to 263 in 76f18c1
Code to reproduce:
The text was updated successfully, but these errors were encountered: