music21.common.misc¶
If it doesn’t fit anywhere else in the common directory, you’ll find it here...
Functions¶
-
music21.common.misc.
defaultDeepcopy
(obj, memo, callInit=True)¶ Unfortunately, it is not possible to do something like:
- def __deepcopy__(self, memo):
- if self._noDeepcopy:
- return self.__class__()
- else:
- copy.deepcopy(self, memo, ignore__deepcopy__=True)
Or, else: return NotImplemented
so that’s what this is for:
- def __deepcopy__(self, memo):
- if self._noDeepcopy:
- return self.__class__()
- else:
- common.defaultDeepcopy(obj, memo)
looks through both __slots__ and __dict__ and does a deepcopy of anything in each of them and returns the new object.
If callInit is False, then only __new__() is called. This is much faster if you’re just going to overload every instance variable.
-
music21.common.misc.
getMissingImportStr
(modNameList)¶ Given a list of missing module names, returns a nicely-formatted message to the user that gives instructions on how to expand music21 with optional packages.
>>> print(common.getMissingImportStr(['matplotlib'])) Certain music21 functions might need the optional package matplotlib; if you run into errors, install it by following the instructions at http://mit.edu/music21/doc/installing/installAdditional.html
>>> print(common.getMissingImportStr(['matplotlib', 'numpy'])) Certain music21 functions might need these optional packages: matplotlib, numpy; if you run into errors, install them by following the instructions at http://mit.edu/music21/doc/installing/installAdditional.html
-
music21.common.misc.
getPlatform
()¶ Return the name of the platform, where platforms are divided between ‘win’ (for Windows), ‘darwin’ (for MacOS X), and ‘nix’ for (GNU/Linux and other variants).
Return type: str
-
music21.common.misc.
pitchList
(pitchL)¶ utility method that replicates the previous behavior of lists of pitches
-
music21.common.misc.
runningUnderIPython
()¶ return bool if we are running under iPython Notebook (not iPython)
(no tests, since will be different)
This post: http://stackoverflow.com/questions/15411967/
how-can-i-check-if-code-is-executed-in-the-ipython-notebooksays not to do this, but really, I can’t think of another way to have different output as default.
Return type: bool
-
music21.common.misc.
sortModules
(moduleList)¶ Sort a lost of imported module names such that most recently modified is first. In ties, last accesstime is used then module name
Will return a different order each time depending on the last mod time
Return type: list(str)