diff --git a/.github/workflows/ut-analysis.yml b/.github/workflows/ut-analysis.yml new file mode 100644 index 00000000..5944756e --- /dev/null +++ b/.github/workflows/ut-analysis.yml @@ -0,0 +1,38 @@ +# 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: Analysis Unit Tests + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.7, 3.8] + + env: + working-directory: ./analysis-master/ + + 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 dependencies + run: | + python -m pip install --upgrade pip + pip install pytest + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + working-directory: ${{ env.working-directory }} + - name: Test with pytest + run: | + pytest + working-directory: ${{ env.working-directory }} \ No newline at end of file diff --git a/.github/workflows/ut-superscript.yml b/.github/workflows/ut-superscript.yml new file mode 100644 index 00000000..fcd2b69f --- /dev/null +++ b/.github/workflows/ut-superscript.yml @@ -0,0 +1,38 @@ +# 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: Superscript Unit Tests + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.7, 3.8] + + env: + working-directory: ./data-analysis/ + + 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 dependencies + run: | + python -m pip install --upgrade pip + pip install pytest + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + working-directory: ${{ env.working-directory }} + - name: Test with pytest + run: | + pytest + working-directory: ${{ env.working-directory }} diff --git a/.gitignore b/.gitignore index 44216d61..e6485438 100644 --- a/.gitignore +++ b/.gitignore @@ -25,4 +25,6 @@ data-analysis/__pycache__/ analysis-master/analysis.egg-info/ analysis-master/build/ analysis-master/metrics/ -data-analysis/config-pop.json \ No newline at end of file +data-analysis/config-pop.json +analysis-master/__pycache__/ +analysis-master/.pytest_cache/ \ No newline at end of file diff --git a/analysis-master/test_analysis.py b/analysis-master/test_analysis.py new file mode 100644 index 00000000..8310e2d7 --- /dev/null +++ b/analysis-master/test_analysis.py @@ -0,0 +1,17 @@ +from analysis import analysis as an + +def test_(): + test_data_linear = [1, 3, 6, 7, 9] + y_data_ccu = [1, 3, 7, 14, 21] + y_data_ccd = [1, 5, 7, 8.5, 8.66] + assert an.basic_stats(test_data_linear) == {"mean": 5.2, "median": 6.0, "standard-deviation": 2.85657137141714, "variance": 8.16, "minimum": 1.0, "maximum": 9.0} + assert an.z_score(3.2, 6, 1.5) == -1.8666666666666665 + assert an.z_normalize(test_data_linear).tolist() == [5.2, 6.0, 2.85657137141714, 8.16, 1.0, 9.0] + assert all(isinstance(item, str) for item in an.regression(test_data_linear, y_data_ccu, ["lin"])) == True + assert all(isinstance(item, str) for item in an.regression(test_data_linear, y_data_ccd, ["log"])) == True + assert all(isinstance(item, str) for item in an.regression(test_data_linear, y_data_ccu, ["exp"])) == True + assert all(isinstance(item, str) for item in an.regression(test_data_linear, y_data_ccu, ["ply"])) == True + assert all(isinstance(item, str) for item in an.regression(test_data_linear, y_data_ccd, ["sig"])) == True + assert an.Metric().elo(1500, 1500, [1, 0], 400, 24) == 1512.0 + assert an.Metric().glicko2(1500, 250, 0.06, [1500, 1400], [250, 240], [1, 0]) == (1478.864307445517, 195.99122679202452, 0.05999602937563585) + assert an.Metric().trueskill([[(25, 8.33), (24, 8.25), (32, 7.5)], [(25, 8.33), (25, 8.33), (21, 6.5)]], [1, 0]) == [(an.metrics.trueskill.Rating(mu=21.346, sigma=7.875), an.metrics.trueskill.Rating(mu=20.415, sigma=7.808), an.metrics.trueskill.Rating(mu=29.037, sigma=7.170)), (an.metrics.trueskill.Rating(mu=28.654, sigma=7.875), an.metrics.trueskill.Rating(mu=28.654, sigma=7.875), an.metrics.trueskill.Rating(mu=23.225, sigma=6.287))] \ No newline at end of file diff --git a/data-analysis/test_superscript.py b/data-analysis/test_superscript.py new file mode 100644 index 00000000..f6709195 --- /dev/null +++ b/data-analysis/test_superscript.py @@ -0,0 +1,2 @@ +def test_(): + assert 1 == 1 \ No newline at end of file