diff --git a/Makefile b/Makefile index d41b949..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: - python -m black PyEMD doc + python -m black $(LINT_TARGET_DIRS) lint-check: python -m isort --check PyEMD - python -m black --check PyEMD doc \ 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/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()