From 09f4913906432568d9706b5a36adbcfa3625fbbd Mon Sep 17 00:00:00 2001 From: Zhenyao Cai Date: Mon, 4 Feb 2019 09:00:36 -0500 Subject: [PATCH 1/4] 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 7571df5254e4e410bd0688b0c2971e340cfdae63 Mon Sep 17 00:00:00 2001 From: Zhenyao Cai Date: Mon, 4 Feb 2019 18:05:41 -0500 Subject: [PATCH 2/4] Fixing bugs --- toymir/freq.py | 8 ++++---- toymir/tests/test_toymir.py | 12 ++++++------ 2 files changed, 10 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..6e94bd3 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 38da0fcf9e69ddb495791e850be9e5e0d1930eed Mon Sep 17 00:00:00 2001 From: Zhenyao Cai Date: Mon, 4 Feb 2019 18:25:51 -0500 Subject: [PATCH 3/4] Add flake8 --- .travis.yml | 2 +- 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 + 6 files changed, 49 insertions(+), 1 deletion(-) 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/.travis.yml b/.travis.yml index 3a164f4..8185273 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 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 From 28d47411111d272573f00bab0a82867e32b71ac8 Mon Sep 17 00:00:00 2001 From: Zhenyao Cai Date: Tue, 5 Feb 2019 09:47:52 -0500 Subject: [PATCH 4/4] Update docs --- toymir/freq.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/toymir/freq.py b/toymir/freq.py index bd9ca27..9748cf7 100644 --- a/toymir/freq.py +++ b/toymir/freq.py @@ -3,7 +3,29 @@ def midi_to_hz(notes): - """Hello Part 6! You should add documentation to this function. + """Get frequencies for given MIDI note number(s) + + Parameters + ---------- + note_nums : number or np.ndarray [shape=(n,), dtype=float] + MIDI notes to `frequencies + + Returns + ------- + frequencies : float or np.ndarray [shape=(n,), dtype=float] + frequencies to convert + + Examples + -------- + >>> midi_to_hz(20) + 25.956 + >>> midi_to_hz([10, 20, 40]) + array([14.56761755, 25.9565436 , 82.40688923]) + + See Also + -------- + hz_to_midi + hz_to_period """ return 440.0 * (2.0 ** ((np.asanyarray(notes) - 69.0) / 12.0))