melody.freq_to_voicing returns single boolean if not a numpy array
Closed this issue · 3 comments
melody.freq_to_voicing
is meant to take a numpy array. I accidentally discovered that if you instead give it a list of floats instead of a numpy array, it returns True
, rather than an array of booleans.
>>> np.array([440.0, 0.0, 0.0]) > 0
[True, False, False]
>>> [440.0, 0.0, 0.0] > 0
True
I definitely just used the function wrong, but it is a bit of a sinister error. I don't have any ideas for an ideal solution... maybe the function could first check that frequencies
is indeed a numpy array and throw a ValueError
if not? Any ideas? Happy to make a PR.
This arguably falls within the scope of #143. In general, at the moment, we don't make an effort to type-check arguments, with the policy that if the docstring asks for, say, an np.ndarray
and the user provides a list
, they are on their own. This isn't the best policy, but if we are going to fix it we should fix it everywhere... and I'm guessing you don't want to make a PR for that right now :)
Fair enough. In that case I will hold off ;).