From 9957889962c7ebb94ff8b5a034f1031736d84f00 Mon Sep 17 00:00:00 2001 From: Ryan Grout Date: Fri, 9 Jul 2021 11:58:02 -0500 Subject: [PATCH 1/8] Avoid updating frequencies inplace. Use linearize_freqs to return an updated copy of freqs. --- utide/constituent_selection.py | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/utide/constituent_selection.py b/utide/constituent_selection.py index ff02e0a..28a0963 100644 --- a/utide/constituent_selection.py +++ b/utide/constituent_selection.py @@ -3,7 +3,7 @@ import numpy as np from ._ut_constants import constit_index_dict, ut_constants -from .astronomy import ut_astron +from .harmonics import linearize_freqs from .utilities import Bunch @@ -31,22 +31,13 @@ def ut_cnstitsel(tref, minres, incnstit, infer): coef.aux.reftime = tref """ - shallow = ut_constants.shallow const = ut_constants.const cnstit = Bunch() coef = Bunch() - astro, ader = ut_astron(tref) - - ii = np.isfinite(const.ishallow) - const.freq[~ii] = np.dot(const.doodson[~ii, :], ader[:, 0]) / 24 - - for k in ii.nonzero()[0]: - ik = const.ishallow[k] + np.arange(const.nshallow[k]) - ik = ik.astype(int) - 1 - const.freq[k] = np.sum(const.freq[shallow.iname[ik] - 1] * shallow.coef[ik]) - + freqs = linearize_freqs(tref) + # cnstit.NR cnstit["NR"] = Bunch() @@ -62,7 +53,7 @@ def ut_cnstitsel(tref, minres, incnstit, infer): RI_index_set = {constit_index_dict[n] for n in RIset} cnstit.NR.lind = [ind for ind in cnstit.NR.lind if ind not in RI_index_set] - cnstit.NR.frq = const.freq[cnstit.NR.lind] + cnstit.NR.frq = freq[cnstit.NR.lind] cnstit.NR.name = const.name[cnstit.NR.lind] nNR = len(cnstit.NR.frq) @@ -80,7 +71,7 @@ def ut_cnstitsel(tref, minres, incnstit, infer): for k, name in enumerate(allrefs): refstruct = Bunch(name=name) refstruct.lind = constit_index_dict[name] - refstruct.frq = const.freq[refstruct.lind] + refstruct.frq = freq[refstruct.lind] ind = [i for i, rname in enumerate(infer.reference_names) if name == rname] refstruct.nI = len(ind) refstruct.I = Bunch(Rp=[], Rm=[], name=[], lind=[], frq=[]) # noqa @@ -101,7 +92,7 @@ def ut_cnstitsel(tref, minres, incnstit, infer): refstruct.I.name.append(iname) lind = constit_index_dict[iname] refstruct.I.lind.append(lind) - refstruct.I.frq.append(const.freq[lind]) + refstruct.I.frq.append(freq[lind]) refstruct.I.Rp = np.array(refstruct.I.Rp) refstruct.I.Rm = np.array(refstruct.I.Rm) From a65ca758ac43d1c08545ab2aa3f42fbcf9d0da77 Mon Sep 17 00:00:00 2001 From: Ryan Grout Date: Fri, 9 Jul 2021 13:01:55 -0500 Subject: [PATCH 2/8] Fix typo. --- utide/constituent_selection.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utide/constituent_selection.py b/utide/constituent_selection.py index 28a0963..850def1 100644 --- a/utide/constituent_selection.py +++ b/utide/constituent_selection.py @@ -3,7 +3,7 @@ import numpy as np from ._ut_constants import constit_index_dict, ut_constants -from .harmonics import linearize_freqs +from .harmonics import linearized_freqs from .utilities import Bunch @@ -36,7 +36,7 @@ def ut_cnstitsel(tref, minres, incnstit, infer): cnstit = Bunch() coef = Bunch() - freqs = linearize_freqs(tref) + freqs = linearized_freqs(tref) # cnstit.NR cnstit["NR"] = Bunch() From e879d712efb6630879e871129dea6ff043baad2b Mon Sep 17 00:00:00 2001 From: Ryan Grout Date: Fri, 9 Jul 2021 14:37:58 -0500 Subject: [PATCH 3/8] Fix typos. --- utide/constituent_selection.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/utide/constituent_selection.py b/utide/constituent_selection.py index 850def1..af2142b 100644 --- a/utide/constituent_selection.py +++ b/utide/constituent_selection.py @@ -53,7 +53,7 @@ def ut_cnstitsel(tref, minres, incnstit, infer): RI_index_set = {constit_index_dict[n] for n in RIset} cnstit.NR.lind = [ind for ind in cnstit.NR.lind if ind not in RI_index_set] - cnstit.NR.frq = freq[cnstit.NR.lind] + cnstit.NR.frq = freqs[cnstit.NR.lind] cnstit.NR.name = const.name[cnstit.NR.lind] nNR = len(cnstit.NR.frq) @@ -71,7 +71,7 @@ def ut_cnstitsel(tref, minres, incnstit, infer): for k, name in enumerate(allrefs): refstruct = Bunch(name=name) refstruct.lind = constit_index_dict[name] - refstruct.frq = freq[refstruct.lind] + refstruct.frq = freqs[refstruct.lind] ind = [i for i, rname in enumerate(infer.reference_names) if name == rname] refstruct.nI = len(ind) refstruct.I = Bunch(Rp=[], Rm=[], name=[], lind=[], frq=[]) # noqa @@ -92,7 +92,7 @@ def ut_cnstitsel(tref, minres, incnstit, infer): refstruct.I.name.append(iname) lind = constit_index_dict[iname] refstruct.I.lind.append(lind) - refstruct.I.frq.append(freq[lind]) + refstruct.I.frq.append(freqs[lind]) refstruct.I.Rp = np.array(refstruct.I.Rp) refstruct.I.Rm = np.array(refstruct.I.Rm) From f1bfe6ff0afb94007a5b3be18184148976a90778 Mon Sep 17 00:00:00 2001 From: Filipe Fernandes Date: Wed, 27 Apr 2022 10:55:34 -0300 Subject: [PATCH 4/8] fix pre-commit --- utide/constituent_selection.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utide/constituent_selection.py b/utide/constituent_selection.py index af2142b..603b479 100644 --- a/utide/constituent_selection.py +++ b/utide/constituent_selection.py @@ -37,7 +37,7 @@ def ut_cnstitsel(tref, minres, incnstit, infer): coef = Bunch() freqs = linearized_freqs(tref) - + # cnstit.NR cnstit["NR"] = Bunch() From 69115271252a33eeab2c3a68fbb194d6976b539c Mon Sep 17 00:00:00 2001 From: Filipe Fernandes Date: Wed, 27 Apr 2022 10:55:51 -0300 Subject: [PATCH 5/8] update pre-commits --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8723965..d775052 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -42,6 +42,6 @@ repos: - --py36-plus - repo: https://github.com/asottile/add-trailing-comma - rev: v2.2.2 + rev: v2.2.3 hooks: - id: add-trailing-comma From a39daf60908a7afa12c3cc1ef500f7169c5910f0 Mon Sep 17 00:00:00 2001 From: Filipe Fernandes Date: Wed, 27 Apr 2022 11:05:45 -0300 Subject: [PATCH 6/8] try micromamba for faster iterations --- .github/workflows/tests.yml | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0179eeb..5c34825 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -22,24 +22,27 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Setup Conda - uses: s-weigand/setup-conda@v1 + - name: Setup + uses: mamba-org/provision-with-micromamba@main with: - activate-conda: false - conda-channels: conda-forge + environment-file: false - name: Python ${{ matrix.python-version }} numpy ${{ matrix.numpy-version }} shell: bash -l {0} run: | - conda create --name TEST python=${{ matrix.python-version }} --file requirements.txt --file requirements-dev.txt - source activate TEST - conda install numpy=${{ matrix.numpy-version }} + micromamba create --name TEST python=${{ matrix.python-version }} --file requirements.txt --file requirements-dev.txt + micromamba activate TEST + micromamba install numpy=${{ matrix.numpy-version }} pip install -e . --no-deps --force-reinstall - conda info --all - conda list + + - name: Debug Info + shell: bash -l {0} + run: | + micromamba info --all + micromamba list - name: Tests shell: bash -l {0} run: | - source activate TEST - pytest -n 2 -rxs --cov=utide tests + micromamba activate TEST + pytest -n 2 -rxs --cov=utide tests/ From 17ce5167ec4943ac519e11856f1ae7fcb4911cdf Mon Sep 17 00:00:00 2001 From: Filipe Fernandes Date: Wed, 27 Apr 2022 11:20:18 -0300 Subject: [PATCH 7/8] activate env --- .github/workflows/tests.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5c34825..ca46055 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -18,6 +18,7 @@ jobs: exclude: - python-version: "3.10" numpy-version: "1.19" + fail-fast: false steps: - uses: actions/checkout@v2 @@ -38,6 +39,7 @@ jobs: - name: Debug Info shell: bash -l {0} run: | + micromamba activate TEST micromamba info --all micromamba list @@ -45,4 +47,4 @@ jobs: shell: bash -l {0} run: | micromamba activate TEST - pytest -n 2 -rxs --cov=utide tests/ + pytest -n 2 -rxs --cov=utide tests From 2562a326425d6f5a85ee4aac9f19fc23b197e299 Mon Sep 17 00:00:00 2001 From: Filipe Fernandes Date: Wed, 27 Apr 2022 11:26:19 -0300 Subject: [PATCH 8/8] micromamba has no channels --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ca46055..a113612 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -31,7 +31,7 @@ jobs: - name: Python ${{ matrix.python-version }} numpy ${{ matrix.numpy-version }} shell: bash -l {0} run: | - micromamba create --name TEST python=${{ matrix.python-version }} --file requirements.txt --file requirements-dev.txt + micromamba create --name TEST python=${{ matrix.python-version }} --file requirements.txt --file requirements-dev.txt --channel conda-forge micromamba activate TEST micromamba install numpy=${{ matrix.numpy-version }} pip install -e . --no-deps --force-reinstall