ttm / music

music is a python package for making sounds and music
MIT License
52 stars 9 forks source link

TypeError fix for compatibility with numpy #9

Closed TranscriptionFactory closed 2 years ago

TranscriptionFactory commented 3 years ago

Issue: functions.py import generates TypeError when calling numpy.linspace():

Traceback: Line 275 in functions.py generates:

    File "~/anaconda3/lib/python3.7/site-packages/music/core/functions.py", line 275, in <module>
        foo = n.linspace(-1, 1, Lt/2, endpoint=False)

    File "<__array_function__ internals>", line 6, in linspace

    File "~/anaconda3/lib/python3.7/site-packages/numpy/core/function_base.py", line 121, in linspace
        .format(type(num)))

TypeError: object of type <class 'float'> cannot be safely interpreted as an integer.

Fix: Correctly casted variable: Lt as int(): (Lt/2) -> int(Lt/2) from (original): foo = n.linspace(-1, 1, Lt/2, endpoint=False) to: foo = n.linspace(-1, 1, int(Lt/2), endpoint=False) in function: W_ (line 275) in location: music/core/functions.py

ttm commented 2 years ago

thank you for solving this issue. In fact, it was solved locally and now on this repo and PyPI. Any reason why we should avoid Lt//2 and use int(Lt/2)?