From bd8b9d29bfc66a73bc8f2a55bfda1ba638534498 Mon Sep 17 00:00:00 2001 From: Jordan Smith Date: Mon, 18 Nov 2019 23:36:46 +0000 Subject: [PATCH 1/5] Added seaborn to requirements.txt, removed conda from test and use virtualenv instead --- requirements.txt | 1 + scripts/test_tutorial_install.py | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/requirements.txt b/requirements.txt index 25df434..87e78d3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,3 +5,4 @@ sphinx numpydoc flake8 pytest +seaborn diff --git a/scripts/test_tutorial_install.py b/scripts/test_tutorial_install.py index e91be5e..93d2487 100644 --- a/scripts/test_tutorial_install.py +++ b/scripts/test_tutorial_install.py @@ -20,12 +20,12 @@ success_flag = False print("Failure! %s failed" % command) -# Check conda because its magic setup does not let us just run it. -if not os.environ['CONDA_EXE'] or not os.environ['CONDA_PYTHON_EXE']: - print('Install check failed! Conda is not installed correctly!') - success_flag = False -else: - print('Conda installed and set in environment.') +# # Check conda because its magic setup does not let us just run it. +# if not os.environ['CONDA_EXE'] or not os.environ['CONDA_PYTHON_EXE']: +# print('Install check failed! Conda is not installed correctly!') +# success_flag = False +# else: +# print('Conda installed and set in environment.') # Final results if success_flag is False: From bb6c151300a9b6401d29d9e40cf0a794d3f4a328 Mon Sep 17 00:00:00 2001 From: Jordan Smith Date: Wed, 20 Nov 2019 00:07:50 +0000 Subject: [PATCH 2/5] Fixed tests, uncommented hz_to_midi --- toymir/freq.py | 8 ++++---- toymir/tests/test_toymir.py | 18 ++++++++++++------ 2 files changed, 16 insertions(+), 10 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): diff --git a/toymir/tests/test_toymir.py b/toymir/tests/test_toymir.py index f1f72be..1723946 100644 --- a/toymir/tests/test_toymir.py +++ b/toymir/tests/test_toymir.py @@ -18,16 +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) +def test_hz_to_midi_throws_if_zero_or_less(): + # The test will pass if code inside the `with` block raises a ValueError! + with pytest.raises(ValueError): + toymir.hz_to_midi(0) + toymir.hz_to_midi(-1) + # Hello! You could add the missing test for test_hz_to_midi here! From eaf306abaa09a8c1a4f6757e3bbc98c718b8bd6d Mon Sep 17 00:00:00 2001 From: Jordan Smith Date: Wed, 20 Nov 2019 00:12:12 +0000 Subject: [PATCH 3/5] Added egg-info file to gitignore. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index d0cb1ae..2a83c1d 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ _build/ auto_examples/ gen_api/ .pytest_cache +toymir.egg-info/* \ No newline at end of file From 7edb618b89000fe763cd9a657e7c1c2d1a3e5c8d Mon Sep 17 00:00:00 2001 From: Jordan Smith Date: Fri, 29 Nov 2019 17:04:47 +0000 Subject: [PATCH 4/5] Uncommented flake8 line as prompted --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3a164f4..9269ba6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ 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/` + - 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 From c25d08b411e7309b98b51f89321c520c15987779 Mon Sep 17 00:00:00 2001 From: Jordan Smith Date: Fri, 29 Nov 2019 17:14:02 +0000 Subject: [PATCH 5/5] Removed tabs and unused seaborn import --- toymir/freq.py | 2 +- toymir/tests/test_toymir.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/toymir/freq.py b/toymir/freq.py index bd9ca27..07279fe 100644 --- a/toymir/freq.py +++ b/toymir/freq.py @@ -1,5 +1,5 @@ import numpy as np -import seaborn # trap to make tests fail! +# import seaborn # trap to make tests fail! def midi_to_hz(notes): diff --git a/toymir/tests/test_toymir.py b/toymir/tests/test_toymir.py index 1723946..e1b366b 100644 --- a/toymir/tests/test_toymir.py +++ b/toymir/tests/test_toymir.py @@ -24,8 +24,8 @@ def test_hz_to_midi_float(): def test_hz_to_midi_array(): - expected = [57, 69, 81] - assert np.allclose(toymir.hz_to_midi([220.0, 440.0, 880.0]), expected) + expected = [57, 69, 81] + assert np.allclose(toymir.hz_to_midi([220.0, 440.0, 880.0]), expected) def test_hz_to_midi_throws_if_zero_or_less():