diff --git a/.github/workflows/ci-lint.yml b/.github/workflows/ci-lint.yml index 2486f0a..e1cac55 100644 --- a/.github/workflows/ci-lint.yml +++ b/.github/workflows/ci-lint.yml @@ -1,26 +1,13 @@ name: Linter -on: [push] +on: [push, pull_request] jobs: - build-n-lint: + lint: runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set up Python 3.8 - uses: actions/setup-python@v2 + - uses: actions/checkout@v4 + - uses: psf/black@stable + - uses: isort/isort-action@v1 with: - python-version: "3.8" - - - name: Install test dependencies - run: | - pip install --upgrade pip - pip install --only-binary=numpy,scipy numpy scipy - pip install -e .[dev] - - name: Run ISort check - run: python -m isort --check PyEMD - - name: Run PyCodeStyle check - run: python -m pycodestyle PyEMD - - name: Run Black check - run: python -m black --check PyEMD + sort-paths: PyEMD diff --git a/.github/workflows/ci-main-build-test-deploy.yml b/.github/workflows/ci-main-build-test-deploy.yml new file mode 100644 index 0000000..0aa7287 --- /dev/null +++ b/.github/workflows/ci-main-build-test-deploy.yml @@ -0,0 +1,52 @@ +name: Upload Python Package + +on: + push: + paths: + - PyEMD/__init__.py + branches: + - $default-branch + +jobs: + build-n-test: + runs-on: ubuntu-latest + + strategy: + matrix: + python-version: [3.8, 3.9, 3.10, 3.11, 3.12] + + steps: + - uses: actions/checkout@v4 + - name: Running Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Install test dependencies + run: | + pip install --only-binary=numpy,scipy numpy scipy + pip install -e .[test] + - name: Run tests + run: | + python -m PyEMD.tests.test_all + + deploy: + # Run 'deploy' job only if `PyEMD/__init__.py` is modified + if: github.event_name == 'push' && contains(github.event.head_commit.modified, 'PyEMD/__init__.py') + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.x" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build + - name: Build package + run: python -m build + - name: Publish package + uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 + with: + user: __token__ + password: ${{ secrets.EMD_PYPI_API_TOKEN }} diff --git a/.github/workflows/ci-pr-test.yml b/.github/workflows/ci-pr-test.yml new file mode 100644 index 0000000..455bf6a --- /dev/null +++ b/.github/workflows/ci-pr-test.yml @@ -0,0 +1,37 @@ +name: Test + +on: + push: + branches-ignore: + - $default-branch + pull_request: + paths: + - 'PyEMD/**.py' + +jobs: + + build-n-test: + runs-on: ubuntu-latest + + strategy: + matrix: + python-version: + - "3.8" + - "3.9" + - "3.10" + - "3.11" + - "3.12" + + steps: + - uses: actions/checkout@v4 + - name: Running Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Install test dependencies + run: | + pip install --only-binary=numpy,scipy numpy scipy + pip install -e .[test] + - name: Run tests + run: | + python -m PyEMD.tests.test_all diff --git a/.github/workflows/ci-test.yml b/.github/workflows/ci-test.yml deleted file mode 100644 index 12dcb5f..0000000 --- a/.github/workflows/ci-test.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: Test - -on: - push: - branches: [ $default-branch ] - pull_request: - paths: - - 'PyEMD/**.py' - -jobs: - build-n-test-36: - name: Linux 3.6 - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v3 - - name: Running Python 3.6 - uses: actions/setup-python@v4 - with: - python-version: 3.6 - architecture: x64 - - name: Install test dependencies - run: | - pip install --only-binary=numpy,scipy numpy scipy - pip install -e .[test] - - name: Run tests - run: | - python -m PyEMD.tests.test_all - - build-n-test: - runs-on: ubuntu-latest - - strategy: - matrix: - python-version: [3.7, 3.8, 3.9] - - steps: - - uses: actions/checkout@v3 - - name: Running Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - name: Install test dependencies - run: | - pip install --only-binary=numpy,scipy numpy scipy - pip install -e .[test] - - name: Run tests - run: | - python -m PyEMD.tests.test_all diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml deleted file mode 100644 index 3ab1912..0000000 --- a/.github/workflows/python-publish.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Upload Python Package - -on: - push: - paths: - - PyEMD/__init__.py - branches: - - "master" - - "ci-test" - -jobs: - deploy: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: "3.x" - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install build - - name: Build package - run: python -m build - - name: Publish package - uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 - with: - user: __token__ - password: ${{ secrets.EMD_PYPI_API_TOKEN }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 2803e70..0000000 --- a/.travis.yml +++ /dev/null @@ -1,20 +0,0 @@ -os: linux -dist: xenial -language: python -python: - - 3.6 - - 3.7 - - 3.8 -# command to run tests -before_install: - - pip install --upgrade pip setuptools wheel -install: - - pip install --only-binary=numpy,scipy numpy scipy - - pip install -r requirements.txt - - pip install -r requirements-extra.txt - - pip install codecov -script: - - python -m PyEMD.tests.test_all - - coverage run PyEMD/tests/test_all.py -after_success: - - codecov diff --git a/Makefile b/Makefile index 2169760..e8c7849 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,4 @@ +LINT_TARGET_DIRS := PyEMD doc example test: python -m PyEMD.tests.test_all @@ -10,8 +11,11 @@ doc: cd doc && make html format: - black PyEMD + python -m black $(LINT_TARGET_DIRS) lint-check: python -m isort --check PyEMD - python -m black --check PyEMD \ No newline at end of file + python -m black --check $(LINT_TARGET_DIRS) + +perf/build: + docker build -t pyemd-perf -f perf_test/Dockerfile . \ No newline at end of file diff --git a/PyEMD/__init__.py b/PyEMD/__init__.py index d53369a..0166f9f 100644 --- a/PyEMD/__init__.py +++ b/PyEMD/__init__.py @@ -1,6 +1,6 @@ import logging -__version__ = "1.5.2" +__version__ = "1.6.0" logger = logging.getLogger("pyemd") from PyEMD.CEEMDAN import CEEMDAN # noqa diff --git a/PyEMD/checks.py b/PyEMD/checks.py index 80d14a1..8818d11 100644 --- a/PyEMD/checks.py +++ b/PyEMD/checks.py @@ -1,4 +1,5 @@ """Calculate the statistical Significance of IMFs.""" + import logging import math diff --git a/PyEMD/tests/test_checks.py b/PyEMD/tests/test_checks.py index 7945e35..874f359 100644 --- a/PyEMD/tests/test_checks.py +++ b/PyEMD/tests/test_checks.py @@ -1,4 +1,5 @@ """Tests for checks.py.""" + import unittest import numpy as np diff --git a/README.md b/README.md index fca085d..30827ea 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ [![codecov](https://codecov.io/gh/laszukdawid/PyEMD/branch/master/graph/badge.svg)](https://codecov.io/gh/laszukdawid/PyEMD) -[![Build Status](https://app.travis-ci.com/laszukdawid/PyEMD.svg?branch=master)](https://app.travis-ci.com/laszukdawid/PyEMD) [![DocStatus](https://readthedocs.org/projects/pyemd/badge/?version=latest)](https://pyemd.readthedocs.io/) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/f56b6fc3f855476dbaebd3c02ae88f3e)](https://www.codacy.com/gh/laszukdawid/PyEMD/dashboard?utm_source=github.com&utm_medium=referral&utm_content=laszukdawid/PyEMD&utm_campaign=Badge_Grade) [![DOI](https://zenodo.org/badge/65324353.svg)](https://zenodo.org/badge/latestdoi/65324353) diff --git a/doc/conf.py b/doc/conf.py index 6d91db0..183b63e 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -65,25 +65,25 @@ master_doc = "index" # General information about the project. -project = u"PyEMD" -copyright = u"2016-{year}, Dawid Laszuk".format(year=datetime.datetime.now().year) -author = u"Dawid Laszuk" +project = "PyEMD" +copyright = "2016-{year}, Dawid Laszuk".format(year=datetime.datetime.now().year) +author = "Dawid Laszuk" # 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 = u"0.4.0" +version = "0.4.0" # The full version, including alpha/beta/rc tags. -release = u"0.4.0" +release = "0.4.0" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. -language = 'en' +language = "en" # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. @@ -142,7 +142,7 @@ # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, "PyEMD.tex", u"PyEMD Documentation", u"Dawid Laszuk", "manual"), + (master_doc, "PyEMD.tex", "PyEMD Documentation", "Dawid Laszuk", "manual"), ] @@ -150,7 +150,7 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). -man_pages = [(master_doc, "PyEMD", u"PyEMD Documentation", [author], 1)] +man_pages = [(master_doc, "PyEMD", "PyEMD Documentation", [author], 1)] # -- Options for Texinfo output ------------------------------------------- @@ -159,7 +159,7 @@ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, "PyEMD", u"PyEMD Documentation", author, "PyEMD", "One line description of project.", "Miscellaneous"), + (master_doc, "PyEMD", "PyEMD Documentation", author, "PyEMD", "One line description of project.", "Miscellaneous"), ] diff --git a/example/eemd_example.py b/example/eemd_example.py index 5c9c7eb..a411da4 100644 --- a/example/eemd_example.py +++ b/example/eemd_example.py @@ -12,7 +12,7 @@ S += 5 * sin(11, 2.7) S += 3 * sin(14, 1.6) S += 1 * np.sin(4 * 2 * np.pi * (t - 0.8) ** 2) -S += t ** 2.1 - t +S += t**2.1 - t # Assign EEMD to `eemd` variable eemd = EEMD() diff --git a/example/emd_comparison.py b/example/emd_comparison.py index 1391069..e516129 100644 --- a/example/emd_comparison.py +++ b/example/emd_comparison.py @@ -6,6 +6,7 @@ a lot of the same computation within a single execution. For a single script with a single EMD execution, it's still much more performant to use normal EMD. """ + import time import numpy as np @@ -17,11 +18,13 @@ t = get_timeline(len(s), s.dtype) n_repeat = 20 -print(f"""Comparing EEMD execution on a larger signal with classic and JIT EMDs. +print( + f"""Comparing EEMD execution on a larger signal with classic and JIT EMDs. Signal is random (uniform) noise of length: {len(s)}. The test is done by executing EEMD with either classic or JIT EMD {n_repeat} times and taking the average. Such setup favouries JitEMD which is compiled once and then reused {n_repeat-1} times. -Compiltion is quite costly.""") +Compiltion is quite costly.""" +) time_0 = time.time() emd = EMD() diff --git a/example/example_spline_capabilities.py b/example/example_spline_capabilities.py index e472bf7..bfaf392 100644 --- a/example/example_spline_capabilities.py +++ b/example/example_spline_capabilities.py @@ -10,7 +10,7 @@ from PyEMD.utils import get_timeline -def test_spline(X,T,s_kind): +def test_spline(X, T, s_kind): """ Test the fitting with the given spline. @@ -38,11 +38,11 @@ def test_spline(X,T,s_kind): emd = EMD() emd.spline_kind = s_kind - max_env, min_env, eMax, eMin = emd.extract_max_min_spline(T,X) + max_env, min_env, eMax, eMin = emd.extract_max_min_spline(T, X) return max_env, min_env, eMax, eMin -def test_akima(X,T,ax): +def test_akima(X, T, ax): """ test the fitting with akima spline. @@ -65,15 +65,15 @@ def test_akima(X,T,ax): max_env, min_env, eMax, eMin = test_spline(X, T, "akima") - ax.plot(max_env,label='max akima') - ax.plot(min_env,label='min akima') + ax.plot(max_env, label="max akima") + ax.plot(min_env, label="min akima") return eMax, eMin -def test_cubic(X,T,ax): +def test_cubic(X, T, ax): """ test the fitting with cubic spline - + Parameters ---------- see 'test_akima' @@ -85,14 +85,14 @@ def test_cubic(X,T,ax): max_env, min_env, eMax, eMin = test_spline(X, T, "cubic") - ax.plot(max_env,label='max cubic') - ax.plot(min_env,label='min cubic') + ax.plot(max_env, label="max cubic") + ax.plot(min_env, label="min cubic") return eMax, eMin -def test_pchip(X,T,ax): +def test_pchip(X, T, ax): """ - test the fitting with pchip spline + test the fitting with pchip spline 'Piecewise Cubic Hermite Interpolating Polynomial' Parameters @@ -106,14 +106,14 @@ def test_pchip(X,T,ax): max_env, min_env, eMax, eMin = test_spline(X, T, "pchip") - ax.plot(max_env,label='max pchip') - ax.plot(min_env,label='min pchip') + ax.plot(max_env, label="max pchip") + ax.plot(min_env, label="min pchip") return eMax, eMin -def test_cubic_hermite(X,T,ax): +def test_cubic_hermite(X, T, ax): """ - test the fitting with cubic_hermite spline + test the fitting with cubic_hermite spline Parameters ---------- @@ -126,24 +126,23 @@ def test_cubic_hermite(X,T,ax): max_env, min_env, eMax, eMin = test_spline(X, T, "cubic_hermite") - ax.plot(max_env,label='max cubic_hermite') - ax.plot(min_env,label='min cubic_hermite') + ax.plot(max_env, label="max cubic_hermite") + ax.plot(min_env, label="min cubic_hermite") return eMax, eMin - if __name__ == "__main__": X = np.random.normal(size=200) - T = get_timeline(len(X),X.dtype) + T = get_timeline(len(X), X.dtype) T = EMD._normalize_time(T) fig, ax = plt.subplots() - ax.plot(X,'--',lw=2,c='k') + ax.plot(X, "--", lw=2, c="k") emax_akima, emin_akima = test_akima(X, T, ax) emax_cubic, emin_cubic = test_cubic(X, T, ax) emax_pchip, emin_pchip = test_pchip(X, T, ax) emax_chermite, emin_chermite = test_cubic_hermite(X, T, ax) - ax.plot(emax_akima[0],emax_akima[1],'--') + ax.plot(emax_akima[0], emax_akima[1], "--") ax.legend() - plt.show() \ No newline at end of file + plt.show() diff --git a/example/hht_example.py b/example/hht_example.py index bffd05a..f9eff6e 100644 --- a/example/hht_example.py +++ b/example/hht_example.py @@ -21,7 +21,7 @@ def instant_phase(imfs): S += 5 * sin(11, 2.7) S += 3 * sin(14, 1.6) S += 1 * np.sin(4 * 2 * np.pi * (t - 0.8) ** 2) -S += t ** 2.1 - t +S += t**2.1 - t # Compute IMFs with EMD emd = EMD() diff --git a/setup.cfg b/setup.cfg index ad927e1..4a3ed67 100644 --- a/setup.cfg +++ b/setup.cfg @@ -22,7 +22,7 @@ install_requires = numpy >= 1.12 scipy >= 0.19 pathos >= 0.2.1 - tqdm == 4.64.* + tqdm >= 4.64.0, < 5.0 python_requires = >=3.6, <4 test_suite = PyEMD.tests @@ -34,10 +34,9 @@ doc = jit = numba==0.56.* dev = - pycodestyle==2.8.* - black==23.3.* - isort==5.10.* - click==8.0.4 + pycodestyle==2.11.* + black==24.3.* + isort==5.12.* test = pytest codecov