diff --git a/.Rproj.user/8624DEA4/console06/INDEX001 b/.Rproj.user/8624DEA4/console06/INDEX001 new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/.Rproj.user/8624DEA4/console06/INDEX001 @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/.Rproj.user/8624DEA4/pcs/files-pane.pper b/.Rproj.user/8624DEA4/pcs/files-pane.pper new file mode 100644 index 0000000..35995a4 --- /dev/null +++ b/.Rproj.user/8624DEA4/pcs/files-pane.pper @@ -0,0 +1,9 @@ +{ + "path" : "~/Desktop/CSC 354/ismir2018-oss-tutorial", + "sortOrder" : [ + { + "ascending" : true, + "columnIndex" : 2 + } + ] +} \ No newline at end of file diff --git a/.Rproj.user/8624DEA4/pcs/source-pane.pper b/.Rproj.user/8624DEA4/pcs/source-pane.pper new file mode 100644 index 0000000..9efb51b --- /dev/null +++ b/.Rproj.user/8624DEA4/pcs/source-pane.pper @@ -0,0 +1,3 @@ +{ + "activeTab" : -1 +} \ No newline at end of file diff --git a/.Rproj.user/8624DEA4/pcs/windowlayoutstate.pper b/.Rproj.user/8624DEA4/pcs/windowlayoutstate.pper new file mode 100644 index 0000000..de91981 --- /dev/null +++ b/.Rproj.user/8624DEA4/pcs/windowlayoutstate.pper @@ -0,0 +1,14 @@ +{ + "left" : { + "panelheight" : 717, + "splitterpos" : 302, + "topwindowstate" : "HIDE", + "windowheight" : 755 + }, + "right" : { + "panelheight" : 717, + "splitterpos" : 453, + "topwindowstate" : "NORMAL", + "windowheight" : 755 + } +} \ No newline at end of file diff --git a/.Rproj.user/8624DEA4/pcs/workbench-pane.pper b/.Rproj.user/8624DEA4/pcs/workbench-pane.pper new file mode 100644 index 0000000..0e24b84 --- /dev/null +++ b/.Rproj.user/8624DEA4/pcs/workbench-pane.pper @@ -0,0 +1,6 @@ +{ + "TabSet1" : 0, + "TabSet2" : 0, + "TabZoom" : { + } +} \ No newline at end of file diff --git a/.Rproj.user/8624DEA4/rmd-outputs b/.Rproj.user/8624DEA4/rmd-outputs new file mode 100644 index 0000000..3f2ff2d --- /dev/null +++ b/.Rproj.user/8624DEA4/rmd-outputs @@ -0,0 +1,5 @@ + + + + + diff --git a/.Rproj.user/8624DEA4/saved_source_markers b/.Rproj.user/8624DEA4/saved_source_markers new file mode 100644 index 0000000..2b1bef1 --- /dev/null +++ b/.Rproj.user/8624DEA4/saved_source_markers @@ -0,0 +1 @@ +{"active_set":"","sets":[]} \ No newline at end of file diff --git a/.Rproj.user/shared/notebooks/patch-chunk-names b/.Rproj.user/shared/notebooks/patch-chunk-names new file mode 100644 index 0000000..e69de29 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/doc/#conf.py# b/doc/#conf.py# new file mode 100755 index 0000000..c8d900c --- /dev/null +++ b/doc/#conf.py# @@ -0,0 +1,302 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# toymir documentation build configuration file, created by +# sphinx-quickstart on Tue Apr 14 10:29:06 2015. +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys +import os +from unittest.mock import MagicMock + + +# General information about the project. +project = 'toymir' +copyright = '2015, Ariel Rokem, 2018, Thor Kell and Brian McFee' + +currentdir = os.path.abspath(os.path.dirname(__file__)) +ver_file = os.path.join(currentdir, '..', project, 'version.py') +with open(ver_file) as f: + exec(f.read()) +source_version = __version__ + +currentdir = os.path.abspath(os.path.dirname(__file__)) +sys.path.append(os.path.join(currentdir, 'tools')) + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +sys.path.insert(0, os.path.abspath('../')) + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +needs_sphinx = '1.0' # numpydoc requires sphinc >= 1.0 + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +sys.path.append(os.path.abspath('sphinxext')) + +extensions = ['sphinx.ext.autodoc', + 'sphinx.ext.doctest', + 'sphinx.ext.intersphinx', + 'sphinx.ext.todo', + 'sphinx.ext.coverage', + 'sphinx.ext.ifconfig', + 'sphinx.ext.autosummary', + 'sphinx.ext.mathjax', + 'math_dollar', # has to go before numpydoc + 'numpydoc', + 'github'] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The encoding of source files. +# source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# Automatically generate stub pages for API +autosummary_generate = True +autodoc_default_flags = ['members', 'inherited-members'] + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = '0.1' +# The full version, including alpha/beta/rc tags. +release = '0.1' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +#language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ['_build'] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +#keep_warnings = False + + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = 'alabaster' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = '_static/logo.png' + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# Add any extra paths that contain custom files (such as robots.txt or +# .htaccess) here, relative to this directory. These files are copied +# directly to the root of the documentation. +#html_extra_path = [] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +#html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +html_sidebars = {'**': ['localtoc.html', 'searchbox.html']} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_domain_indices = True +html_domain_indices = False + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +#html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +#html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = None + +# Output file base name for HTML help builder. +htmlhelp_basename = 'toymirdoc' + + +# -- Options for LaTeX output --------------------------------------------- + +latex_elements = { +# The paper size ('letterpaper' or 'a4paper'). +#'papersize': 'letterpaper', + +# The font size ('10pt', '11pt' or '12pt'). +#'pointsize': '10pt', + +# Additional stuff for the LaTeX preamble. +#'preamble': '', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + ('index', 'toymir.tex', 'toymir Documentation', + 'Brian McFee and Thor Kell', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# If true, show page references after internal links. +#latex_show_pagerefs = False + +# If true, show URL addresses after external links. +#latex_show_urls = False + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_domain_indices = True + + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ('index', 'toymir', 'toymir Documentation', + ['Ariel Rokem'], 1) +] + +# If true, show URL addresses after external links. +#man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ('index', 'toymir', 'toymir Documentation', + 'Ariel Rokem', 'toymir', 'One line description of project.', + 'Miscellaneous'), +] + +# Documents to append as an appendix to all manuals. +#texinfo_appendices = [] + +# If false, no module index is generated. +texinfo_domain_indices = False + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +#texinfo_show_urls = 'footnote' + +# If true, do not generate a @detailmenu in the "Top" node's menu. +#texinfo_no_detailmenu = False + +# Example configuration for intersphinx: refer to the Python standard library. +intersphinx_mapping = {'http://docs.python.org/': None} + + +class Mock(MagicMock): + @classmethod + def __getattr__(cls, name): + return MagicMock() + + +on_rtd = os.environ.get('READTHEDOCS', None) == 'True' +if on_rtd: + MOCK_MODULES = ['numpy'] + sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES) diff --git a/doc/conf.py b/doc/conf.py index c8d900c..d3ce530 100755 --- a/doc/conf.py +++ b/doc/conf.py @@ -15,7 +15,7 @@ import sys import os -from unittest.mock import MagicMock +from mock import MagicMock # General information about the project. 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/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..666cb13 100644 --- a/toymir/freq.py +++ b/toymir/freq.py @@ -1,9 +1,26 @@ import numpy as np -import seaborn # trap to make tests fail! def midi_to_hz(notes): """Hello Part 6! You should add documentation to this function. + Parameters + ---------- + notes : 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(100) + + 78741067093.3 + + >>> hz_to_midi([110, 220, 440]) + array([ 8.0630853e+13, 1.0466483e+47, 1.763599e+113]) """ return 440.0 * (2.0 ** ((np.asanyarray(notes) - 69.0) / 12.0)) @@ -38,12 +55,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..a931484 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_midi_throws_if_zero_or_less(): + # This is a bit magic-looking, but all it is saying is that + # the test will pass if code inside the `with` block raises a ValueError! + with pytest.raises(Exception): + toymir.hz_to_period(0) def test_hz_to_period_float(): expected = 0.1