Skip to content

Warnings and documentation about expected stream nesting #870

@jacobtylerwalls

Description

@jacobtylerwalls

Starting a thread to stash some ideas for documenting better the expected (tested) nested stream hierachy of (Opus) - Score - Part - Measure - (Voice)

Here's a warning we could emit on show or write:

index c43979d30..12c9855d1 100644
--- a/music21/base.py
+++ b/music21/base.py
@@ -2575,6 +2575,9 @@ class Music21Object(prebase.ProtoM21Object):
 
         scClass = common.findSubConverterForFormat(regularizedConverterFormat)
         formatWriter = scClass()
+        if self.isStream and not self.isWellFormedNotation():
+            environLocal.warn('''Your operations on this stream have left it malformed. 
+Try running makeNotation(), or see docs for stream.isWellFormedNotation()''')
         return formatWriter.write(self,
                                   regularizedConverterFormat,
                                   fp=fp,
@@ -2642,6 +2645,9 @@ class Music21Object(prebase.ProtoM21Object):
 
         scClass = common.findSubConverterForFormat(regularizedConverterFormat)
         formatWriter = scClass()
+        if self.isStream and not self.isWellFormedNotation():
+            environLocal.warn('''Your operations on this stream have left it malformed. 
+Try running makeNotation(), or see docs for stream.isWellFormedNotation()''')
         return formatWriter.show(self,
                                  regularizedConverterFormat,
                                  app=app,

Somewhere in the user's guide wouldn't be a bad idea, either. Maybe a couple more examples in the doctests for stream.isWellFormedNotation.

This comes up constantly on the list, as you know.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions