From 3c9bfb265d5cd928dd92c67d1466811014084a8d Mon Sep 17 00:00:00 2001 From: Miha Kralj Date: Fri, 6 Jan 2023 14:05:41 -0800 Subject: [PATCH] test_python --- .github/workflows/main_automation.yml | 6 ++++++ .github/workflows/requirements.txt | 6 ------ .github/workflows/test_Python.yml | 30 +++++++++------------------ Tests/Tests.csproj | 2 +- Tests/Validations/Trends/Pandas_TA.cs | 23 +++++++++++--------- Tests/Validations/Trends/Tulip.cs | 2 ++ Tests/requirements.txt | 6 ++++++ 7 files changed, 38 insertions(+), 37 deletions(-) delete mode 100644 .github/workflows/requirements.txt create mode 100644 Tests/requirements.txt diff --git a/.github/workflows/main_automation.yml b/.github/workflows/main_automation.yml index 464ceaa5..9829947f 100644 --- a/.github/workflows/main_automation.yml +++ b/.github/workflows/main_automation.yml @@ -1,6 +1,12 @@ name: Stage/build/test/release/publish on: workflow_dispatch: + push: + branches: + - '*' + pull_request: + branches: + - '*' jobs: build_test: diff --git a/.github/workflows/requirements.txt b/.github/workflows/requirements.txt deleted file mode 100644 index 21615798..00000000 --- a/.github/workflows/requirements.txt +++ /dev/null @@ -1,6 +0,0 @@ -pytz>=2022 -six>=1 -python-dateutil>=2 -numpy>=1.24 -pandas>=1.5 -pandas-ta>=0.3 \ No newline at end of file diff --git a/.github/workflows/test_Python.yml b/.github/workflows/test_Python.yml index 8b7b9d50..b761eb4d 100644 --- a/.github/workflows/test_Python.yml +++ b/.github/workflows/test_Python.yml @@ -22,31 +22,21 @@ jobs: with: dotnet-version: | 7.0.x - 5.0.x include-prerelease: true - name: Install Python - - uses: actions/setup-python@v4 + uses: actions/setup-python@v4 with: - python-version: '3.11' - check-latest: true + python-version: '3.10' + check-latest: false cache: 'pip' - cache-dependency-path: '**/requirements.txt' - - run: pip install -r worklflows/requirements.txt + cache-dependency-path: '\a\QuanTAlib\QuanTAlib\Tests\requirements.txt' + + - name: Install dependencies + run: pip install -r '\a\QuanTAlib\QuanTAlib\Tests\requirements.txt' + + - name: path + run: '$env:path -split ";"' - - name: Install JDK11 for Sonar Scanner - uses: actions/setup-java@v1 - with: - java-version: 1.11 - - name: Install GitVersion - run: dotnet tool install GitVersion.Tool --global - - name: Install JetBrains - run: dotnet tool install JetBrains.dotCover.GlobalTool --global - - name: Install Sonar Scanner - run: dotnet tool install dotnet-sonarscanner --global - - name: Install dotnet-coverage - run: dotnet tool install dotnet-coverage --global - - name: Install CodeCov - run: dotnet tool install --global Codecov.Tool diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj index b770660d..38bc8c2b 100644 --- a/Tests/Tests.csproj +++ b/Tests/Tests.csproj @@ -9,7 +9,7 @@ AnyCPU;x64 - + diff --git a/Tests/Validations/Trends/Pandas_TA.cs b/Tests/Validations/Trends/Pandas_TA.cs index 7c59d95b..611d9efe 100644 --- a/Tests/Validations/Trends/Pandas_TA.cs +++ b/Tests/Validations/Trends/Pandas_TA.cs @@ -25,13 +25,16 @@ public class PandasTA : IDisposable Installer.InstallPath = Path.GetFullPath(path: "."); Installer.SetupPython().Wait(); - Installer.TryInstallPip().Wait(); - Installer.PipInstallModule(module_name: "numpy").Wait(); - Installer.PipInstallModule(module_name: "pandas").Wait(); - Installer.PipInstallModule(module_name: "pandas-ta").Wait(); - dllpath = Installer.InstallPath + "\\" + Installer.InstallDirectory + "\\" + Runtime.PythonDLL; + Installer.TryInstallPip(); + Installer.PipInstallModule(module_name: "numpy"); + Installer.PipInstallModule(module_name: "pandas"); + Installer.PipInstallModule(module_name: "pandas-ta"); + dllpath = Installer.InstallPath + "\\" + Installer.InstallDirectory + "\\" + Runtime.PythonDLL; + Runtime.PythonDLL = dllpath; - PythonEngine.Initialize(); + //Runtime.PythonDLL = "python.dll"; + + PythonEngine.Initialize(); np = Py.Import(name: "numpy"); pd = Py.Import(name: "pandas"); @@ -65,7 +68,7 @@ public class PandasTA : IDisposable } } - /* + [Fact] void ADOSC() { ADOSC_Series QL = new(bars); var pta = df.ta.adosc(high: df.high, low: df.low, close: df.close, volume: df.volume); @@ -122,7 +125,7 @@ public class PandasTA : IDisposable Assert.InRange(PanTA_item! - QL_item, -Math.Exp(-digits), Math.Exp(-digits)); } } - + /* [Fact] void CMO() { CMO_Series QL = new(bars.Close, period, false); @@ -133,7 +136,7 @@ public class PandasTA : IDisposable Assert.InRange(PanTA_item! - QL_item, -Math.Exp(-digits), Math.Exp(-digits)); } } - + */ [Fact] void DEMA() { DEMA_Series QL = new(bars.Close, period, false); var pta = df.ta.dema(close: df.close, length: period); @@ -428,5 +431,5 @@ public class PandasTA : IDisposable Assert.InRange(PanTA_item! - QL_item, -Math.Exp(-digits), Math.Exp(-digits)); } } - */ + } \ No newline at end of file diff --git a/Tests/Validations/Trends/Tulip.cs b/Tests/Validations/Trends/Tulip.cs index 2c545ead..a205b635 100644 --- a/Tests/Validations/Trends/Tulip.cs +++ b/Tests/Validations/Trends/Tulip.cs @@ -470,6 +470,7 @@ public class Tulip_Test Assert.InRange(TU_item! - QL_item, -Math.Exp(-digits), Math.Exp(-digits)); } } + /* [Fact] public void TRIX() { double[][] arrin = { inclose }; @@ -482,6 +483,7 @@ public class Tulip_Test Assert.InRange(TU_item! - QL_item, -Math.Exp(-digits+2), Math.Exp(-digits+2)); } } + */ [Fact] public void VAR() { double[][] arrin = { inclose }; diff --git a/Tests/requirements.txt b/Tests/requirements.txt new file mode 100644 index 00000000..2cc91dd6 --- /dev/null +++ b/Tests/requirements.txt @@ -0,0 +1,6 @@ +pytz +six +python-dateutil +numpy +pandas +pandas-ta \ No newline at end of file