Skip to content

Commit

Permalink
Fix #348
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderJuestel committed Jul 21, 2024
1 parent 8000aaa commit 15ca7b6
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 16 deletions.
2 changes: 1 addition & 1 deletion gemgis/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2203,7 +2203,7 @@ def chunks(x, n):
for j in chunks(i, nodes_per_line):
j_fmt = "0.{}f".format(decimal_places)
j_fmt = "{0:" + j_fmt + "}"
j = [j_fmt.format(float(x)) if not x is np.nan else j_fmt.format(float(nodata)) for x in j]
j = [j_fmt.format(float(x)) if x is not np.nan else j_fmt.format(float(nodata)) for x in j]
line = "{:>" + "{}".format(field_width) + "}"
lines.append("".join([line] * len(j)).format(*tuple(j)))

Expand Down
2 changes: 1 addition & 1 deletion gemgis/vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -8179,7 +8179,7 @@ def create_voronoi_polygons(gdf: gpd.geodataframe.GeoDataFrame) -> gpd.geodatafr
vor = Voronoi(points)

# Filtering invalid Voronoi regions
regions = [region for region in vor.regions if not -1 in region]
regions = [region for region in vor.regions if -1 not in region]

# Creating Polygons from Voronoi regions
polygons = [geometry.Polygon(vor.vertices[regions[i]]) for i in range(len(regions))]
Expand Down
4 changes: 2 additions & 2 deletions gemgis/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def create_lines_3d_polydata(gdf: gpd.geodataframe.GeoDataFrame) -> pv.core.poin
vertices_list = [list(gdf.geometry[i].coords) for i in range(len(gdf))]

# Extracting Z values of all points if gdf has no Z but Z value is provided for each LineString in an additional column
if (all(gdf.has_z == False)) and ('Z' in gdf.columns):
if (not all(gdf.has_z)) and ('Z' in gdf.columns):
vertices_list_z = [[vertices_list[j][i] + tuple([gdf['Z'].loc[j]]) for i in range(len(vertices_list[j]))] for j
in range(len(vertices_list))]
vertices_list = vertices_list_z
Expand Down Expand Up @@ -1667,7 +1667,7 @@ def create_depth_maps_from_gempy(geo_model,
raise TypeError('geo_model must be a GemPy geo_model')

# Checking that the model was computed
if all(pd.isna(geo_model.surfaces.df.vertices)) == True and all(pd.isna(geo_model.surfaces.df.edges)) == True:
if all(pd.isna(geo_model.surfaces.df.vertices)) and all(pd.isna(geo_model.surfaces.df.edges)):
raise ValueError('Model must be created before depth map extraction')

# Extracting surface data_df for all surfaces
Expand Down
4 changes: 0 additions & 4 deletions gemgis/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ def load_wms(url: str,
"""
# Trying to import owslib but returning error if owslib is not installed
try:
import owslib
from owslib.wms import WebMapService
except ModuleNotFoundError:
raise ModuleNotFoundError(
Expand Down Expand Up @@ -547,7 +546,6 @@ def load_wfs(url: str): # -> owslib.wfs.WebFeatureService:

# Trying to import owslib but returning error if owslib is not installed
try:
import owslib
from owslib import util
from owslib.wfs import WebFeatureService
__all__ = [util]
Expand Down Expand Up @@ -622,7 +620,6 @@ def load_as_gpd(url: str,

# Trying to import owslib but returning error if owslib is not installed
try:
import owslib
from owslib import util
__all__ = [util]
except ModuleNotFoundError:
Expand Down Expand Up @@ -716,7 +713,6 @@ def load_wcs(url: str): # -> owslib.wcs.WebCoverageService:

# Trying to import owslib but returning error if owslib is not installed
try:
import owslib
from owslib import util
from owslib.wcs import WebCoverageService
__all__ = [util]
Expand Down
1 change: 0 additions & 1 deletion tests/test_gemgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import pandas as pd
from shapely import geometry
import geopandas as gpd
import gempy as gp
import gemgis as gg

gg.download_gemgis_data.download_tutorial_data(filename='test_gemgis.zip',
Expand Down
8 changes: 4 additions & 4 deletions tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,15 +370,15 @@ def test_stratigraphic_table_list_comprehension():
try:
pdf = load_pdf('../docs/getting_started/tutorial/data/test_misc/test_pdf.pdf')

assert type(pdf) == str
assert type(pdf) is str

df = get_stratigraphic_data_df(data=pdf,
name='Test',
symbols=symbols,
formations=formations,
return_gdf=False)

assert type(df) == pd.DataFrame
assert type(df) is pd.DataFrame
assert len(df) == 7
assert df.loc[0]['Depth'] == 1242
assert df.loc[4]['Depth'] == 1135
Expand All @@ -398,7 +398,7 @@ def test_stratigraphic_table_list_comprehension():
try:
pdf = load_pdf('../docs/getting_started/tutorial/data/test_misc/test_pdf.pdf')

assert type(pdf) == str
assert type(pdf) is str

df = get_stratigraphic_data_df(data=pdf,
name='Test',
Expand All @@ -407,7 +407,7 @@ def test_stratigraphic_table_list_comprehension():
remove_last=True,
return_gdf=False)

assert type(df) == pd.DataFrame
assert type(df) is pd.DataFrame
assert len(df) == 5
assert df.loc[0]['Depth'] == 1242
assert df.loc[4]['Depth'] == 1135
Expand Down
2 changes: 1 addition & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ def test_get_nearest_neighbor():

index = get_nearest_neighbor(x=x,
y=np.array([0, 0]))
assert type(index) == np.int64
assert type(index) is np.int64
assert index == 0


Expand Down
4 changes: 2 additions & 2 deletions tests/test_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ def test_load_wfs():

wfs = load_wfs(url='https://nibis.lbeg.de/net3/public/ogc.ashx?NodeId=287&Service=WFS&Request=GetCapabilities&')

assert type(wfs) == owslib.feature.wfs100.WebFeatureService_1_0_0
assert type(wfs) is owslib.feature.wfs100.WebFeatureService_1_0_0
assert wfs.version == '1.0.0'
assert wfs.identification.version == '1.0.0'
assert wfs.identification.type == 'LBEG'
Expand Down Expand Up @@ -608,7 +608,7 @@ def test_create_request():
identifier='nw_dgm',
form='image/tiff',
extent=[292000, 298000, 5626000, 5632000])
assert type(url) == str
assert type(url) is str
assert url == 'https://www.wcs.nrw.de/geobasis/wcs_nw_dgm?REQUEST=GetCoverage&SERVICE=WCS&VERSION=2.0.1&COVERAGEID=nw_dgm&FORMAT=image/tiff&SUBSET=x(292000,298000)&SUBSET=y(5626000,5632000)&OUTFILE=test.tif'

with pytest.raises(TypeError):
Expand Down

0 comments on commit 15ca7b6

Please sign in to comment.