Skip to content

Commit

Permalink
Merge pull request #5 from groupmm/unit_tests
Browse files Browse the repository at this point in the history
add unit_tests and set workflows
  • Loading branch information
yiitozer authored Mar 12, 2024
2 parents f353ce7 + db66e7e commit de7fdda
Show file tree
Hide file tree
Showing 51 changed files with 272 additions and 112 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/test_conda.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Python Package using Conda

on:
push:
branches:
- unit_tests
pull_request:
branches:
- unit_tests
jobs:
build-linux:
runs-on: ubuntu-latest
strategy:
max-parallel: 5

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.11
uses: actions/setup-python@v2
with:
python-version: 3.11
- name: Add conda to system path
run: |
# $CONDA is an environment variable pointing to the root of the miniconda directory
echo $CONDA/bin >> $GITHUB_PATH
- name: Install dependencies
run: |
conda install -c conda-forge libsndfile python=3.11
python -m pip install -e .['tests']
- name: Lint with flake8
run: |
conda install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
55 changes: 55 additions & 0 deletions .github/workflows/test_pip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python package

on:
push:
branches:
- main
- unit_tests
pull_request:
branches:
- main
- unit_tests

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version:
- 3.8
- 3.9
- '3.10'
- 3.11

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install libnsdfile
run: |
sudo apt update
sudo apt install libsndfile1-dev libsndfile1
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8
python -m pip install -e .['tests']
python --version
pip --version
python -m pip list
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
[![Python package using Conda](https://github.com/groupmm/libsoni/actions/workflows/test_conda.yml/badge.svg)](https://github.com/groupmm/libsoni/actions/workflows/test_conda.yml)
[![Python package using pip](https://github.com/groupmm/libsoni/actions/workflows/test_pip.yml/badge.svg)](https://github.com/groupmm/libsoni/actions/workflows/test_pip.yml)


<table border="0">
<tr>
<td><img src="docs/source/_static/libsoni_logo.png" alt="libsoni logo" width="1000"></td>
<td><img src=https://github.com/groupmm/libsoni/blob/unit_tests/docs/build/html/_static/libsoni_logo.png alt="libsoni logo" width="1000"></td>
<td><h2>libsoni: A Python Toolbox for Sonifying Music Annotations and Feature Representations</h2>
<br> <br>
</td>
Expand Down
Binary file modified docs/build/doctrees/core/pianoroll.doctree
Binary file not shown.
Binary file modified docs/build/doctrees/environment.pickle
Binary file not shown.
4 changes: 3 additions & 1 deletion docs/build/html/_modules/libsoni/core/methods.html
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,9 @@ <h1>Source code for libsoni.core.methods</h1><div class="highlight"><pre>
<span class="k">assert</span> <span class="mi">0</span> <span class="o">&lt;=</span> <span class="n">pitch</span> <span class="o">&lt;=</span> <span class="mi">127</span><span class="p">,</span> <span class="sa">f</span><span class="s1">&#39;Pitch is out of range [0,127].&#39;</span>

<span class="n">pitch_frequency</span> <span class="o">=</span> <span class="n">pitch_to_frequency</span><span class="p">(</span><span class="n">pitch</span><span class="o">=</span><span class="n">pitch</span><span class="p">,</span> <span class="n">tuning_frequency</span><span class="o">=</span><span class="n">tuning_frequency</span><span class="p">)</span>
<span class="n">generated_tone</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">sin</span><span class="p">(</span><span class="mi">2</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">pi</span> <span class="o">*</span> <span class="n">pitch_frequency</span> <span class="o">*</span> <span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="n">duration</span> <span class="o">*</span> <span class="n">fs</span><span class="p">)))</span> <span class="o">/</span> <span class="n">fs</span> <span class="o">+</span> <span class="n">modulation_amplitude</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">sin</span><span class="p">(</span><span class="mi">2</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">pi</span> <span class="o">*</span> <span class="n">pitch_frequency</span> <span class="o">*</span> <span class="n">modulation_rate_relative</span> <span class="o">*</span> <span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="n">duration</span> <span class="o">*</span> <span class="n">fs</span><span class="p">)))))</span>
<span class="n">generated_tone</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">sin</span><span class="p">(</span><span class="mi">2</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">pi</span> <span class="o">*</span> <span class="n">pitch_frequency</span> <span class="o">*</span> <span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="n">duration</span> <span class="o">*</span> <span class="n">fs</span><span class="p">)))</span> <span class="o">/</span> <span class="n">fs</span> <span class="o">+</span>
<span class="n">modulation_amplitude</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">sin</span><span class="p">(</span><span class="mi">2</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">pi</span> <span class="o">*</span> <span class="n">pitch_frequency</span> <span class="o">*</span> <span class="n">modulation_rate_relative</span> <span class="o">*</span>
<span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="n">duration</span> <span class="o">*</span> <span class="n">fs</span><span class="p">)))))</span>
<span class="n">generated_tone</span> <span class="o">=</span> <span class="n">gain</span> <span class="o">*</span> <span class="n">fade_signal</span><span class="p">(</span><span class="n">signal</span><span class="o">=</span><span class="n">generated_tone</span><span class="p">,</span> <span class="n">fs</span><span class="o">=</span><span class="n">fs</span><span class="p">,</span> <span class="n">fading_duration</span><span class="o">=</span><span class="n">fading_duration</span><span class="p">)</span>

<span class="k">return</span> <span class="n">generated_tone</span></div>
Expand Down
Loading

0 comments on commit de7fdda

Please sign in to comment.