From e6b182ab445a7855723aa8e07b89e2d3fdfe646d Mon Sep 17 00:00:00 2001 From: Noelle Cheng Date: Sun, 8 Jun 2025 10:20:06 +0800 Subject: [PATCH 01/16] make workflow runs on all pushes --- .github/workflows/linting_and_testing.yml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/.github/workflows/linting_and_testing.yml b/.github/workflows/linting_and_testing.yml index c8c89126..aeb1a206 100644 --- a/.github/workflows/linting_and_testing.yml +++ b/.github/workflows/linting_and_testing.yml @@ -2,19 +2,6 @@ name: Linting and Testing on: push: - branches: - - master - paths: - - '**.py' - - .github/workflows/linting_and_testing.yml - - pull_request: - branches: - - master - paths: - - '**.py' - - .github/workflows/linting_and_testing.yml - workflow_dispatch: jobs: linting: From 1b8f33641eac4ebfb377b6881c0046c9aae03472 Mon Sep 17 00:00:00 2001 From: Noelle Cheng Date: Sun, 8 Jun 2025 13:54:20 +0800 Subject: [PATCH 02/16] replace dwithin --- map2loop/thickness_calculator.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/map2loop/thickness_calculator.py b/map2loop/thickness_calculator.py index 5d7844d8..8072d580 100644 --- a/map2loop/thickness_calculator.py +++ b/map2loop/thickness_calculator.py @@ -365,7 +365,8 @@ def compute( # calculate the length of the shortest line line_length = scipy.spatial.distance.euclidean(p1, p2) # find the indices of the points that are within 5% of the length of the shortest line - indices = shapely.dwithin(short_line, interp_points, line_length * 0.25) + # indices = shapely.dwithin(short_line, interp_points, line_length * 0.25) + indices= numpy.array([shapely.distance(short_line,point)<= (line_length * 0.25) for point in interp_points]) # get the dip of the points that are within _dip = numpy.deg2rad(dip[indices]) _dips.append(_dip) From ee1864054ea058731e919eae7b8d24fc775ecef5 Mon Sep 17 00:00:00 2001 From: Noelle Cheng Date: Sun, 8 Jun 2025 16:27:34 +0800 Subject: [PATCH 03/16] fix short_line --- map2loop/thickness_calculator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/map2loop/thickness_calculator.py b/map2loop/thickness_calculator.py index 8072d580..b8cbfa3b 100644 --- a/map2loop/thickness_calculator.py +++ b/map2loop/thickness_calculator.py @@ -366,7 +366,7 @@ def compute( line_length = scipy.spatial.distance.euclidean(p1, p2) # find the indices of the points that are within 5% of the length of the shortest line # indices = shapely.dwithin(short_line, interp_points, line_length * 0.25) - indices= numpy.array([shapely.distance(short_line,point)<= (line_length * 0.25) for point in interp_points]) + indices= numpy.array([shapely.distance(short_line[0],point)<= (line_length * 0.25) for point in interp_points]) # get the dip of the points that are within _dip = numpy.deg2rad(dip[indices]) _dips.append(_dip) From 97016eca8f3b3c6a83c240d18acde352ed793684 Mon Sep 17 00:00:00 2001 From: Noelle Cheng Date: Sun, 8 Jun 2025 16:52:20 +0800 Subject: [PATCH 04/16] fix dependency file path and handle >= version condition in check_all_dependencies --- map2loop/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/map2loop/__init__.py b/map2loop/__init__.py index d7ccac11..8723f4ef 100644 --- a/map2loop/__init__.py +++ b/map2loop/__init__.py @@ -30,7 +30,7 @@ class DependencyChecker: def __init__(self, package_name, dependency_file="dependencies.txt"): self.package_name = package_name - self.dependency_file = pathlib.Path(__file__).parent / dependency_file + self.dependency_file = pathlib.Path(__file__).parent.parent / dependency_file self.required_version = self.get_required_version() self.installed_version = self.get_installed_version() @@ -93,7 +93,7 @@ def check_version(self): def check_all_dependencies(dependency_file="dependencies.txt"): - dependencies_path = pathlib.Path(__file__).parent / dependency_file + dependencies_path = pathlib.Path(__file__).parent.parent / dependency_file try: with dependencies_path.open("r") as file: for line in file: @@ -103,6 +103,8 @@ def check_all_dependencies(dependency_file="dependencies.txt"): if line: if "==" in line: package_name, _ = line.split("==") + elif ">=" in line: + package_name, _ = line.split(">=") else: package_name = line From 1f429562c4c8013fe9ff7675a59a3ed3d8ae1a3f Mon Sep 17 00:00:00 2001 From: Noelle Cheng Date: Mon, 9 Jun 2025 12:51:27 +0800 Subject: [PATCH 05/16] remove gdal from dependencies.txt --- dependencies.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dependencies.txt b/dependencies.txt index 80e02915..76f0f574 100644 --- a/dependencies.txt +++ b/dependencies.txt @@ -7,5 +7,4 @@ owslib loopprojectfile==0.2.2 beartype pytest -scikit-learn -gdal \ No newline at end of file +scikit-learn \ No newline at end of file From 291cdd78c7be93f202a2762d64679e90e9736d70 Mon Sep 17 00:00:00 2001 From: Noelle Cheng Date: Mon, 9 Jun 2025 14:04:45 +0800 Subject: [PATCH 06/16] change order of dependencies --- .github/workflows/linting_and_testing.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/linting_and_testing.yml b/.github/workflows/linting_and_testing.yml index aeb1a206..c58048ed 100644 --- a/.github/workflows/linting_and_testing.yml +++ b/.github/workflows/linting_and_testing.yml @@ -40,7 +40,9 @@ jobs: - name: Install dependencies run: | conda run -n test conda info - conda run -n test conda install -c conda-forge -c loop3d --file dependencies.txt gdal python=${{ matrix.python-version }} pytest -y + conda run -n test conda install -c loop3d -c conda-forge gdal python=${{ matrix.python-version }} -y + conda run -n test conda install -c loop3d -c conda-forge --file dependencies.txt python=${{ matrix.python-version }} -y + conda run -n test conda install pytest python=${{ matrix.python-version }} -y - name: Install map2loop run: | From e6f363c58d3ea87de469361d70b71f6d75b466d5 Mon Sep 17 00:00:00 2001 From: Noelle Cheng Date: Mon, 9 Jun 2025 16:46:29 +0800 Subject: [PATCH 07/16] display gdal owslib versions --- .github/workflows/linting_and_testing.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/linting_and_testing.yml b/.github/workflows/linting_and_testing.yml index c58048ed..b057b0e7 100644 --- a/.github/workflows/linting_and_testing.yml +++ b/.github/workflows/linting_and_testing.yml @@ -44,6 +44,12 @@ jobs: conda run -n test conda install -c loop3d -c conda-forge --file dependencies.txt python=${{ matrix.python-version }} -y conda run -n test conda install pytest python=${{ matrix.python-version }} -y + - name: displace gdal owslib version + run: | + echo "${{ matrix.os }} ${{ matrix.python-version }}" + conda run -n test conda list gdal + conda run -n test conda list owslib + - name: Install map2loop run: | conda run -n test python -m pip install . From e58156da80bc4ae34cb49677ea8f4f5b8c56cee7 Mon Sep 17 00:00:00 2001 From: Noelle Cheng Date: Wed, 11 Jun 2025 21:13:56 +0800 Subject: [PATCH 08/16] fix: specify gdal 3.4.3 for windows python 3.10 --- .github/workflows/linting_and_testing.yml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/linting_and_testing.yml b/.github/workflows/linting_and_testing.yml index b057b0e7..d5906d65 100644 --- a/.github/workflows/linting_and_testing.yml +++ b/.github/workflows/linting_and_testing.yml @@ -37,18 +37,22 @@ jobs: conda-remove-defaults: "true" - - name: Install dependencies + - name: Install dependencies for windows python 3.10 + if: ${{ matrix.os == 'windows-latest' && matrix.python-version == '3.10' }} run: | conda run -n test conda info - conda run -n test conda install -c loop3d -c conda-forge gdal python=${{ matrix.python-version }} -y + conda run -n test conda install -c loop3d -c conda-forge "gdal=3.4.3" python=${{ matrix.python-version }} -y conda run -n test conda install -c loop3d -c conda-forge --file dependencies.txt python=${{ matrix.python-version }} -y conda run -n test conda install pytest python=${{ matrix.python-version }} -y - - name: displace gdal owslib version + - name: Install dependencies for other environments + if: ${{ matrix.os != 'windows-latest' || matrix.python-version != '3.10' }} run: | - echo "${{ matrix.os }} ${{ matrix.python-version }}" - conda run -n test conda list gdal - conda run -n test conda list owslib + conda run -n test conda info + conda run -n test conda install -c loop3d -c conda-forge gdal python=${{ matrix.python-version }} -y + conda run -n test conda install -c loop3d -c conda-forge --file dependencies.txt python=${{ matrix.python-version }} -y + conda run -n test conda install pytest python=${{ matrix.python-version }} -y + - name: Install map2loop run: | From 10378065d00705a2f61bb0b6dfd8d6895e633596 Mon Sep 17 00:00:00 2001 From: Noelle Cheng Date: Fri, 13 Jun 2025 18:10:29 +0800 Subject: [PATCH 09/16] print gdal owslib shapely version --- .github/workflows/linting_and_testing.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/linting_and_testing.yml b/.github/workflows/linting_and_testing.yml index d5906d65..09bc3efb 100644 --- a/.github/workflows/linting_and_testing.yml +++ b/.github/workflows/linting_and_testing.yml @@ -53,6 +53,13 @@ jobs: conda run -n test conda install -c loop3d -c conda-forge --file dependencies.txt python=${{ matrix.python-version }} -y conda run -n test conda install pytest python=${{ matrix.python-version }} -y + - name: displace gdal owslib version + run: | + echo "${{ matrix.os }} ${{ matrix.python-version }}" + conda run -n test conda list gdal + conda run -n test conda list owslib + conda run -n test python -c "from shapely import geos_version; print('geos_version: ', geos_version)" + conda run -n test python -c "import shapely; print('shapely version: ',shapely.__version__)" - name: Install map2loop run: | From 2dd81b652d3b4aaa48d7740ac6b98553376f49f6 Mon Sep 17 00:00:00 2001 From: Noelle Cheng Date: Fri, 13 Jun 2025 20:05:11 +0800 Subject: [PATCH 10/16] set gdal>=3.6.2 and shapely>=2.0.2 in dependencies.txt --- .github/workflows/linting_and_testing.yml | 12 +----------- dependencies.txt | 3 ++- map2loop/thickness_calculator.py | 3 +-- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/.github/workflows/linting_and_testing.yml b/.github/workflows/linting_and_testing.yml index 09bc3efb..a0f0ff77 100644 --- a/.github/workflows/linting_and_testing.yml +++ b/.github/workflows/linting_and_testing.yml @@ -37,19 +37,9 @@ jobs: conda-remove-defaults: "true" - - name: Install dependencies for windows python 3.10 - if: ${{ matrix.os == 'windows-latest' && matrix.python-version == '3.10' }} - run: | - conda run -n test conda info - conda run -n test conda install -c loop3d -c conda-forge "gdal=3.4.3" python=${{ matrix.python-version }} -y - conda run -n test conda install -c loop3d -c conda-forge --file dependencies.txt python=${{ matrix.python-version }} -y - conda run -n test conda install pytest python=${{ matrix.python-version }} -y - - - name: Install dependencies for other environments - if: ${{ matrix.os != 'windows-latest' || matrix.python-version != '3.10' }} + - name: Install dependencies run: | conda run -n test conda info - conda run -n test conda install -c loop3d -c conda-forge gdal python=${{ matrix.python-version }} -y conda run -n test conda install -c loop3d -c conda-forge --file dependencies.txt python=${{ matrix.python-version }} -y conda run -n test conda install pytest python=${{ matrix.python-version }} -y diff --git a/dependencies.txt b/dependencies.txt index 76f0f574..d7bd1e53 100644 --- a/dependencies.txt +++ b/dependencies.txt @@ -1,7 +1,8 @@ +gdal>=3.6.2 numpy scipy geopandas -shapely>=2 +shapely>=2.0.2 networkx owslib loopprojectfile==0.2.2 diff --git a/map2loop/thickness_calculator.py b/map2loop/thickness_calculator.py index b8cbfa3b..5d7844d8 100644 --- a/map2loop/thickness_calculator.py +++ b/map2loop/thickness_calculator.py @@ -365,8 +365,7 @@ def compute( # calculate the length of the shortest line line_length = scipy.spatial.distance.euclidean(p1, p2) # find the indices of the points that are within 5% of the length of the shortest line - # indices = shapely.dwithin(short_line, interp_points, line_length * 0.25) - indices= numpy.array([shapely.distance(short_line[0],point)<= (line_length * 0.25) for point in interp_points]) + indices = shapely.dwithin(short_line, interp_points, line_length * 0.25) # get the dip of the points that are within _dip = numpy.deg2rad(dip[indices]) _dips.append(_dip) From 1419270a5ab543e0879abc4258dcfc7d63b59a06 Mon Sep 17 00:00:00 2001 From: Noelle Cheng Date: Fri, 13 Jun 2025 21:06:01 +0800 Subject: [PATCH 11/16] change back to shapely>=2 in dependencies.txt --- dependencies.txt | 2 +- map2loop/thickness_calculator.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/dependencies.txt b/dependencies.txt index d7bd1e53..c9014571 100644 --- a/dependencies.txt +++ b/dependencies.txt @@ -2,7 +2,7 @@ gdal>=3.6.2 numpy scipy geopandas -shapely>=2.0.2 +shapely>=2 networkx owslib loopprojectfile==0.2.2 diff --git a/map2loop/thickness_calculator.py b/map2loop/thickness_calculator.py index 5d7844d8..d7a9aad1 100644 --- a/map2loop/thickness_calculator.py +++ b/map2loop/thickness_calculator.py @@ -23,7 +23,7 @@ import geopandas import shapely import math - +from shapely.errors import UnsupportedGEOSVersionError class ThicknessCalculator(ABC): """ @@ -365,7 +365,11 @@ def compute( # calculate the length of the shortest line line_length = scipy.spatial.distance.euclidean(p1, p2) # find the indices of the points that are within 5% of the length of the shortest line - indices = shapely.dwithin(short_line, interp_points, line_length * 0.25) + try: + # GEOS 3.10.0+ + indices = shapely.dwithin(short_line, interp_points, line_length * 0.25) + except UnsupportedGEOSVersionError: + indices= numpy.array([shapely.distance(short_line[0],point)<= (line_length * 0.25) for point in interp_points]) # get the dip of the points that are within _dip = numpy.deg2rad(dip[indices]) _dips.append(_dip) From 75f08c9df680b44b18c8a62ef165323ceae983d1 Mon Sep 17 00:00:00 2001 From: Noelle Cheng Date: Fri, 13 Jun 2025 21:25:42 +0800 Subject: [PATCH 12/16] remove gdal>=3.6.2 from dependencies.txt --- .github/workflows/linting_and_testing.yml | 1 + dependencies.txt | 1 - map2loop/thickness_calculator.py | 7 +------ 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/linting_and_testing.yml b/.github/workflows/linting_and_testing.yml index a0f0ff77..2dbe7e2b 100644 --- a/.github/workflows/linting_and_testing.yml +++ b/.github/workflows/linting_and_testing.yml @@ -40,6 +40,7 @@ jobs: - name: Install dependencies run: | conda run -n test conda info + conda run -n test conda install -c loop3d -c conda-forge "gdal>=3.6.2" python=${{ matrix.python-version }} -y conda run -n test conda install -c loop3d -c conda-forge --file dependencies.txt python=${{ matrix.python-version }} -y conda run -n test conda install pytest python=${{ matrix.python-version }} -y diff --git a/dependencies.txt b/dependencies.txt index c9014571..76f0f574 100644 --- a/dependencies.txt +++ b/dependencies.txt @@ -1,4 +1,3 @@ -gdal>=3.6.2 numpy scipy geopandas diff --git a/map2loop/thickness_calculator.py b/map2loop/thickness_calculator.py index d7a9aad1..2e3bf1f5 100644 --- a/map2loop/thickness_calculator.py +++ b/map2loop/thickness_calculator.py @@ -23,7 +23,6 @@ import geopandas import shapely import math -from shapely.errors import UnsupportedGEOSVersionError class ThicknessCalculator(ABC): """ @@ -365,11 +364,7 @@ def compute( # calculate the length of the shortest line line_length = scipy.spatial.distance.euclidean(p1, p2) # find the indices of the points that are within 5% of the length of the shortest line - try: - # GEOS 3.10.0+ - indices = shapely.dwithin(short_line, interp_points, line_length * 0.25) - except UnsupportedGEOSVersionError: - indices= numpy.array([shapely.distance(short_line[0],point)<= (line_length * 0.25) for point in interp_points]) + indices = shapely.dwithin(short_line, interp_points, line_length * 0.25) # get the dip of the points that are within _dip = numpy.deg2rad(dip[indices]) _dips.append(_dip) From a4331fe8d9221fca39c6b465e67a29ea825e5b2e Mon Sep 17 00:00:00 2001 From: Noelle Cheng Date: Fri, 13 Jun 2025 21:53:36 +0800 Subject: [PATCH 13/16] windows python 3.10 glda=3.4.3 --- .github/workflows/linting_and_testing.yml | 13 +++++++++++-- dependencies.txt | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/linting_and_testing.yml b/.github/workflows/linting_and_testing.yml index 2dbe7e2b..09bc3efb 100644 --- a/.github/workflows/linting_and_testing.yml +++ b/.github/workflows/linting_and_testing.yml @@ -37,10 +37,19 @@ jobs: conda-remove-defaults: "true" - - name: Install dependencies + - name: Install dependencies for windows python 3.10 + if: ${{ matrix.os == 'windows-latest' && matrix.python-version == '3.10' }} + run: | + conda run -n test conda info + conda run -n test conda install -c loop3d -c conda-forge "gdal=3.4.3" python=${{ matrix.python-version }} -y + conda run -n test conda install -c loop3d -c conda-forge --file dependencies.txt python=${{ matrix.python-version }} -y + conda run -n test conda install pytest python=${{ matrix.python-version }} -y + + - name: Install dependencies for other environments + if: ${{ matrix.os != 'windows-latest' || matrix.python-version != '3.10' }} run: | conda run -n test conda info - conda run -n test conda install -c loop3d -c conda-forge "gdal>=3.6.2" python=${{ matrix.python-version }} -y + conda run -n test conda install -c loop3d -c conda-forge gdal python=${{ matrix.python-version }} -y conda run -n test conda install -c loop3d -c conda-forge --file dependencies.txt python=${{ matrix.python-version }} -y conda run -n test conda install pytest python=${{ matrix.python-version }} -y diff --git a/dependencies.txt b/dependencies.txt index 76f0f574..7f7a2447 100644 --- a/dependencies.txt +++ b/dependencies.txt @@ -1,7 +1,7 @@ numpy scipy geopandas -shapely>=2 +shapely>=2.0.2 networkx owslib loopprojectfile==0.2.2 From 0d583cb20f519ed42fd382023a706a894cbdb2ed Mon Sep 17 00:00:00 2001 From: Noelle Cheng Date: Fri, 13 Jun 2025 22:47:21 +0800 Subject: [PATCH 14/16] add geos version compatibility for shapely.dwithin --- dependencies.txt | 2 +- map2loop/thickness_calculator.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/dependencies.txt b/dependencies.txt index 7f7a2447..76f0f574 100644 --- a/dependencies.txt +++ b/dependencies.txt @@ -1,7 +1,7 @@ numpy scipy geopandas -shapely>=2.0.2 +shapely>=2 networkx owslib loopprojectfile==0.2.2 diff --git a/map2loop/thickness_calculator.py b/map2loop/thickness_calculator.py index 2e3bf1f5..d7a9aad1 100644 --- a/map2loop/thickness_calculator.py +++ b/map2loop/thickness_calculator.py @@ -23,6 +23,7 @@ import geopandas import shapely import math +from shapely.errors import UnsupportedGEOSVersionError class ThicknessCalculator(ABC): """ @@ -364,7 +365,11 @@ def compute( # calculate the length of the shortest line line_length = scipy.spatial.distance.euclidean(p1, p2) # find the indices of the points that are within 5% of the length of the shortest line - indices = shapely.dwithin(short_line, interp_points, line_length * 0.25) + try: + # GEOS 3.10.0+ + indices = shapely.dwithin(short_line, interp_points, line_length * 0.25) + except UnsupportedGEOSVersionError: + indices= numpy.array([shapely.distance(short_line[0],point)<= (line_length * 0.25) for point in interp_points]) # get the dip of the points that are within _dip = numpy.deg2rad(dip[indices]) _dips.append(_dip) From e3aef22dae78bfcfebc93156d611753151c44fff Mon Sep 17 00:00:00 2001 From: Noelle Cheng Date: Mon, 16 Jun 2025 13:08:54 +0800 Subject: [PATCH 15/16] add back branch and path restrictions --- .github/workflows/linting_and_testing.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linting_and_testing.yml b/.github/workflows/linting_and_testing.yml index 09bc3efb..03eab6dc 100644 --- a/.github/workflows/linting_and_testing.yml +++ b/.github/workflows/linting_and_testing.yml @@ -2,6 +2,19 @@ name: Linting and Testing on: push: + branches: + - master + paths: + - '**.py' + - .github/workflows/linting_and_testing.yml + + pull_request: + branches: + - master + paths: + - '**.py' + - .github/workflows/linting_and_testing.yml + workflow_dispatch: jobs: linting: @@ -67,5 +80,4 @@ jobs: - name: Run tests run: | - conda run -n test pytest - + conda run -n test pytest \ No newline at end of file From 18dd00da3d769b64b087658282e619e1f3a040b7 Mon Sep 17 00:00:00 2001 From: Noelle Cheng Date: Mon, 16 Jun 2025 13:10:52 +0800 Subject: [PATCH 16/16] remove print statements --- .github/workflows/linting_and_testing.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/linting_and_testing.yml b/.github/workflows/linting_and_testing.yml index 03eab6dc..9570a3bb 100644 --- a/.github/workflows/linting_and_testing.yml +++ b/.github/workflows/linting_and_testing.yml @@ -65,14 +65,6 @@ jobs: conda run -n test conda install -c loop3d -c conda-forge gdal python=${{ matrix.python-version }} -y conda run -n test conda install -c loop3d -c conda-forge --file dependencies.txt python=${{ matrix.python-version }} -y conda run -n test conda install pytest python=${{ matrix.python-version }} -y - - - name: displace gdal owslib version - run: | - echo "${{ matrix.os }} ${{ matrix.python-version }}" - conda run -n test conda list gdal - conda run -n test conda list owslib - conda run -n test python -c "from shapely import geos_version; print('geos_version: ', geos_version)" - conda run -n test python -c "import shapely; print('shapely version: ',shapely.__version__)" - name: Install map2loop run: |