Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
676d0cd
Add seaborn to requirements.txt
lcarpenter20 May 28, 2019
89c7db0
Merge pull request #1 from lcarpenter20/update-conda-env
lcarpenter20 May 28, 2019
1fd5b8c
Changed second import in toymir/__init__.py to from . import freq
lcarpenter20 May 28, 2019
e1ec6ca
Merge pull request #2 from lcarpenter20/update-conda-env
lcarpenter20 May 28, 2019
53eeb6b
Uncommented two functions that start with test_hz_to_midi
lcarpenter20 May 28, 2019
3ad64bb
Merge pull request #3 from lcarpenter20/fix-failing-test
lcarpenter20 May 28, 2019
c6856d0
Uncommented code
lcarpenter20 May 28, 2019
6072eb9
Merge pull request #4 from lcarpenter20/fix-failing-test
lcarpenter20 May 28, 2019
2701bff
Indented line that throws an exception
lcarpenter20 May 28, 2019
8434cf4
Merge pull request #5 from lcarpenter20/fix-failing-test
lcarpenter20 May 28, 2019
3f7d7a4
Unindented a line that was uncommented
lcarpenter20 May 28, 2019
296167f
Merge pull request #6 from lcarpenter20/fix-failing-test
lcarpenter20 May 28, 2019
f856e74
Changed second import back to from .freq import *
lcarpenter20 May 28, 2019
8cd6e5a
Merge pull request #7 from lcarpenter20/fix-failing-test
lcarpenter20 May 28, 2019
2cb85fe
Uncommented
lcarpenter20 May 28, 2019
25545ef
Merge pull request #8 from lcarpenter20/fix-failing-test
lcarpenter20 May 28, 2019
9becfb9
Uncommented
lcarpenter20 May 28, 2019
c0560c2
Merge pull request #9 from lcarpenter20/fix-failing-test
lcarpenter20 May 28, 2019
4f53312
Uncommented the flake8 line above the call to pytest
lcarpenter20 May 28, 2019
4bbc5bb
Merge pull request #10 from lcarpenter20/add-flake8
lcarpenter20 May 28, 2019
0dd34e1
Deleted the unused import, seaborn
lcarpenter20 May 29, 2019
00b7865
Merge pull request #11 from lcarpenter20/add-flake8
lcarpenter20 May 29, 2019
e11ebfd
Trying to see if Travis works
lcarpenter20 May 29, 2019
53e29a7
Merge pull request #12 from lcarpenter20/add-flake8
lcarpenter20 May 29, 2019
cec02fb
Uncommented two lines of code
lcarpenter20 May 29, 2019
e978e48
Commented unused import, seaborn
lcarpenter20 May 29, 2019
a5dfaa9
Commented out a line in travis.yml
lcarpenter20 May 29, 2019
21320e5
Merge pull request #13 from lcarpenter20/add-flake8
lcarpenter20 May 29, 2019
fb570df
Corrected the errors
lcarpenter20 May 29, 2019
7c8a1ab
Addded documentation to midi_to_hz function
lcarpenter20 May 29, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ install:
- travis_retry pip install -e .

script:
# - flake8 --ignore N802,N806,E501 `find . -name \*.py | grep -v setup.py | grep -v version.py | grep -v __init__.py | grep -v /doc/`
# - pytest --pyargs toymir --cov-report term-missing --cov=toymir
- pytest
- flake8 --ignore N802,N806,E501 `find . -name \*.py | grep -v setup.py | grep -v version.py | grep -v __init__.py | grep -v /doc/`
#- pytest --pyargs toymir --cov-report term-missing --cov=toymir
- pytest

# Hey, this block (and the above arguments to pytest )
# are important if you care about test coverage.
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ sphinx
numpydoc
flake8
pytest
seaborn
2 changes: 1 addition & 1 deletion toymir/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# When you import from .MODULE, that means look within the current package
# instead of going out to the installed packages
from .version import __version__ # noqa
from .freq import * # noqa
from .freq import * # noqa
28 changes: 22 additions & 6 deletions toymir/freq.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
import numpy as np
import seaborn # trap to make tests fail!
# import seaborn trap to make tests fail!


def midi_to_hz(notes):
"""Hello Part 6! You should add documentation to this function.
"""Get frequencies (Hz) of MIDI

Parameters
----------
notes : number or np.ndarray [shape=(n,), dtype=float]
note numbers to convert

Returns
-------

frequences : float or np.ndarray [shape=(n,), dtype=float]
frequences to convert

Examples
--------
>>> midi_to_hz(120)
8372.01
"""

return 440.0 * (2.0 ** ((np.asanyarray(notes) - 69.0) / 12.0))
Expand Down Expand Up @@ -38,12 +54,12 @@ def hz_to_midi(frequencies):
# Oh hey, it's Part 5! You could uncomment this implementation,
# and then the tests will pass!

# less_than_zero = (np.asanyarray(frequencies) <= 0).any()
less_than_zero = (np.asanyarray(frequencies) <= 0).any()

# if less_than_zero:
# raise ValueError('Cannot convert a hz of zero or less to a period.')
if less_than_zero:
raise ValueError('Cannot convert a hz of zero or less to a period.')

# return 12 * (np.log2(np.asanyarray(frequencies)) - np.log2(440.0)) + 69
return 12 * (np.log2(np.asanyarray(frequencies)) - np.log2(440.0)) + 69


def hz_to_period(frequencies):
Expand Down
14 changes: 7 additions & 7 deletions toymir/tests/test_toymir.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ def test_midi_to_hz_array():
# These are the two tests you should uncomment!


# def test_hz_to_midi_float():
# expected = 69
# assert toymir.hz_to_midi(440.0) == expected
def test_hz_to_midi_float():
expected = 69
assert toymir.hz_to_midi(440.0) == expected


# def test_hz_to_midi_array():
# expected = [57, 69, 81]
# assert np.allclose(toymir.hz_to_midi([220.0, 440.0, 880.0]), expected)
def test_hz_to_midi_array():
expected = [57, 69, 81]
assert np.allclose(toymir.hz_to_midi([220.0, 440.0, 880.0]), expected)


# Hello! You could add the missing test for test_hz_to_midi here!
# Hello! You could add the missing test for test_hz_to_midi here!


def test_hz_to_period_float():
Expand Down