diff --git a/.github/workflows/linting_and_testing.yml b/.github/workflows/linting_and_testing.yml index c8c89126..9570a3bb 100644 --- a/.github/workflows/linting_and_testing.yml +++ b/.github/workflows/linting_and_testing.yml @@ -3,11 +3,11 @@ name: Linting and Testing on: push: branches: - - master + - master paths: - '**.py' - .github/workflows/linting_and_testing.yml - + pull_request: branches: - master @@ -50,16 +50,26 @@ 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 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=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 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: | conda run -n test python -m pip install . - name: Run tests run: | - conda run -n test pytest - + conda run -n test pytest \ No newline at end of file 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 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 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)