From 8cd18a7a92f089a6495959d78671928c40c5bbc4 Mon Sep 17 00:00:00 2001 From: Wenqin Date: Tue, 5 Feb 2019 10:41:23 -0500 Subject: [PATCH 1/8] Add seaborn to requirements.txt --- requirements.txt | 1 + 1 file changed, 1 insertion(+) 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 From f81d423ceb582c9802aa7c1df79553319b23f29b Mon Sep 17 00:00:00 2001 From: Wenqin Date: Tue, 5 Feb 2019 11:35:54 -0500 Subject: [PATCH 2/8] fix broken tests --- toymir.egg-info/PKG-INFO | 31 ++++++++++++++++++++++++++++ toymir.egg-info/SOURCES.txt | 14 +++++++++++++ toymir.egg-info/dependency_links.txt | 1 + toymir.egg-info/requires.txt | 1 + toymir.egg-info/top_level.txt | 1 + toymir/freq.py | 8 +++---- toymir/tests/test_toymir.py | 12 +++++------ 7 files changed, 58 insertions(+), 10 deletions(-) create mode 100644 toymir.egg-info/PKG-INFO create mode 100644 toymir.egg-info/SOURCES.txt create mode 100644 toymir.egg-info/dependency_links.txt create mode 100644 toymir.egg-info/requires.txt create mode 100644 toymir.egg-info/top_level.txt diff --git a/toymir.egg-info/PKG-INFO b/toymir.egg-info/PKG-INFO new file mode 100644 index 0000000..7b7752c --- /dev/null +++ b/toymir.egg-info/PKG-INFO @@ -0,0 +1,31 @@ +Metadata-Version: 1.2 +Name: toymir +Version: 0.1.dev0 +Summary: toymir: a toy package for learning about OSS in MIR +Home-page: http://github.com/bmcfee/ismir2018-oss-tutorial +Author: Brian McFee +Author-email: brian.mcfee@nyu.edu +Maintainer: Brian McFee +Maintainer-email: brian.mcfee@nyu.edu +License: MIT +Description: + + toymir + ======== + toymir is a small Python package for use in the ISMIR 2018 tutorial on + open source software and reproducibility. + + It is based on the Shablona_ package, developed by Ariel Rokem at the + University of Washington eScience Institute. + + .. _Shablona: https://github.com/uwescience/shablona + +Platform: OS Independent +Classifier: Development Status :: 3 - Alpha +Classifier: Environment :: Console +Classifier: Intended Audience :: Science/Research +Classifier: License :: OSI Approved :: MIT License +Classifier: Operating System :: OS Independent +Classifier: Programming Language :: Python +Classifier: Topic :: Scientific/Engineering +Requires: numpy diff --git a/toymir.egg-info/SOURCES.txt b/toymir.egg-info/SOURCES.txt new file mode 100644 index 0000000..5a30789 --- /dev/null +++ b/toymir.egg-info/SOURCES.txt @@ -0,0 +1,14 @@ +README.md +setup.py +toymir/__init__.py +toymir/freq.py +toymir/version.py +toymir.egg-info/PKG-INFO +toymir.egg-info/SOURCES.txt +toymir.egg-info/dependency_links.txt +toymir.egg-info/requires.txt +toymir.egg-info/top_level.txt +toymir/data/ortho.csv +toymir/data/para.csv +toymir/tests/__init__.py +toymir/tests/test_toymir.py \ No newline at end of file diff --git a/toymir.egg-info/dependency_links.txt b/toymir.egg-info/dependency_links.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/toymir.egg-info/dependency_links.txt @@ -0,0 +1 @@ + diff --git a/toymir.egg-info/requires.txt b/toymir.egg-info/requires.txt new file mode 100644 index 0000000..24ce15a --- /dev/null +++ b/toymir.egg-info/requires.txt @@ -0,0 +1 @@ +numpy diff --git a/toymir.egg-info/top_level.txt b/toymir.egg-info/top_level.txt new file mode 100644 index 0000000..17abe18 --- /dev/null +++ b/toymir.egg-info/top_level.txt @@ -0,0 +1 @@ +toymir 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..ca61f9b 100644 --- a/toymir/tests/test_toymir.py +++ b/toymir/tests/test_toymir.py @@ -18,14 +18,14 @@ 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! From b0e82170df0ffe10654d26a9763dc5e008b1f10c Mon Sep 17 00:00:00 2001 From: Wenqin Date: Thu, 7 Feb 2019 12:52:15 -0500 Subject: [PATCH 3/8] add missing tests --- toymir/tests/test_toymir.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/toymir/tests/test_toymir.py b/toymir/tests/test_toymir.py index ca61f9b..6e40775 100644 --- a/toymir/tests/test_toymir.py +++ b/toymir/tests/test_toymir.py @@ -29,6 +29,9 @@ def test_hz_to_midi_array(): # Hello! You could add the missing test for test_hz_to_midi here! +def test_hz_to_midi_throws_if_zero_or_less(): + with pytest.raises(ValueError): + toymir.hz_to_midi(0) def test_hz_to_period_float(): From c650fdbf7015483ce3c1d57803d2412b2ffcca59 Mon Sep 17 00:00:00 2001 From: Wenqin Date: Thu, 7 Feb 2019 12:56:20 -0500 Subject: [PATCH 4/8] add flake 8 --- .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 99ecb1474a1db3af9268084447282c5f01bea7fb Mon Sep 17 00:00:00 2001 From: Wenqin Date: Thu, 7 Feb 2019 13:10:30 -0500 Subject: [PATCH 5/8] comment extra import to pass flake8 --- toymir/freq.py | 1 - 1 file changed, 1 deletion(-) diff --git a/toymir/freq.py b/toymir/freq.py index bd9ca27..aa4b4d5 100644 --- a/toymir/freq.py +++ b/toymir/freq.py @@ -1,5 +1,4 @@ import numpy as np -import seaborn # trap to make tests fail! def midi_to_hz(notes): From 2297483f6d49f013850ab8b997a8801e38fcd400 Mon Sep 17 00:00:00 2001 From: WENQIN CHEN Date: Thu, 7 Feb 2019 13:22:28 -0500 Subject: [PATCH 6/8] test git config reset --- toymir/freq.py | 1 - 1 file changed, 1 deletion(-) diff --git a/toymir/freq.py b/toymir/freq.py index aa4b4d5..a83b89b 100644 --- a/toymir/freq.py +++ b/toymir/freq.py @@ -1,6 +1,5 @@ import numpy as np - def midi_to_hz(notes): """Hello Part 6! You should add documentation to this function. """ From 462157f184b99c6f33be78722c577383d2c2783a Mon Sep 17 00:00:00 2001 From: WENQIN CHEN Date: Thu, 7 Feb 2019 13:28:46 -0500 Subject: [PATCH 7/8] fix travis issue --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9269ba6..dbb14f8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,4 +24,4 @@ script: # are important if you care about test coverage. # That's outside the scope of this tutorial though! # after_success: -# - coveralls +# - coveralls \ No newline at end of file From c08c6009c3c21d88277cfd347497fb13bed0637a Mon Sep 17 00:00:00 2001 From: WENQIN CHEN Date: Fri, 8 Feb 2019 00:52:02 -0500 Subject: [PATCH 8/8] add some documentation --- toymir/freq.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/toymir/freq.py b/toymir/freq.py index a83b89b..49b5c48 100644 --- a/toymir/freq.py +++ b/toymir/freq.py @@ -1,7 +1,17 @@ import numpy as np def midi_to_hz(notes): - """Hello Part 6! You should add documentation to this function. + """Get frequencies for given MIDI note number(s) + + Parameters + ---------- + notes : number or np.ndarray [shape=(n,), dtype=float] + MIDI notes + + Returns + ------- + frequencies : float or np.ndarray [shape=(n,), dtype=float] + frequencies to convert """ return 440.0 * (2.0 ** ((np.asanyarray(notes) - 69.0) / 12.0))