Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions .github/workflows/linting_and_testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
3 changes: 1 addition & 2 deletions dependencies.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ owslib
loopprojectfile==0.2.2
beartype
pytest
scikit-learn
gdal
scikit-learn
6 changes: 4 additions & 2 deletions map2loop/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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:
Expand All @@ -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

Expand Down
8 changes: 6 additions & 2 deletions map2loop/thickness_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import geopandas
import shapely
import math

from shapely.errors import UnsupportedGEOSVersionError

class ThicknessCalculator(ABC):
"""
Expand Down Expand Up @@ -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)
Expand Down
Loading