Skip to content
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

Bug in the harmony module #63

Closed
eidanch opened this issue Jul 14, 2014 · 1 comment
Closed

Bug in the harmony module #63

eidanch opened this issue Jul 14, 2014 · 1 comment

Comments

@eidanch
Copy link

eidanch commented Jul 14, 2014

The following code:

>>> y = harmony.ChordSymbol('F')
>>> y.key = key.Key('C')
>>> y.romanNumeral

Produces the following TypeError:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Eidan\Anaconda\lib\site-packages\music21\harmony.py", line 373, in fget
    self._roman = roman.romanNumeralFromChord(self)
  File "C:\Users\Eidan\Anaconda\lib\site-packages\music21\roman.py", line 622, in romanNumeralFromChord
    chordObjSemiclosed = chordObj.semiClosedPosition(inPlace=False)
  File "C:\Users\Eidan\Anaconda\lib\site-packages\music21\chord.py", line 2822, in semiClosedPosition
    c2 = self.closedPosition(forceOctave, inPlace, leaveRedundantPitches)
  File "C:\Users\Eidan\Anaconda\lib\site-packages\music21\chord.py", line 920, in closedPosition
    returnObj = copy.deepcopy(self)
  File "C:\Users\Eidan\Anaconda\lib\copy.py", line 174, in deepcopy
    y = copier(memo)
  File "C:\Users\Eidan\Anaconda\lib\site-packages\music21\chord.py", line 277, in __deepcopy__
    new = note.NotRest.__deepcopy__(self, memo=memo)
  File "C:\Users\Eidan\Anaconda\lib\site-packages\music21\note.py", line 599, in __deepcopy__
    new = GeneralNote.__deepcopy__(self, memo=memo)
  File "C:\Users\Eidan\Anaconda\lib\site-packages\music21\base.py", line 1679, in __deepcopy__
    newValue = copy.deepcopy(part, memo)
  File "C:\Users\Eidan\Anaconda\lib\copy.py", line 190, in deepcopy
    y = _reconstruct(x, rv, 1, memo)
  File "C:\Users\Eidan\Anaconda\lib\copy.py", line 334, in _reconstruct
    state = deepcopy(state, memo)
  File "C:\Users\Eidan\Anaconda\lib\copy.py", line 163, in deepcopy
    y = copier(x, memo)
  File "C:\Users\Eidan\Anaconda\lib\copy.py", line 257, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "C:\Users\Eidan\Anaconda\lib\copy.py", line 190, in deepcopy
    y = _reconstruct(x, rv, 1, memo)
  File "C:\Users\Eidan\Anaconda\lib\copy.py", line 334, in _reconstruct
    state = deepcopy(state, memo)
  File "C:\Users\Eidan\Anaconda\lib\copy.py", line 163, in deepcopy
    y = copier(x, memo)
  File "C:\Users\Eidan\Anaconda\lib\copy.py", line 257, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "C:\Users\Eidan\Anaconda\lib\copy.py", line 190, in deepcopy
    y = _reconstruct(x, rv, 1, memo)
  File "C:\Users\Eidan\Anaconda\lib\copy.py", line 334, in _reconstruct
    state = deepcopy(state, memo)
  File "C:\Users\Eidan\Anaconda\lib\copy.py", line 163, in deepcopy
    y = copier(x, memo)
  File "C:\Users\Eidan\Anaconda\lib\copy.py", line 257, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "C:\Users\Eidan\Anaconda\lib\copy.py", line 163, in deepcopy
    y = copier(x, memo)
  File "C:\Users\Eidan\Anaconda\lib\copy.py", line 257, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "C:\Users\Eidan\Anaconda\lib\copy.py", line 190, in deepcopy
    y = _reconstruct(x, rv, 1, memo)
  File "C:\Users\Eidan\Anaconda\lib\copy.py", line 329, in _reconstruct
    y = callable(*args)
  File "C:\Users\Eidan\Anaconda\lib\copy_reg.py", line 93, in __newobj__
    return cls.__new__(cls, *args)
TypeError: object.__new__(NotImplementedType) is not safe, use NotImplementedType.__new__()
@mscuthbert
Copy link
Member

Still needs a bit more testing, but a patch is in. change

    @key.setter
    def key(self, keyOrScale):
        if common.isStr(keyOrScale):
            self._key = key.Key(keyOrScale)
        else:
            self._key = key

to

    @key.setter
    def key(self, keyOrScale):
        if common.isStr(keyOrScale):
            self._key = key.Key(keyOrScale)
        else:
            self._key = keyOrScale
            self._roman = None

or upgrade to latest SVN.

Apparently the error comes from trying to deepcopy the key, MODULE object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants