From e71729c3368c7316b135ba44b5e628c5b884804c Mon Sep 17 00:00:00 2001 From: Andrew Gray Date: Mon, 14 Aug 2023 10:03:20 -0700 Subject: [PATCH 01/33] GEOPY-882 migrate provision-with-micromamba to setup-micromamba --- .github/workflows/pytest-windows.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pytest-windows.yaml b/.github/workflows/pytest-windows.yaml index 86853dc17..248fd2ae5 100644 --- a/.github/workflows/pytest-windows.yaml +++ b/.github/workflows/pytest-windows.yaml @@ -43,7 +43,7 @@ jobs: with: lfs: true - name: Setup conda env - uses: mamba-org/provision-with-micromamba@main + uses: mamba-org/setup-micromamba@v1 with: environment-file: ${{ env.CONDA_LOCK_ENV_FILE }} environment-name: test_env From 27a0c5165190985938667b9b5eb8bb5aaa4e63d3 Mon Sep 17 00:00:00 2001 From: Andrew Gray Date: Mon, 14 Aug 2023 10:28:58 -0700 Subject: [PATCH 02/33] GEOPY-882 tell github action to activate the conda env it just created? --- .github/workflows/pytest-windows.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/pytest-windows.yaml b/.github/workflows/pytest-windows.yaml index 248fd2ae5..8b93fc657 100644 --- a/.github/workflows/pytest-windows.yaml +++ b/.github/workflows/pytest-windows.yaml @@ -47,8 +47,10 @@ jobs: with: environment-file: ${{ env.CONDA_LOCK_ENV_FILE }} environment-name: test_env + activate-environment: test_env cache-downloads: true - name: pytest + shell: shell: bash -l {0} run: | pytest --cov=${source_dir} --cov-report=xml --cov-branch - name: Codecov From e1e63542986e2e25a89c3fced57b150add14484b Mon Sep 17 00:00:00 2001 From: Andrew Gray Date: Mon, 14 Aug 2023 11:13:56 -0700 Subject: [PATCH 03/33] GEOPY-882 remove incorrect shell --- .github/workflows/pytest-windows.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/pytest-windows.yaml b/.github/workflows/pytest-windows.yaml index 8b93fc657..4e31fb3ef 100644 --- a/.github/workflows/pytest-windows.yaml +++ b/.github/workflows/pytest-windows.yaml @@ -50,7 +50,6 @@ jobs: activate-environment: test_env cache-downloads: true - name: pytest - shell: shell: bash -l {0} run: | pytest --cov=${source_dir} --cov-report=xml --cov-branch - name: Codecov From 684c9a7d455588212df6d59ce2076d80d9d62918 Mon Sep 17 00:00:00 2001 From: Andrew Gray Date: Mon, 14 Aug 2023 11:38:10 -0700 Subject: [PATCH 04/33] GEOPY-882 specify shell --- .github/workflows/pytest-windows.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pytest-windows.yaml b/.github/workflows/pytest-windows.yaml index 4e31fb3ef..b283ca92d 100644 --- a/.github/workflows/pytest-windows.yaml +++ b/.github/workflows/pytest-windows.yaml @@ -50,6 +50,7 @@ jobs: activate-environment: test_env cache-downloads: true - name: pytest + shell: powershell run: | pytest --cov=${source_dir} --cov-report=xml --cov-branch - name: Codecov From ea3194709a5200f9f2da0f0365c625a99236df42 Mon Sep 17 00:00:00 2001 From: Andrew Gray Date: Mon, 14 Aug 2023 11:53:08 -0700 Subject: [PATCH 05/33] GEOPY-882 specify init-shell --- .github/workflows/pytest-windows.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/pytest-windows.yaml b/.github/workflows/pytest-windows.yaml index b283ca92d..c412410bc 100644 --- a/.github/workflows/pytest-windows.yaml +++ b/.github/workflows/pytest-windows.yaml @@ -47,10 +47,9 @@ jobs: with: environment-file: ${{ env.CONDA_LOCK_ENV_FILE }} environment-name: test_env - activate-environment: test_env + init-shell: powershell cache-downloads: true - name: pytest - shell: powershell run: | pytest --cov=${source_dir} --cov-report=xml --cov-branch - name: Codecov From dd4a6516ee0f867c8d0ebd1b7edfb7350eca0e14 Mon Sep 17 00:00:00 2001 From: Andrew Gray Date: Wed, 20 Sep 2023 09:53:58 -0700 Subject: [PATCH 06/33] GEOPY-1058 migrate to setup-micromamba in github workflows --- .github/workflows/create_env_file.yml | 4 ++-- .github/workflows/pytest-unix-os.yaml | 2 +- .github/workflows/static-analysis.yml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/create_env_file.yml b/.github/workflows/create_env_file.yml index 3d3b03bb0..387ad2cf1 100644 --- a/.github/workflows/create_env_file.yml +++ b/.github/workflows/create_env_file.yml @@ -34,13 +34,13 @@ jobs: SHORT_SHA=${GITHUB_SHA:0:8} echo "git_ref_suffix=${REF_NAME}-${SHORT_SHA}" >> $GITHUB_OUTPUT - name: Activate conda base env - uses: mamba-org/provision-with-micromamba@main + uses: mamba-org/setup-micromamba@v1 with: environment-file: environments\env-python-${{ env.python_ver }}.yml environment-name: conda-lock cache-downloads: true cache-env: true - extra-specs: conda-lock + create-args: conda-lock channels: conda-forge - name: Create env file id: create-env-file diff --git a/.github/workflows/pytest-unix-os.yaml b/.github/workflows/pytest-unix-os.yaml index cde52eebd..e0af82f33 100644 --- a/.github/workflows/pytest-unix-os.yaml +++ b/.github/workflows/pytest-unix-os.yaml @@ -44,7 +44,7 @@ jobs: with: lfs: true - name: Setup conda env - uses: mamba-org/provision-with-micromamba@main + uses: mamba-org/setup-micromamba@v1 with: environment-file: ${{ env.CONDA_LOCK_ENV_FILE }} environment-name: test_env diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 8ef8a2124..7e9ea3933 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -37,7 +37,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: Setup conda env - uses: mamba-org/provision-with-micromamba@main + uses: mamba-org/setup-micromamba@v1 with: environment-file: ${{ env.CONDA_LOCK_ENV_FILE }} environment-name: linter_env From c2d23b68faff504af4be79f250642e746425d00f Mon Sep 17 00:00:00 2001 From: Andrew Gray Date: Fri, 29 Sep 2023 06:47:11 -0700 Subject: [PATCH 07/33] GEOPY-1083 run pylint on ubuntu --- .github/workflows/static-analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 7e9ea3933..c9c4466ce 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -26,7 +26,7 @@ env: jobs: pylint: name: pylint - runs-on: windows-latest + runs-on: ubuntu-latest defaults: run: shell: bash -l {0} From 3c9b3082239008a5a2b094718628a9fd1a64f28a Mon Sep 17 00:00:00 2001 From: Andrew Gray Date: Fri, 29 Sep 2023 07:13:32 -0700 Subject: [PATCH 08/33] GEOPY-1083 static-analysys: use linux lock file --- .github/workflows/static-analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index c9c4466ce..1d3a4c3ee 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -32,7 +32,7 @@ jobs: shell: bash -l {0} env: PYTHONUTF8: 1 - CONDA_LOCK_ENV_FILE: environments/conda-py-3.9-win-64-dev.lock.yml + CONDA_LOCK_ENV_FILE: environments/conda-py-3.9-linux-64-dev.lock.yml PIP_EXTRA_INDEX_URL: https://test.pypi.org/simple/ steps: - uses: actions/checkout@v3 From 4ae3b3fcefbbe0f523ac039297ffef3511bd4a94 Mon Sep 17 00:00:00 2001 From: Andrew Gray Date: Fri, 29 Sep 2023 10:30:36 -0700 Subject: [PATCH 09/33] GEOPY-1083 remove Macos from pytest for now --- .github/workflows/pytest-unix-os.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pytest-unix-os.yaml b/.github/workflows/pytest-unix-os.yaml index e0af82f33..0bb98d2df 100644 --- a/.github/workflows/pytest-unix-os.yaml +++ b/.github/workflows/pytest-unix-os.yaml @@ -30,7 +30,7 @@ jobs: fail-fast: false matrix: python_ver: ['3.9', '3.10'] - os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest] runs-on: ${{ matrix.os }} defaults: run: From ad82243e47ebff163b8cac52e545e3b8fe4639cc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 1 Oct 2023 11:09:43 +0000 Subject: [PATCH 10/33] Bump actions/checkout from 3 to 4 Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/create_env_file.yml | 6 +++--- .github/workflows/pytest-unix-os.yaml | 2 +- .github/workflows/pytest-windows.yaml | 2 +- .github/workflows/static-analysis.yml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/create_env_file.yml b/.github/workflows/create_env_file.yml index 387ad2cf1..5eac9037c 100644 --- a/.github/workflows/create_env_file.yml +++ b/.github/workflows/create_env_file.yml @@ -26,7 +26,7 @@ jobs: full_env_file: ${{ steps.create-env-file.outputs.full_env_file }} artifact: ${{ env.ARTIFACT_NAME }}.${{ steps.git-info.outputs.git_ref_suffix }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: git info id: git-info run: | @@ -63,7 +63,7 @@ jobs: outputs: release_id: ${{ steps.create-release.outputs.release_id }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Create draft release id: create-release env: @@ -85,7 +85,7 @@ jobs: if: ${{ needs.create-env-file.outputs.releaseFullEnv == true }} runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/download-artifact@v3 with: name: ${{ needs.create-env-file.outputs.artifact }} diff --git a/.github/workflows/pytest-unix-os.yaml b/.github/workflows/pytest-unix-os.yaml index 0bb98d2df..ad800e30a 100644 --- a/.github/workflows/pytest-unix-os.yaml +++ b/.github/workflows/pytest-unix-os.yaml @@ -40,7 +40,7 @@ jobs: CONDA_LOCK_ENV_FILE: environments/conda-py-${{ matrix.python_ver }}-${{ startsWith(matrix.os, 'macos') && 'osx' || 'linux' }}-64-dev.lock.yml PIP_EXTRA_INDEX_URL: https://test.pypi.org/simple/ steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: lfs: true - name: Setup conda env diff --git a/.github/workflows/pytest-windows.yaml b/.github/workflows/pytest-windows.yaml index c412410bc..9d8dff5b5 100644 --- a/.github/workflows/pytest-windows.yaml +++ b/.github/workflows/pytest-windows.yaml @@ -39,7 +39,7 @@ jobs: CONDA_LOCK_ENV_FILE: environments/conda-py-${{ matrix.python_ver }}-win-64-dev.lock.yml PIP_EXTRA_INDEX_URL: https://test.pypi.org/simple/ steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: lfs: true - name: Setup conda env diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 1d3a4c3ee..99edd0f5d 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -35,7 +35,7 @@ jobs: CONDA_LOCK_ENV_FILE: environments/conda-py-3.9-linux-64-dev.lock.yml PIP_EXTRA_INDEX_URL: https://test.pypi.org/simple/ steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup conda env uses: mamba-org/setup-micromamba@v1 with: From 592914b5eca7d02f7ab319df7536a76a892bf554 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 2 Oct 2023 20:39:22 +0000 Subject: [PATCH 11/33] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 23.7.0 → 23.9.1](https://github.com/psf/black/compare/23.7.0...23.9.1) - [github.com/asottile/pyupgrade: v3.10.1 → v3.13.0](https://github.com/asottile/pyupgrade/compare/v3.10.1...v3.13.0) - [github.com/rstcheck/rstcheck: v6.1.2 → v6.2.0](https://github.com/rstcheck/rstcheck/compare/v6.1.2...v6.2.0) --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7ede0a341..20390c8ff 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ ci: repos: - repo: https://github.com/psf/black - rev: 23.7.0 + rev: 23.9.1 hooks: - id: black - repo: https://github.com/PyCQA/isort @@ -29,7 +29,7 @@ repos: # hooks: # - id: flake8 - repo: https://github.com/asottile/pyupgrade - rev: v3.10.1 + rev: v3.13.0 hooks: - id: pyupgrade args: [--py39-plus] @@ -83,7 +83,7 @@ repos: - id: mixed-line-ending - id: name-tests-test - repo: https://github.com/rstcheck/rstcheck - rev: v6.1.2 + rev: v6.2.0 hooks: - id: rstcheck exclude: ^THIRD_PARTY_SOFTWARE.rst$ From 7ba5f096b209d48c47fd85f1449736cb26cf43de Mon Sep 17 00:00:00 2001 From: Andrew Gray Date: Mon, 14 Aug 2023 10:03:20 -0700 Subject: [PATCH 12/33] GEOPY-882 migrate provision-with-micromamba to setup-micromamba --- .github/workflows/pytest-windows.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pytest-windows.yaml b/.github/workflows/pytest-windows.yaml index 86853dc17..248fd2ae5 100644 --- a/.github/workflows/pytest-windows.yaml +++ b/.github/workflows/pytest-windows.yaml @@ -43,7 +43,7 @@ jobs: with: lfs: true - name: Setup conda env - uses: mamba-org/provision-with-micromamba@main + uses: mamba-org/setup-micromamba@v1 with: environment-file: ${{ env.CONDA_LOCK_ENV_FILE }} environment-name: test_env From 8876ea478f42d25ab6cfecc1a7d75eebdcaba2ba Mon Sep 17 00:00:00 2001 From: Andrew Gray Date: Mon, 14 Aug 2023 10:28:58 -0700 Subject: [PATCH 13/33] GEOPY-882 tell github action to activate the conda env it just created? --- .github/workflows/pytest-windows.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/pytest-windows.yaml b/.github/workflows/pytest-windows.yaml index 248fd2ae5..8b93fc657 100644 --- a/.github/workflows/pytest-windows.yaml +++ b/.github/workflows/pytest-windows.yaml @@ -47,8 +47,10 @@ jobs: with: environment-file: ${{ env.CONDA_LOCK_ENV_FILE }} environment-name: test_env + activate-environment: test_env cache-downloads: true - name: pytest + shell: shell: bash -l {0} run: | pytest --cov=${source_dir} --cov-report=xml --cov-branch - name: Codecov From e2f28992282a74000bda8039c4f6ad02836e2fec Mon Sep 17 00:00:00 2001 From: Andrew Gray Date: Mon, 14 Aug 2023 11:13:56 -0700 Subject: [PATCH 14/33] GEOPY-882 remove incorrect shell --- .github/workflows/pytest-windows.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/pytest-windows.yaml b/.github/workflows/pytest-windows.yaml index 8b93fc657..4e31fb3ef 100644 --- a/.github/workflows/pytest-windows.yaml +++ b/.github/workflows/pytest-windows.yaml @@ -50,7 +50,6 @@ jobs: activate-environment: test_env cache-downloads: true - name: pytest - shell: shell: bash -l {0} run: | pytest --cov=${source_dir} --cov-report=xml --cov-branch - name: Codecov From 2279ac466b71b9d35b596ba15b4683e9997cad65 Mon Sep 17 00:00:00 2001 From: Andrew Gray Date: Mon, 14 Aug 2023 11:38:10 -0700 Subject: [PATCH 15/33] GEOPY-882 specify shell --- .github/workflows/pytest-windows.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pytest-windows.yaml b/.github/workflows/pytest-windows.yaml index 4e31fb3ef..b283ca92d 100644 --- a/.github/workflows/pytest-windows.yaml +++ b/.github/workflows/pytest-windows.yaml @@ -50,6 +50,7 @@ jobs: activate-environment: test_env cache-downloads: true - name: pytest + shell: powershell run: | pytest --cov=${source_dir} --cov-report=xml --cov-branch - name: Codecov From 1a824c76fa5a46899f387fc67cffe9cb761013e4 Mon Sep 17 00:00:00 2001 From: Andrew Gray Date: Mon, 14 Aug 2023 11:53:08 -0700 Subject: [PATCH 16/33] GEOPY-882 specify init-shell --- .github/workflows/pytest-windows.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/pytest-windows.yaml b/.github/workflows/pytest-windows.yaml index b283ca92d..c412410bc 100644 --- a/.github/workflows/pytest-windows.yaml +++ b/.github/workflows/pytest-windows.yaml @@ -47,10 +47,9 @@ jobs: with: environment-file: ${{ env.CONDA_LOCK_ENV_FILE }} environment-name: test_env - activate-environment: test_env + init-shell: powershell cache-downloads: true - name: pytest - shell: powershell run: | pytest --cov=${source_dir} --cov-report=xml --cov-branch - name: Codecov From 0bcca1b183e2539d3320adbe260dffafb0dbca24 Mon Sep 17 00:00:00 2001 From: Andrew Gray Date: Wed, 20 Sep 2023 09:53:58 -0700 Subject: [PATCH 17/33] GEOPY-1058 migrate to setup-micromamba in github workflows --- .github/workflows/create_env_file.yml | 4 ++-- .github/workflows/pytest-unix-os.yaml | 2 +- .github/workflows/static-analysis.yml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/create_env_file.yml b/.github/workflows/create_env_file.yml index 3d3b03bb0..387ad2cf1 100644 --- a/.github/workflows/create_env_file.yml +++ b/.github/workflows/create_env_file.yml @@ -34,13 +34,13 @@ jobs: SHORT_SHA=${GITHUB_SHA:0:8} echo "git_ref_suffix=${REF_NAME}-${SHORT_SHA}" >> $GITHUB_OUTPUT - name: Activate conda base env - uses: mamba-org/provision-with-micromamba@main + uses: mamba-org/setup-micromamba@v1 with: environment-file: environments\env-python-${{ env.python_ver }}.yml environment-name: conda-lock cache-downloads: true cache-env: true - extra-specs: conda-lock + create-args: conda-lock channels: conda-forge - name: Create env file id: create-env-file diff --git a/.github/workflows/pytest-unix-os.yaml b/.github/workflows/pytest-unix-os.yaml index b4a45dbbf..0bb98d2df 100644 --- a/.github/workflows/pytest-unix-os.yaml +++ b/.github/workflows/pytest-unix-os.yaml @@ -44,7 +44,7 @@ jobs: with: lfs: true - name: Setup conda env - uses: mamba-org/provision-with-micromamba@main + uses: mamba-org/setup-micromamba@v1 with: environment-file: ${{ env.CONDA_LOCK_ENV_FILE }} environment-name: test_env diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 8ef8a2124..7e9ea3933 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -37,7 +37,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: Setup conda env - uses: mamba-org/provision-with-micromamba@main + uses: mamba-org/setup-micromamba@v1 with: environment-file: ${{ env.CONDA_LOCK_ENV_FILE }} environment-name: linter_env From c6294c80cb2c2f8f20aab5d3a184a97560b08ddd Mon Sep 17 00:00:00 2001 From: Andrew Gray Date: Fri, 29 Sep 2023 06:47:11 -0700 Subject: [PATCH 18/33] GEOPY-1083 run pylint on ubuntu --- .github/workflows/static-analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 7e9ea3933..c9c4466ce 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -26,7 +26,7 @@ env: jobs: pylint: name: pylint - runs-on: windows-latest + runs-on: ubuntu-latest defaults: run: shell: bash -l {0} From fe1ed8ee25f2becb09974fbaabb471e9aa0bd5e0 Mon Sep 17 00:00:00 2001 From: Andrew Gray Date: Fri, 29 Sep 2023 07:13:32 -0700 Subject: [PATCH 19/33] GEOPY-1083 static-analysys: use linux lock file --- .github/workflows/static-analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index c9c4466ce..1d3a4c3ee 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -32,7 +32,7 @@ jobs: shell: bash -l {0} env: PYTHONUTF8: 1 - CONDA_LOCK_ENV_FILE: environments/conda-py-3.9-win-64-dev.lock.yml + CONDA_LOCK_ENV_FILE: environments/conda-py-3.9-linux-64-dev.lock.yml PIP_EXTRA_INDEX_URL: https://test.pypi.org/simple/ steps: - uses: actions/checkout@v3 From d05343709b378a070fa4f8af5d15ccdb3c40c6ff Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 2 Oct 2023 20:39:22 +0000 Subject: [PATCH 20/33] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 23.7.0 → 23.9.1](https://github.com/psf/black/compare/23.7.0...23.9.1) - [github.com/asottile/pyupgrade: v3.10.1 → v3.13.0](https://github.com/asottile/pyupgrade/compare/v3.10.1...v3.13.0) - [github.com/rstcheck/rstcheck: v6.1.2 → v6.2.0](https://github.com/rstcheck/rstcheck/compare/v6.1.2...v6.2.0) --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7ede0a341..20390c8ff 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ ci: repos: - repo: https://github.com/psf/black - rev: 23.7.0 + rev: 23.9.1 hooks: - id: black - repo: https://github.com/PyCQA/isort @@ -29,7 +29,7 @@ repos: # hooks: # - id: flake8 - repo: https://github.com/asottile/pyupgrade - rev: v3.10.1 + rev: v3.13.0 hooks: - id: pyupgrade args: [--py39-plus] @@ -83,7 +83,7 @@ repos: - id: mixed-line-ending - id: name-tests-test - repo: https://github.com/rstcheck/rstcheck - rev: v6.1.2 + rev: v6.2.0 hooks: - id: rstcheck exclude: ^THIRD_PARTY_SOFTWARE.rst$ From 51a85ba031b8bd9318e24a857a384f778ba3ba4d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 1 Oct 2023 11:09:43 +0000 Subject: [PATCH 21/33] Bump actions/checkout from 3 to 4 Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/create_env_file.yml | 6 +++--- .github/workflows/pytest-unix-os.yaml | 2 +- .github/workflows/pytest-windows.yaml | 2 +- .github/workflows/static-analysis.yml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/create_env_file.yml b/.github/workflows/create_env_file.yml index 387ad2cf1..5eac9037c 100644 --- a/.github/workflows/create_env_file.yml +++ b/.github/workflows/create_env_file.yml @@ -26,7 +26,7 @@ jobs: full_env_file: ${{ steps.create-env-file.outputs.full_env_file }} artifact: ${{ env.ARTIFACT_NAME }}.${{ steps.git-info.outputs.git_ref_suffix }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: git info id: git-info run: | @@ -63,7 +63,7 @@ jobs: outputs: release_id: ${{ steps.create-release.outputs.release_id }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Create draft release id: create-release env: @@ -85,7 +85,7 @@ jobs: if: ${{ needs.create-env-file.outputs.releaseFullEnv == true }} runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/download-artifact@v3 with: name: ${{ needs.create-env-file.outputs.artifact }} diff --git a/.github/workflows/pytest-unix-os.yaml b/.github/workflows/pytest-unix-os.yaml index 0bb98d2df..ad800e30a 100644 --- a/.github/workflows/pytest-unix-os.yaml +++ b/.github/workflows/pytest-unix-os.yaml @@ -40,7 +40,7 @@ jobs: CONDA_LOCK_ENV_FILE: environments/conda-py-${{ matrix.python_ver }}-${{ startsWith(matrix.os, 'macos') && 'osx' || 'linux' }}-64-dev.lock.yml PIP_EXTRA_INDEX_URL: https://test.pypi.org/simple/ steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: lfs: true - name: Setup conda env diff --git a/.github/workflows/pytest-windows.yaml b/.github/workflows/pytest-windows.yaml index c412410bc..9d8dff5b5 100644 --- a/.github/workflows/pytest-windows.yaml +++ b/.github/workflows/pytest-windows.yaml @@ -39,7 +39,7 @@ jobs: CONDA_LOCK_ENV_FILE: environments/conda-py-${{ matrix.python_ver }}-win-64-dev.lock.yml PIP_EXTRA_INDEX_URL: https://test.pypi.org/simple/ steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: lfs: true - name: Setup conda env diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 1d3a4c3ee..99edd0f5d 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -35,7 +35,7 @@ jobs: CONDA_LOCK_ENV_FILE: environments/conda-py-3.9-linux-64-dev.lock.yml PIP_EXTRA_INDEX_URL: https://test.pypi.org/simple/ steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup conda env uses: mamba-org/setup-micromamba@v1 with: From 0e79eb1392cd56f2091a5cc7bafa7157ff551278 Mon Sep 17 00:00:00 2001 From: jamiefb Date: Tue, 31 Oct 2023 15:50:12 -0700 Subject: [PATCH 22/33] add diagonal_balance to uijson --- geoapps/octree_creation/constants.py | 6 +++++ geoapps/octree_creation/driver.py | 35 +++++++++++++++++++++++----- geoapps/octree_creation/params.py | 9 +++++++ 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/geoapps/octree_creation/constants.py b/geoapps/octree_creation/constants.py index 15b19dac7..5b26272d4 100644 --- a/geoapps/octree_creation/constants.py +++ b/geoapps/octree_creation/constants.py @@ -99,6 +99,12 @@ "main": True, "value": 500.0, }, + "diagonal_balance": { + "group": "Basic", + "label": "UBC Compatible", + "main": True, + "value": False, + }, "minimum_level": { "enabled": True, "group": "Basic", diff --git a/geoapps/octree_creation/driver.py b/geoapps/octree_creation/driver.py index 466ad9377..322ad0e74 100644 --- a/geoapps/octree_creation/driver.py +++ b/geoapps/octree_creation/driver.py @@ -65,7 +65,9 @@ def octree_from_params(params: OctreeParams): depth_core=params.depth_core, ) minimum_level = OctreeDriver.minimum_level(mesh, params.minimum_level) - mesh.refine(minimum_level, finalize=False) + mesh.refine( + minimum_level, finalize=False, diagonal_balance=params.diagonal_balance + ) for label, value in params.free_parameter_dict.items(): refinement_object = getattr(params, value["object"]) @@ -77,12 +79,12 @@ def octree_from_params(params: OctreeParams): if isinstance(refinement_object, Curve): mesh = OctreeDriver.refine_tree_from_curve( - mesh, refinement_object, levels + mesh, refinement_object, levels, params.diagonal_balance ) elif isinstance(refinement_object, Surface): mesh = OctreeDriver.refine_tree_from_triangulation( - mesh, refinement_object, levels + mesh, refinement_object, levels, params.diagonal_balance ) elif getattr(params, value["type"]) == "surface": @@ -90,6 +92,7 @@ def octree_from_params(params: OctreeParams): mesh, refinement_object, levels, + params.diagonal_balance, max_distance=getattr(params, value["distance"]), ) @@ -98,6 +101,7 @@ def octree_from_params(params: OctreeParams): mesh, refinement_object, levels, + diagonal_balance=params.diagonal_balance, ) else: @@ -116,6 +120,7 @@ def refine_tree_from_curve( mesh: TreeMesh, curve: Curve, levels: list[int] | np.ndarray, + diagonal_balance: bool, finalize: bool = False, ) -> TreeMesh: """ @@ -126,6 +131,7 @@ def refine_tree_from_curve( :param curve: Curve object to use for refinement. :param levels: Number of cells requested at each refinement level. Defined in reversed order from the highest octree to lowest. + :param diagonal_balance: Whether to balance cells along the diagonal of the tree during construction. :param finalize: Finalize the tree mesh after refinement. """ @@ -137,7 +143,7 @@ def refine_tree_from_curve( locations = densify_curve(curve, mesh.h[0][0]) mesh = OctreeDriver.refine_tree_from_points( - mesh, locations, levels, finalize=False + mesh, locations, levels, diagonal_balance=diagonal_balance, finalize=False ) if finalize: @@ -150,6 +156,7 @@ def refine_tree_from_points( mesh: TreeMesh, points: ObjectBase | np.ndarray, levels: list[int] | np.ndarray, + diagonal_balance: bool, finalize: bool = False, ) -> TreeMesh: """ @@ -159,6 +166,7 @@ def refine_tree_from_points( :param points: Object to use for refinement. :param levels: Number of cells requested at each refinement level. Defined in reversed order from the highest octree to lowest. + :param diagonal_balance: Whether to balance cells along the diagonal of the tree during construction. :param finalize: Finalize the tree mesh after refinement. :return: Refined tree mesh. @@ -177,7 +185,13 @@ def refine_tree_from_points( distance = 0 for ii, n_cells in enumerate(levels): distance += n_cells * OctreeDriver.cell_size_from_level(mesh, ii) - mesh.refine_ball(locations, distance, mesh.max_level - ii, finalize=False) + mesh.refine_ball( + locations, + distance, + mesh.max_level - ii, + diagonal_balance=diagonal_balance, + finalize=False, + ) if finalize: mesh.finalize() @@ -189,6 +203,7 @@ def refine_tree_from_surface( mesh: TreeMesh, surface: ObjectBase, levels: list[int] | np.ndarray, + diagonal_balance: bool, max_distance: float = np.inf, finalize: bool = False, ) -> TreeMesh: @@ -200,6 +215,7 @@ def refine_tree_from_surface( :param levels: Number of cells requested at each refinement level. Defined in reversed order from the highest octree to lowest. :param max_distance: Maximum distance from the surface to refine. + :param diagonal_balance: Whether to balance cells along the diagonal of the tree during construction. :param finalize: Finalize the tree mesh after refinement. :return: Refined tree mesh. @@ -247,6 +263,7 @@ def refine_tree_from_surface( mesh.insert_cells( np.c_[xy[keeper], elevation - depth], np.ones(nnz) * mesh.max_level - ind, + diagonal_balance=diagonal_balance, finalize=False, ) @@ -257,7 +274,11 @@ def refine_tree_from_surface( @staticmethod def refine_tree_from_triangulation( - mesh: TreeMesh, surface, levels: list[int] | np.ndarray, finalize=False + mesh: TreeMesh, + surface, + levels: list[int] | np.ndarray, + diagonal_balance: bool, + finalize=False, ) -> TreeMesh: """ Refine a tree mesh along the simplicies of a surface. @@ -266,6 +287,7 @@ def refine_tree_from_triangulation( :param surface: Surface object to use for refinement. :param levels: Number of cells requested at each refinement level. Defined in reversed order from highest octree to lowest. + :param diagonal_balance: Whether to balance cells along the diagonal of the tree during construction. :param finalize: Finalize the tree mesh after refinement. :return: Refined tree mesh. @@ -290,6 +312,7 @@ def refine_tree_from_triangulation( (surface.vertices, surface.cells), -ind[0] - 1, paddings, + diagonal_balance=diagonal_balance, finalize=finalize, ) return mesh diff --git a/geoapps/octree_creation/params.py b/geoapps/octree_creation/params.py index 84ccea33d..980194239 100644 --- a/geoapps/octree_creation/params.py +++ b/geoapps/octree_creation/params.py @@ -31,6 +31,7 @@ def __init__(self, input_file=None, **kwargs): self._u_cell_size = None self._v_cell_size = None self._w_cell_size = None + self._diagonal_balance = None self._minimum_level = None self._horizontal_padding = None self._vertical_padding = None @@ -143,6 +144,14 @@ def depth_core(self): def depth_core(self, val): self.setter_validator("depth_core", val) + @property + def diagonal_balance(self): + return self._diagonal_balance + + @diagonal_balance.setter + def diagonal_balance(self, val): + self.setter_validator("diagonal_balance", val) + @property def minimum_level(self): return self._minimum_level From c483a790d4b7dc2448daccf327c6ff77077e30b3 Mon Sep 17 00:00:00 2001 From: jamiefb Date: Wed, 1 Nov 2023 11:07:57 -0700 Subject: [PATCH 23/33] test passing visually --- tests/run_tests/octree_creation_test.py | 68 +++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 3 deletions(-) diff --git a/tests/run_tests/octree_creation_test.py b/tests/run_tests/octree_creation_test.py index fc9c26e33..378f58aa9 100644 --- a/tests/run_tests/octree_creation_test.py +++ b/tests/run_tests/octree_creation_test.py @@ -19,6 +19,7 @@ from scipy.spatial import Delaunay from geoapps.driver_base.utils import treemesh_2_octree +from geoapps.octree_creation import OctreeParams from geoapps.octree_creation.application import OctreeDriver, OctreeMesh from geoapps.utils.testing import get_output_workspace @@ -88,6 +89,7 @@ def test_create_octree_radial(tmp_path: Path, setup_test_octree): treemesh, points, str2list(refinement), + diagonal_balance=False, finalize=True, ) octree = treemesh_2_octree(workspace, treemesh, name="Octree_Mesh") @@ -139,11 +141,16 @@ def test_create_octree_curve(tmp_path: Path, setup_test_octree): with Workspace.create(tmp_path / "testOctree.geoh5") as workspace: curve = Curve.create(workspace, vertices=locations) curve.remove_cells([-1]) - treemesh.refine(treemesh.max_level - minimum_level + 1, finalize=False) + treemesh.refine( + treemesh.max_level - minimum_level + 1, + diagonal_balance=False, + finalize=False, + ) treemesh = OctreeDriver.refine_tree_from_curve( treemesh, curve, str2list(refinement), + diagonal_balance=False, finalize=True, ) octree = treemesh_2_octree(workspace, treemesh, name="Octree_Mesh") @@ -191,11 +198,16 @@ def test_create_octree_surface(tmp_path: Path, setup_test_octree): with Workspace.create(tmp_path / "testOctree.geoh5") as workspace: points = Points.create(workspace, vertices=locations) - treemesh.refine(treemesh.max_level - minimum_level + 1, finalize=False) + treemesh.refine( + treemesh.max_level - minimum_level + 1, + diagonal_balance=False, + finalize=False, + ) treemesh = OctreeDriver.refine_tree_from_surface( treemesh, points, str2list(refinement), + diagonal_balance=False, finalize=True, ) octree = treemesh_2_octree(workspace, treemesh, name="Octree_Mesh") @@ -270,11 +282,16 @@ def test_create_octree_triangulation(tmp_path: Path, setup_test_octree): vertices=np.c_[x.flatten(), y.flatten(), z.flatten()], cells=surf.simplices, ) - treemesh.refine(treemesh.max_level - minimum_level + 1, finalize=False) + treemesh.refine( + treemesh.max_level - minimum_level + 1, + diagonal_balance=False, + finalize=False, + ) treemesh = OctreeDriver.refine_tree_from_triangulation( treemesh, sphere, str2list(refinement), + diagonal_balance=False, finalize=True, ) octree = treemesh_2_octree(workspace, treemesh, name="Octree_Mesh") @@ -306,3 +323,48 @@ def test_create_octree_triangulation(tmp_path: Path, setup_test_octree): with Workspace(get_output_workspace(tmp_path)) as workspace: rec_octree = workspace.get_entity("Octree_Mesh")[0] compare_entities(octree, rec_octree, ignore=["_uid"]) + + +def test_octree_diagonal_balance(tmp_path: Path): + # Create temp workspace + with Workspace(tmp_path / "testOctree.geoh5") as workspace: + points = Points.create(workspace, vertices=np.array([[150, 0, 150], [0, 0, 0]])) + + # Repeat the creation using the app + params_dict = { + "geoh5": workspace, + "objects": str(points.uid), + "u_cell_size": 10.0, + "v_cell_size": 10.0, + "w_cell_size": 10.0, + "horizontal_padding": 500.0, + "vertical_padding": 200.0, + "depth_core": 400.0, + "Refinement A object": points.uid, + "Refinement A levels": "1", + "Refinement A type": "radial", + "Refinement A distance": 200, + } + + diag_true_params = OctreeParams( + **params_dict, diagonal_balance=True, ga_group_name="diag_true_mesh" + ) + diag_false_params = OctreeParams( + **params_dict, diagonal_balance=False, ga_group_name="diag_false_mesh" + ) + + diag_true_filename = "diag_balance_true.ui.json" + diag_false_filename = "diag_balance_false.ui.json" + diag_true_params.write_input_file( + name=diag_true_filename, path=tmp_path, validate=False + ) + diag_false_params.write_input_file( + name=diag_false_filename, path=tmp_path, validate=False + ) + + OctreeDriver.start(tmp_path / diag_true_filename) + OctreeDriver.start(tmp_path / diag_false_filename) + + with workspace.open(mode="r"): + diag_true_results = workspace.get_entity("diag_true_mesh") + diag_false_results = workspace.get_entity("diag_false_mesh") From e8961b70790d52fd4eb15d9a94da393d7a15fe9a Mon Sep 17 00:00:00 2001 From: jamiefb Date: Wed, 1 Nov 2023 13:48:04 -0700 Subject: [PATCH 24/33] update tests, add diagonal_balance to notebook --- geoapps/octree_creation/application.py | 45 +++++++++++++++++++++--- geoapps/utils/testing.py | 2 ++ tests/run_tests/octree_creation_test.py | 46 +++++++++++++++++++++---- 3 files changed, 83 insertions(+), 10 deletions(-) diff --git a/geoapps/octree_creation/application.py b/geoapps/octree_creation/application.py index d6167f700..85391769e 100644 --- a/geoapps/octree_creation/application.py +++ b/geoapps/octree_creation/application.py @@ -23,13 +23,23 @@ from geoapps.base.application import BaseApplication from geoapps.base.selection import ObjectDataSelection +from geoapps.octree_creation.constants import app_initializer +from geoapps.octree_creation.driver import OctreeDriver +from geoapps.octree_creation.params import OctreeParams from geoapps.utils import warn_module_not_found -from . import OctreeParams, app_initializer -from .driver import OctreeDriver - with warn_module_not_found(): - from ipywidgets import Dropdown, FloatText, Label, Layout, Text, VBox, Widget + from ipywidgets import ( + Checkbox, + Dropdown, + FloatText, + IntText, + Label, + Layout, + Text, + VBox, + Widget, + ) from ipywidgets.widgets.widget_selection import TraitError @@ -46,6 +56,8 @@ class OctreeMesh(ObjectDataSelection): _depth_core = None _horizontal_padding = None _vertical_padding = None + _diagonal_balance = None + _minimum_level = None def __init__(self, ui_json=None, **kwargs): app_initializer.update(kwargs) @@ -79,6 +91,9 @@ def __init__(self, ui_json=None, **kwargs): Label("Padding distance"), self.horizontal_padding, self.vertical_padding, + Label("Basic"), + self.diagonal_balance, + self.minimum_level, ], layout=Layout(border="solid"), ), @@ -180,6 +195,28 @@ def vertical_padding(self) -> FloatText: ) return self._vertical_padding + @property + def diagonal_balance(self) -> Checkbox: + """ + Widget controlling the diagonal balance. + """ + if getattr(self, "_diagonal_balance", None) is None: + self._diagonal_balance = Checkbox( + description="UBC compatible", + ) + return self._diagonal_balance + + @property + def minimum_level(self) -> IntText: + """ + Widget controlling the minimum refinement level. + """ + if getattr(self, "_minimum_level", None) is None: + self._minimum_level = IntText( + description="Minimum refinement level", + ) + return self._minimum_level + @property def workspace(self): """ diff --git a/geoapps/utils/testing.py b/geoapps/utils/testing.py index 81a5ef52e..9304aa0df 100644 --- a/geoapps/utils/testing.py +++ b/geoapps/utils/testing.py @@ -417,6 +417,7 @@ def topo_drape(x, y): mesh, topography, levels=refinement, + diagonal_balance=False, finalize=False, ) @@ -425,6 +426,7 @@ def topo_drape(x, y): mesh, vertices, levels=[2], + diagonal_balance=False, finalize=False, ) diff --git a/tests/run_tests/octree_creation_test.py b/tests/run_tests/octree_creation_test.py index 378f58aa9..6066e4cca 100644 --- a/tests/run_tests/octree_creation_test.py +++ b/tests/run_tests/octree_creation_test.py @@ -21,6 +21,7 @@ from geoapps.driver_base.utils import treemesh_2_octree from geoapps.octree_creation import OctreeParams from geoapps.octree_creation.application import OctreeDriver, OctreeMesh +from geoapps.shared_utils.utils import octree_2_treemesh from geoapps.utils.testing import get_output_workspace # pylint: disable=redefined-outer-name @@ -326,9 +327,10 @@ def test_create_octree_triangulation(tmp_path: Path, setup_test_octree): def test_octree_diagonal_balance(tmp_path: Path): - # Create temp workspace - with Workspace(tmp_path / "testOctree.geoh5") as workspace: - points = Points.create(workspace, vertices=np.array([[150, 0, 150], [0, 0, 0]])) + workspace = Workspace.create(tmp_path / "testDiagonalBalance.geoh5") + with workspace.open(mode="r+"): + point = [0, 0, 0] + points = Points.create(workspace, vertices=np.array([[150, 0, 150], point])) # Repeat the creation using the app params_dict = { @@ -365,6 +367,38 @@ def test_octree_diagonal_balance(tmp_path: Path): OctreeDriver.start(tmp_path / diag_true_filename) OctreeDriver.start(tmp_path / diag_false_filename) - with workspace.open(mode="r"): - diag_true_results = workspace.get_entity("diag_true_mesh") - diag_false_results = workspace.get_entity("diag_false_mesh") + with workspace.open(mode="r"): + for name in ["diag_true_mesh", "diag_false_mesh"]: + results = [] + treemesh = octree_2_treemesh(workspace.get_entity(name)[0]) + + ind = treemesh._get_containing_cell_indexes( # pylint: disable=protected-access + point + ) + starting_cell = treemesh[ind] + + level = starting_cell._level # pylint: disable=protected-access + for first_neighbor in starting_cell.neighbors: + neighbors = [] + for neighbor in treemesh[first_neighbor].neighbors: + if isinstance(neighbor, list): + neighbors += neighbor + else: + neighbors.append(neighbor) + + for second_neighbor in neighbors: + compare_cell = treemesh[second_neighbor] + if set(starting_cell.nodes) & set(compare_cell.nodes): + results.append( + np.abs( + level + - compare_cell._level # pylint: disable=protected-access + ) + ) + + if name == "diag_true_mesh": + assert np.all(np.array(results) < 2) + elif name == "diag_false_mesh": + values, counts = np.unique(results, return_counts=True) + assert (values == np.array([0, 1, 2])).all() + assert (counts == np.array([22, 8, 2])).all() From 6c29f6fd57df2c60d8a671b7932fee1ad2f13fef Mon Sep 17 00:00:00 2001 From: jamiefb Date: Wed, 1 Nov 2023 13:59:30 -0700 Subject: [PATCH 25/33] update tests with diagonal balance --- tests/data_test.py | 1 + tests/utils_test.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/data_test.py b/tests/data_test.py index 7a2cfec7f..8f24db35a 100644 --- a/tests/data_test.py +++ b/tests/data_test.py @@ -81,6 +81,7 @@ def test_survey_data(tmp_path: Path): mesh, test_topo_object, levels=[2], + diagonal_balance=False, finalize=True, ) diff --git a/tests/utils_test.py b/tests/utils_test.py index e1b657ee7..238dc7726 100644 --- a/tests/utils_test.py +++ b/tests/utils_test.py @@ -110,13 +110,14 @@ def test_drape_to_octree(tmp_path: Path): mesh_type="TREE", ) tree = OctreeDriver.refine_tree_from_points( - tree, locs, levels=[4, 2], finalize=False + tree, locs, levels=[4, 2], diagonal_balance=False, finalize=False ) topography = Points.create(ws, vertices=topo) tree = OctreeDriver.refine_tree_from_surface( tree, topography, levels=[2, 2], + diagonal_balance=False, finalize=True, ) # interp and save common models into the octree From 3c094c1667c14a0e11f4960fb208f9c928c86482 Mon Sep 17 00:00:00 2001 From: jamiefb Date: Thu, 2 Nov 2023 10:36:01 -0700 Subject: [PATCH 26/33] default diagonal_balance true; parametrize unit test --- geoapps/octree_creation/constants.py | 2 +- geoapps/octree_creation/driver.py | 8 +-- tests/run_tests/octree_creation_test.py | 89 ++++++++++++------------- 3 files changed, 46 insertions(+), 53 deletions(-) diff --git a/geoapps/octree_creation/constants.py b/geoapps/octree_creation/constants.py index 5b26272d4..9924744a9 100644 --- a/geoapps/octree_creation/constants.py +++ b/geoapps/octree_creation/constants.py @@ -103,7 +103,7 @@ "group": "Basic", "label": "UBC Compatible", "main": True, - "value": False, + "value": True, }, "minimum_level": { "enabled": True, diff --git a/geoapps/octree_creation/driver.py b/geoapps/octree_creation/driver.py index 322ad0e74..4b7765e1e 100644 --- a/geoapps/octree_creation/driver.py +++ b/geoapps/octree_creation/driver.py @@ -120,7 +120,7 @@ def refine_tree_from_curve( mesh: TreeMesh, curve: Curve, levels: list[int] | np.ndarray, - diagonal_balance: bool, + diagonal_balance: bool = True, finalize: bool = False, ) -> TreeMesh: """ @@ -156,7 +156,7 @@ def refine_tree_from_points( mesh: TreeMesh, points: ObjectBase | np.ndarray, levels: list[int] | np.ndarray, - diagonal_balance: bool, + diagonal_balance: bool = True, finalize: bool = False, ) -> TreeMesh: """ @@ -203,7 +203,7 @@ def refine_tree_from_surface( mesh: TreeMesh, surface: ObjectBase, levels: list[int] | np.ndarray, - diagonal_balance: bool, + diagonal_balance: bool = True, max_distance: float = np.inf, finalize: bool = False, ) -> TreeMesh: @@ -277,7 +277,7 @@ def refine_tree_from_triangulation( mesh: TreeMesh, surface, levels: list[int] | np.ndarray, - diagonal_balance: bool, + diagonal_balance: bool = True, finalize=False, ) -> TreeMesh: """ diff --git a/tests/run_tests/octree_creation_test.py b/tests/run_tests/octree_creation_test.py index 6066e4cca..262ce223b 100644 --- a/tests/run_tests/octree_creation_test.py +++ b/tests/run_tests/octree_creation_test.py @@ -326,7 +326,13 @@ def test_create_octree_triangulation(tmp_path: Path, setup_test_octree): compare_entities(octree, rec_octree, ignore=["_uid"]) -def test_octree_diagonal_balance(tmp_path: Path): +@pytest.mark.parametrize( + "diagonal_balance, exp_values, exp_counts", + [(True, [0, 1], [22, 10]), (False, [0, 1, 2], [22, 8, 2])], +) +def test_octree_diagonal_balance( + tmp_path: Path, diagonal_balance, exp_values, exp_counts +): workspace = Workspace.create(tmp_path / "testDiagonalBalance.geoh5") with workspace.open(mode="r+"): point = [0, 0, 0] @@ -348,57 +354,44 @@ def test_octree_diagonal_balance(tmp_path: Path): "Refinement A distance": 200, } - diag_true_params = OctreeParams( - **params_dict, diagonal_balance=True, ga_group_name="diag_true_mesh" - ) - diag_false_params = OctreeParams( - **params_dict, diagonal_balance=False, ga_group_name="diag_false_mesh" + params = OctreeParams( + **params_dict, diagonal_balance=diagonal_balance, ga_group_name="mesh" ) + filename = "diag_balance.ui.json" - diag_true_filename = "diag_balance_true.ui.json" - diag_false_filename = "diag_balance_false.ui.json" - diag_true_params.write_input_file( - name=diag_true_filename, path=tmp_path, validate=False - ) - diag_false_params.write_input_file( - name=diag_false_filename, path=tmp_path, validate=False - ) + params.write_input_file(name=filename, path=tmp_path, validate=False) - OctreeDriver.start(tmp_path / diag_true_filename) - OctreeDriver.start(tmp_path / diag_false_filename) + OctreeDriver.start(tmp_path / filename) with workspace.open(mode="r"): - for name in ["diag_true_mesh", "diag_false_mesh"]: - results = [] - treemesh = octree_2_treemesh(workspace.get_entity(name)[0]) - - ind = treemesh._get_containing_cell_indexes( # pylint: disable=protected-access - point - ) - starting_cell = treemesh[ind] - - level = starting_cell._level # pylint: disable=protected-access - for first_neighbor in starting_cell.neighbors: - neighbors = [] - for neighbor in treemesh[first_neighbor].neighbors: - if isinstance(neighbor, list): - neighbors += neighbor - else: - neighbors.append(neighbor) - - for second_neighbor in neighbors: - compare_cell = treemesh[second_neighbor] - if set(starting_cell.nodes) & set(compare_cell.nodes): - results.append( - np.abs( - level - - compare_cell._level # pylint: disable=protected-access - ) + results = [] + treemesh = octree_2_treemesh(workspace.get_entity("mesh")[0]) + + ind = treemesh._get_containing_cell_indexes( # pylint: disable=protected-access + point + ) + starting_cell = treemesh[ind] + + level = starting_cell._level # pylint: disable=protected-access + for first_neighbor in starting_cell.neighbors: + neighbors = [] + for neighbor in treemesh[first_neighbor].neighbors: + if isinstance(neighbor, list): + neighbors += neighbor + else: + neighbors.append(neighbor) + + for second_neighbor in neighbors: + compare_cell = treemesh[second_neighbor] + if set(starting_cell.nodes) & set(compare_cell.nodes): + results.append( + np.abs( + level + - compare_cell._level # pylint: disable=protected-access ) + ) + + values, counts = np.unique(results, return_counts=True) - if name == "diag_true_mesh": - assert np.all(np.array(results) < 2) - elif name == "diag_false_mesh": - values, counts = np.unique(results, return_counts=True) - assert (values == np.array([0, 1, 2])).all() - assert (counts == np.array([22, 8, 2])).all() + assert (values == np.array(exp_values)).all() + assert (counts == np.array(exp_counts)).all() From c559017de03d3264a63a8939c34b760b5861e57c Mon Sep 17 00:00:00 2001 From: dominiquef Date: Thu, 2 Nov 2023 14:11:26 -0700 Subject: [PATCH 27/33] Fix tests --- tests/run_tests/octree_creation_test.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/run_tests/octree_creation_test.py b/tests/run_tests/octree_creation_test.py index 262ce223b..378f18aaf 100644 --- a/tests/run_tests/octree_creation_test.py +++ b/tests/run_tests/octree_creation_test.py @@ -116,6 +116,7 @@ def test_create_octree_radial(tmp_path: Path, setup_test_octree): w_cell_size=cell_sizes[2], horizontal_padding=horizontal_padding, vertical_padding=vertical_padding, + diagonal_balance=False, depth_core=depth_core, **refinements, ) @@ -175,6 +176,7 @@ def test_create_octree_curve(tmp_path: Path, setup_test_octree): horizontal_padding=horizontal_padding, vertical_padding=vertical_padding, depth_core=depth_core, + diagonal_balance=False, **refinements, ) app.trigger_click(None) @@ -235,6 +237,7 @@ def test_create_octree_surface(tmp_path: Path, setup_test_octree): horizontal_padding=horizontal_padding, vertical_padding=vertical_padding, depth_core=depth_core, + diagonal_balance=False, **refinements, ) app.trigger_click(None) From d58c460b98edae6b224b5b9058f0649b7e13b54c Mon Sep 17 00:00:00 2001 From: dominiquef Date: Mon, 18 Dec 2023 16:38:48 -0800 Subject: [PATCH 28/33] Create copy of models --- geoapps/inversion/components/models.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/geoapps/inversion/components/models.py b/geoapps/inversion/components/models.py index 5567bf828..88b79d93e 100644 --- a/geoapps/inversion/components/models.py +++ b/geoapps/inversion/components/models.py @@ -115,16 +115,17 @@ def active_cells(self, active_cells): @property def starting(self): - mstart = self._starting.model + mstart = self._starting.model.copy() if mstart is not None and self.is_sigma: + mstart = mstart.copy() mstart = np.log(mstart) return mstart @property def reference(self): - mref = self._reference.model + mref = self._reference.model.copy() if self.driver.params.forward_only: return mref @@ -132,11 +133,13 @@ def reference(self): if mref is None: mref = self.starting self.driver.params.alpha_s = 0.0 - elif self.is_sigma & (all(mref == 0)): - mref = self.starting - self.driver.params.alpha_s = 0.0 else: - mref = np.log(mref) if self.is_sigma else mref + mref = mref.copy() + if self.is_sigma & (all(mref == 0)): + mref = self.starting + self.driver.params.alpha_s = 0.0 + else: + mref = np.log(mref) if self.is_sigma else mref return mref @property @@ -146,6 +149,8 @@ def lower_bound(self): if lbound is None: return -np.inf + lbound = lbound.copy() + if self.is_sigma: is_finite = np.isfinite(lbound) lbound[is_finite] = np.log(lbound[is_finite]) @@ -158,6 +163,7 @@ def upper_bound(self): if ubound is None: return np.inf + ubound = ubound.copy() if self.is_sigma: is_finite = np.isfinite(ubound) ubound[is_finite] = np.log(ubound[is_finite]) @@ -169,6 +175,7 @@ def conductivity(self): mstart = self._conductivity.model if mstart is not None and self.is_sigma: + mstart = mstart.copy() mstart = np.log(mstart) return mstart From dd070365b0c609250a4fac07bb6f73ad6aa9fa84 Mon Sep 17 00:00:00 2001 From: dominiquef Date: Mon, 18 Dec 2023 16:39:50 -0800 Subject: [PATCH 29/33] Fix issue with lagging workspace_geoh5 --- geoapps/inversion/joint/driver.py | 1 + 1 file changed, 1 insertion(+) diff --git a/geoapps/inversion/joint/driver.py b/geoapps/inversion/joint/driver.py index 6a6e9ee68..7be9f987e 100644 --- a/geoapps/inversion/joint/driver.py +++ b/geoapps/inversion/joint/driver.py @@ -69,6 +69,7 @@ def drivers(self) -> list[InversionDriver] | None: group = self.workspace.get_entity(group.uid)[0] ui_json = group.options ui_json["geoh5"] = self.workspace + ui_json["workspace_geoh5"] = None ifile = InputFile(ui_json=ui_json) mod_name, class_name = DRIVER_MAP.get(ifile.data["inversion_type"]) From 621ff71564c675f1a9a821796fb1a1abcbfb9be3 Mon Sep 17 00:00:00 2001 From: dominiquef Date: Wed, 3 Jan 2024 15:16:04 -0800 Subject: [PATCH 30/33] Update years --- LICENSE | 2 +- README.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/LICENSE b/LICENSE index 63604bb9b..814813801 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2023 Mira Geoscience +Copyright (c) 2024 Mira Geoscience Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.rst b/README.rst index e03c00f88..714c8cd7d 100644 --- a/README.rst +++ b/README.rst @@ -79,7 +79,7 @@ License ^^^^^^^ MIT License -Copyright (c) 2023 Mira Geoscience +Copyright (c) 2024 Mira Geoscience Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From cae3ab6808ec337609110ca4940a194a2bd45d98 Mon Sep 17 00:00:00 2001 From: dominiquef Date: Thu, 11 Jan 2024 11:31:06 -0800 Subject: [PATCH 31/33] Remove redundant copies --- geoapps/inversion/components/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/geoapps/inversion/components/models.py b/geoapps/inversion/components/models.py index 213b80704..64a2c6b38 100644 --- a/geoapps/inversion/components/models.py +++ b/geoapps/inversion/components/models.py @@ -115,7 +115,7 @@ def active_cells(self, active_cells): @property def starting(self): - mstart = self._starting.model.copy() + mstart = self._starting.model if mstart is not None and self.is_sigma: mstart = mstart.copy() @@ -125,7 +125,7 @@ def starting(self): @property def reference(self): - mref = self._reference.model.copy() + mref = self._reference.model if self.driver.params.forward_only: return mref From c1567f5d65dbbf9345f2a17b9ba98035bd897fb0 Mon Sep 17 00:00:00 2001 From: dominiquef Date: Mon, 29 Jan 2024 15:13:58 -0800 Subject: [PATCH 32/33] Update and fix assigned log values --- geoapps/inversion/components/models.py | 52 ++++++++++--------- .../inversion/joint/joint_surveys/driver.py | 3 ++ 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/geoapps/inversion/components/models.py b/geoapps/inversion/components/models.py index 64a2c6b38..eb0043ab1 100644 --- a/geoapps/inversion/components/models.py +++ b/geoapps/inversion/components/models.py @@ -114,42 +114,43 @@ def active_cells(self, active_cells): self._active_cells = active_cells @property - def starting(self): - mstart = self._starting.model + def starting(self) -> np.ndarray | None: + if self._starting.model is None: + return None + + mstart = self._starting.model.copy() if mstart is not None and self.is_sigma: - mstart = mstart.copy() mstart = np.log(mstart) return mstart @property - def reference(self): + def reference(self) -> np.ndarray | None: mref = self._reference.model if self.driver.params.forward_only: return mref if mref is None: - mref = self.starting + ref_model = self.starting self.driver.params.alpha_s = 0.0 else: - mref = mref.copy() + ref_model = mref.copy() if self.is_sigma & (all(mref == 0)): - mref = self.starting + ref_model = self.starting self.driver.params.alpha_s = 0.0 else: - mref = np.log(mref) if self.is_sigma else mref - return mref + ref_model = np.log(ref_model) if self.is_sigma else ref_model - @property - def lower_bound(self): - lbound = self._lower_bound.model + return ref_model - if lbound is None: + @property + def lower_bound(self) -> np.ndarray | None: + if self._lower_bound.model is None: return -np.inf - lbound = lbound.copy() + lbound = self._lower_bound.model.copy() if self.is_sigma: is_finite = np.isfinite(lbound) @@ -157,13 +158,12 @@ def lower_bound(self): return lbound @property - def upper_bound(self): - ubound = self._upper_bound.model - - if ubound is None: + def upper_bound(self) -> np.ndarray | None: + if self._upper_bound.model is None: return np.inf - ubound = ubound.copy() + ubound = self._upper_bound.model.copy() + if self.is_sigma: is_finite = np.isfinite(ubound) ubound[is_finite] = np.log(ubound[is_finite]) @@ -171,14 +171,16 @@ def upper_bound(self): return ubound @property - def conductivity(self): - mstart = self._conductivity.model + def conductivity(self) -> np.ndarray | None: + if self._conductivity.model is None: + return None - if mstart is not None and self.is_sigma: - mstart = mstart.copy() - mstart = np.log(mstart) + cond_model = self._conductivity.model.copy() - return mstart + if cond_model is not None and self.is_sigma: + cond_model = np.log(cond_model) + + return cond_model def _initialize(self, driver): self.driver = driver diff --git a/geoapps/inversion/joint/joint_surveys/driver.py b/geoapps/inversion/joint/joint_surveys/driver.py index ff7acbb42..46aab255b 100644 --- a/geoapps/inversion/joint/joint_surveys/driver.py +++ b/geoapps/inversion/joint/joint_surveys/driver.py @@ -47,6 +47,9 @@ def validate_create_models(self): norm = np.array(np.sum(projection, axis=1)).flatten() model = (projection * model_local_values) / (norm + 1e-8) + if self.drivers[0].models.is_sigma: + model = np.exp(model) + setattr( getattr(self.models, f"_{model_type}"), "model", From e53da5c9e6d0dc316083fd94baef0755850171f7 Mon Sep 17 00:00:00 2001 From: dominiquef Date: Tue, 30 Jan 2024 11:31:17 -0800 Subject: [PATCH 33/33] Simplify logic --- geoapps/inversion/components/models.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/geoapps/inversion/components/models.py b/geoapps/inversion/components/models.py index eb0043ab1..ef6f4e74a 100644 --- a/geoapps/inversion/components/models.py +++ b/geoapps/inversion/components/models.py @@ -132,16 +132,12 @@ def reference(self) -> np.ndarray | None: if self.driver.params.forward_only: return mref - if mref is None: - ref_model = self.starting + if mref is None or (self.is_sigma and all(mref == 0)): + mref = self.starting self.driver.params.alpha_s = 0.0 - else: - ref_model = mref.copy() - if self.is_sigma & (all(mref == 0)): - ref_model = self.starting - self.driver.params.alpha_s = 0.0 - else: - ref_model = np.log(ref_model) if self.is_sigma else ref_model + + ref_model = mref.copy() + ref_model = np.log(ref_model) if self.is_sigma else ref_model return ref_model