Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flake8 #67

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
11 changes: 6 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
language: python
sudo: false
sudo: true

env:
global:
- PIP_DEPS="pytest coveralls pytest-cov flake8"

python:
- '3.5'
- '3.6'
# - '3.5'
# - '3.6'
- '3.7'


install:
Expand All @@ -16,8 +17,8 @@ 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
- 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 )
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
31 changes: 31 additions & 0 deletions toymir.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -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: [email protected]
Maintainer: Brian McFee
Maintainer-email: [email protected]
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
14 changes: 14 additions & 0 deletions toymir.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions toymir.egg-info/dependency_links.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions toymir.egg-info/requires.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
numpy
1 change: 1 addition & 0 deletions toymir.egg-info/top_level.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
toymir
9 changes: 4 additions & 5 deletions toymir/freq.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import numpy as np
import seaborn # trap to make tests fail!


def midi_to_hz(notes):
Expand Down Expand Up @@ -38,12 +37,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
12 changes: 6 additions & 6 deletions toymir/tests/test_toymir.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down