From c061ae6328278e58b63d63e9c93236a0204f729e Mon Sep 17 00:00:00 2001 From: Juan Escudero Pedrosa Date: Wed, 13 Dec 2023 12:02:07 +0100 Subject: [PATCH 01/13] fix tests for python 3.11 --- mutis/lib/correlation.py | 4 ++-- mutis/signal.py | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/mutis/lib/correlation.py b/mutis/lib/correlation.py index f8fad50..ec5a6ce 100644 --- a/mutis/lib/correlation.py +++ b/mutis/lib/correlation.py @@ -267,8 +267,8 @@ def nindcf(t1, s1, t2, s2): """Computes the normalised correlation of two discrete signals (interpolating them).""" dt = np.max([(t1.max() - t1.min()) / t1.size, (t2.max() - t2.min()) / t2.size]) - n1 = np.int(np.ptp(t1) / dt * 10.0) - n2 = np.int(np.ptp(t1) / dt * 10.0) + n1 = int(np.ptp(t1) / dt * 10.0) + n2 = int(np.ptp(t1) / dt * 10.0) s1i = np.interp(np.linspace(t1.min(), t1.max(), n1), t1, s1) s2i = np.interp(np.linspace(t2.min(), t2.max(), n2), t2, s2) return ndcf(s1i, s2i) diff --git a/mutis/signal.py b/mutis/signal.py index 04c08b3..6a20934 100644 --- a/mutis/signal.py +++ b/mutis/signal.py @@ -47,7 +47,6 @@ class Signal: (For OU method) Parameter mu of the OU process. OU_sigma : :class:`float` (For OU method) Parameter sigma of the OU process. - """ def __init__(self, times, values, dvalues=None, fgen=None): @@ -113,7 +112,7 @@ def OU_fit(self, bins=None, rang=None, a=1e-5, b=100): # plot histogram if bins is None: - bins = np.int(y.size ** 0.5 / 1.5) # bins='auto' + bins = int(y.size ** 0.5 / 1.5) # bins='auto' if rang is None: rang = (np.percentile(y, 0), np.percentile(y, 99)) @@ -128,7 +127,7 @@ def OU_fit(self, bins=None, rang=None, a=1e-5, b=100): anchored_text = AnchoredText( f"mean {np.mean(y):.2g} \n " f"median {np.median(y):.2g} \n " - f"mode {scipy_stats.mode(y)[0][0]:.2g} \n " + f"mode {scipy_stats.mode(y)[0]:.2g} \n " f"std {np.std(y):.2g} \n " f"var {np.var(y):.2g}", loc="upper right", @@ -232,12 +231,12 @@ def check_gen(self, fgen=None, fgen_params=None, fpsd="lombscargle", **axes): axes["ax1"].set_title("light curves") # plot their histogram - bins = "auto" # bins = np.int(y.size**0.5/1.5) # + bins = "auto" # bins = int(y.size**0.5/1.5) # rang = (np.percentile(y, 0), np.percentile(y, 99)) axes["ax2"].hist(y, density=True, color="b", alpha=0.4, bins=bins, range=rang) # ax2p = ax2.twinx() - bins = "auto" # bins = np.int(y.size**0.5/1.5) # + bins = "auto" # bins = int(y.size**0.5/1.5) # rang = (np.percentile(y2, 0), np.percentile(y2, 99)) axes["ax2"].hist(y2, density=True, color="r", alpha=0.4, bins=bins, range=rang) From ae404850a9ace0c66871ff729f6be359fa4d0937 Mon Sep 17 00:00:00 2001 From: Juan Escudero Pedrosa Date: Wed, 13 Dec 2023 12:02:53 +0100 Subject: [PATCH 02/13] bump python version to 3.11 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 2d00dbd..f173a33 100644 --- a/setup.py +++ b/setup.py @@ -18,5 +18,5 @@ "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", ], - python_requires='>=3.7', + python_requires='>=3.11', ) \ No newline at end of file From 7a017b0c714253d39ccbe68bbbda31330ee420a7 Mon Sep 17 00:00:00 2001 From: Juan Escudero Pedrosa Date: Wed, 13 Dec 2023 16:35:50 +0100 Subject: [PATCH 03/13] fix docs --- docs/recipes/stochastics_tests.ipynb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/recipes/stochastics_tests.ipynb b/docs/recipes/stochastics_tests.ipynb index f5312e8..3d83441 100644 --- a/docs/recipes/stochastics_tests.ipynb +++ b/docs/recipes/stochastics_tests.ipynb @@ -313,9 +313,7 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": [ - "fit[0]*sigma_est**2/2" - ] + "source": [] }, { "cell_type": "markdown", From dc63c2a88ee649394e91dd889fe1df055cbfd5cc Mon Sep 17 00:00:00 2001 From: Juan Escudero Pedrosa Date: Wed, 13 Dec 2023 16:51:01 +0100 Subject: [PATCH 04/13] try to fix CI --- .github/workflows/ci.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 57fe1f3..8d79476 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,13 @@ name: CI -on: [push, pull_request] + +on: + push: + branches: + - main + tags: + - '**' + pull_request: + jobs: tests: defaults: From 7bab083736457aa929802eaf547fdd6ebbeb1c10 Mon Sep 17 00:00:00 2001 From: Juan Escudero Pedrosa Date: Wed, 13 Dec 2023 17:05:15 +0100 Subject: [PATCH 05/13] bump action versions --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8d79476..54733bf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,9 +17,9 @@ jobs: runs-on: ubuntu-latest steps: - name: checkout repo - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: create and activate env - uses: conda-incubator/setup-miniconda@v2 + uses: conda-incubator/setup-miniconda@v3 with: activate-environment: mutis environment-file: environment.yml @@ -38,9 +38,9 @@ jobs: runs-on: ubuntu-latest steps: - name: checkout repo - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: create and activate env - uses: conda-incubator/setup-miniconda@v2 + uses: conda-incubator/setup-miniconda@v3 with: activate-environment: mutis environment-file: environment.yml From 143ed3454a4ef8c28e9fb44a95bc4532828e7fd7 Mon Sep 17 00:00:00 2001 From: Juan Escudero Pedrosa Date: Wed, 13 Dec 2023 17:12:06 +0100 Subject: [PATCH 06/13] debug actions --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 54733bf..8e0210f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,6 +26,9 @@ jobs: - name: install mutis run: | pip install -e . + - name: show the code + run: | + cat mutis/signal.py - name: test coverage run: | make test-cov From 20e381f510f4dc3a11e954196de1eb1137274bf7 Mon Sep 17 00:00:00 2001 From: Juan Escudero Pedrosa Date: Wed, 13 Dec 2023 17:19:31 +0100 Subject: [PATCH 07/13] debug ci --- .github/workflows/ci.yml | 45 +++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8e0210f..9e7222f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,14 +10,11 @@ on: jobs: tests: - defaults: - run: - shell: bash -l {0} name: test coverage runs-on: ubuntu-latest steps: - name: checkout repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: create and activate env uses: conda-incubator/setup-miniconda@v3 with: @@ -33,23 +30,23 @@ jobs: run: | make test-cov codecov -X gcov - docs: - defaults: - run: - shell: bash -l {0} - name: docs building - runs-on: ubuntu-latest - steps: - - name: checkout repo - uses: actions/checkout@v3 - - name: create and activate env - uses: conda-incubator/setup-miniconda@v3 - with: - activate-environment: mutis - environment-file: environment.yml - - name: install mutis - run: | - pip install -e . - - name: build docs - run: | - make docs-sphinx + # docs: + # defaults: + # run: + # shell: bash -l {0} + # name: docs building + # runs-on: ubuntu-latest + # steps: + # - name: checkout repo + # uses: actions/checkout@v4 + # - name: create and activate env + # uses: conda-incubator/setup-miniconda@v3 + # with: + # activate-environment: mutis + # environment-file: environment.yml + # - name: install mutis + # run: | + # pip install -e . + # - name: build docs + # run: | + # make docs-sphinx From 4e04ca6ed3d80eed004984209b4517bf1dc261f0 Mon Sep 17 00:00:00 2001 From: Juan Escudero Pedrosa Date: Wed, 13 Dec 2023 17:25:17 +0100 Subject: [PATCH 08/13] debug ci --- .github/workflows/ci.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9e7222f..fdf2c5a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,10 +11,20 @@ on: jobs: tests: name: test coverage - runs-on: ubuntu-latest + strategy: + matrix: + include: + - python-version: "3.11" + os: ubuntu-latest + runs-on: ${{ matrix.os }} steps: - name: checkout repo uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: show the code 1 + run: | + cat mutis/signal.py - name: create and activate env uses: conda-incubator/setup-miniconda@v3 with: @@ -23,7 +33,7 @@ jobs: - name: install mutis run: | pip install -e . - - name: show the code + - name: show the code 2 run: | cat mutis/signal.py - name: test coverage From 284c275f458cd50eefc9b0d088857e2bfb5c81b6 Mon Sep 17 00:00:00 2001 From: Juan Escudero Pedrosa Date: Wed, 13 Dec 2023 17:28:58 +0100 Subject: [PATCH 09/13] debug ci --- .github/workflows/ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fdf2c5a..7f35b63 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,8 +18,7 @@ jobs: os: ubuntu-latest runs-on: ${{ matrix.os }} steps: - - name: checkout repo - uses: actions/checkout@v4 + - uses: actions/checkout@v4 with: fetch-depth: 0 - name: show the code 1 From fb2bcd331a5d9684f5fc61c4c816af0dfc9589e9 Mon Sep 17 00:00:00 2001 From: Juan Escudero Pedrosa Date: Wed, 13 Dec 2023 17:32:33 +0100 Subject: [PATCH 10/13] debug ci --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7f35b63..3f37c51 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,6 +21,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 + ref: ${{ github.event.pull_request.head.sha }} - name: show the code 1 run: | cat mutis/signal.py From 22fb4d551dc0c8d7cab04b8230579581a3f86287 Mon Sep 17 00:00:00 2001 From: Juan Escudero Pedrosa Date: Wed, 13 Dec 2023 17:36:44 +0100 Subject: [PATCH 11/13] fix ci --- .github/workflows/ci.yml | 49 ++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3f37c51..f6ebc83 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,6 +30,8 @@ jobs: with: activate-environment: mutis environment-file: environment.yml + auto-update-conda: true + python-version: ${{ matrix.python-version }} - name: install mutis run: | pip install -e . @@ -40,23 +42,30 @@ jobs: run: | make test-cov codecov -X gcov - # docs: - # defaults: - # run: - # shell: bash -l {0} - # name: docs building - # runs-on: ubuntu-latest - # steps: - # - name: checkout repo - # uses: actions/checkout@v4 - # - name: create and activate env - # uses: conda-incubator/setup-miniconda@v3 - # with: - # activate-environment: mutis - # environment-file: environment.yml - # - name: install mutis - # run: | - # pip install -e . - # - name: build docs - # run: | - # make docs-sphinx + docs: + name: docs building + strategy: + matrix: + include: + - python-version: "3.11" + os: ubuntu-latest + runs-on: ${{ matrix.os }} + steps: + - name: checkout repo + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ github.event.pull_request.head.sha }} + - name: create and activate env + uses: conda-incubator/setup-miniconda@v3 + with: + activate-environment: mutis + environment-file: environment.yml + auto-update-conda: true + python-version: ${{ matrix.python-version }} + - name: install mutis + run: | + pip install -e . + - name: build docs + run: | + make docs-sphinx From c049e11f1405eafa2af1abdf8dddc688bf61c73f Mon Sep 17 00:00:00 2001 From: Juan Escudero Pedrosa Date: Wed, 13 Dec 2023 17:41:16 +0100 Subject: [PATCH 12/13] fix ci --- .github/workflows/ci.yml | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f6ebc83..afbfe74 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,22 +9,27 @@ on: pull_request: jobs: + tests: name: test coverage + strategy: matrix: include: - python-version: "3.11" os: ubuntu-latest + runs-on: ${{ matrix.os }} + + defaults: + run: + shell: bash -l {0} + steps: - uses: actions/checkout@v4 with: fetch-depth: 0 ref: ${{ github.event.pull_request.head.sha }} - - name: show the code 1 - run: | - cat mutis/signal.py - name: create and activate env uses: conda-incubator/setup-miniconda@v3 with: @@ -35,24 +40,28 @@ jobs: - name: install mutis run: | pip install -e . - - name: show the code 2 - run: | - cat mutis/signal.py - name: test coverage run: | make test-cov codecov -X gcov + docs: name: docs building + strategy: matrix: include: - python-version: "3.11" os: ubuntu-latest + runs-on: ${{ matrix.os }} + + defaults: + run: + shell: bash -l {0} + steps: - - name: checkout repo - uses: actions/checkout@v4 + - uses: actions/checkout@v4 with: fetch-depth: 0 ref: ${{ github.event.pull_request.head.sha }} From da2dd2e71c18090a7ffc6637cc7600252c44af86 Mon Sep 17 00:00:00 2001 From: Juan Escudero Pedrosa Date: Wed, 13 Dec 2023 18:09:16 +0100 Subject: [PATCH 13/13] add tests for bayesian blocks --- mutis/flares/bayblocks.py | 2 +- mutis/tests/test_bayblocks.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 mutis/tests/test_bayblocks.py diff --git a/mutis/flares/bayblocks.py b/mutis/flares/bayblocks.py index 33e6a6d..95ec956 100644 --- a/mutis/flares/bayblocks.py +++ b/mutis/flares/bayblocks.py @@ -213,7 +213,7 @@ def get_flare_list(self): np.where((np.abs(np.diff(np.asarray(self.inflare, dtype=int))) == 1))[0]+1) # (groups contains the groups of indices of self.inflare/self.values - # that corresond to flares or no flares) + # that correspond to flares or no flares) #print(self.inflare) #print([list(grp) for grp in groups]) diff --git a/mutis/tests/test_bayblocks.py b/mutis/tests/test_bayblocks.py new file mode 100644 index 0000000..f96c4c1 --- /dev/null +++ b/mutis/tests/test_bayblocks.py @@ -0,0 +1,16 @@ +import unittest +import numpy as np +from mutis.flares.bayblocks import BayesianBlocks +from mutis import Signal + +def test_bayblocks(): + # test the bayblock algorithm with a signal that corresponds to 3 gaussian pulses in a row + t = np.linspace(0, 6, 50) + y = np.exp(-(t-1)**2/0.1) + np.exp(-(t-3)**2/0.1) + np.exp(-(t-5)**2/0.1) + dy = 0.1 * np.abs(y) + signal = Signal(t, y, dy) + bayblocks = BayesianBlocks(signal, p=1e-1) + bayblocks.get_flares() + bayblocks.signal.plot() + bayblocks.plot() + assert len(bayblocks.get_flare_list()) == 3 \ No newline at end of file