From 03c0c7a7a646e0347b317cd22249b255bf3238b7 Mon Sep 17 00:00:00 2001 From: Corinne Moriarty Date: Sun, 24 Feb 2019 20:20:10 -0500 Subject: [PATCH 1/3] Add seaborn to requirements.txt --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 25df434..95362fd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,3 +5,4 @@ sphinx numpydoc flake8 pytest +seaborn \ No newline at end of file From 9e2f19682b598f22facbf2b706f944d30a1b3afd Mon Sep 17 00:00:00 2001 From: Corinne Moriarty Date: Wed, 27 Feb 2019 23:08:37 -0500 Subject: [PATCH 2/3] Update toymir/freq.py --- toymir/freq.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/toymir/freq.py b/toymir/freq.py index 311890f..bd9ca27 100644 --- a/toymir/freq.py +++ b/toymir/freq.py @@ -38,12 +38,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): From 6cf45ab17c25c0540e1ff1d27ceb108b105b50a0 Mon Sep 17 00:00:00 2001 From: Corinne Moriarty Date: Wed, 27 Feb 2019 23:10:33 -0500 Subject: [PATCH 3/3] Add test to updated toymir functions --- toymir/tests/test_toymir.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/toymir/tests/test_toymir.py b/toymir/tests/test_toymir.py index f1f72be..5dd86bd 100644 --- a/toymir/tests/test_toymir.py +++ b/toymir/tests/test_toymir.py @@ -18,18 +18,22 @@ 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! +def test_hz_to_period_zero(): + expected = ValueError + assert toymir.hz_to_midi(0) == expected + def test_hz_to_period_float(): expected = 0.1