From 15ca7b6f6287a63028f49d2f43a61b60c51c7a6d Mon Sep 17 00:00:00 2001 From: AlexanderJuestel Date: Sun, 21 Jul 2024 12:38:43 +0200 Subject: [PATCH] Fix #348 --- gemgis/utils.py | 2 +- gemgis/vector.py | 2 +- gemgis/visualization.py | 4 ++-- gemgis/web.py | 4 ---- tests/test_gemgis.py | 1 - tests/test_misc.py | 8 ++++---- tests/test_utils.py | 2 +- tests/test_web.py | 4 ++-- 8 files changed, 11 insertions(+), 16 deletions(-) diff --git a/gemgis/utils.py b/gemgis/utils.py index 5afe457c..43884219 100644 --- a/gemgis/utils.py +++ b/gemgis/utils.py @@ -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))) diff --git a/gemgis/vector.py b/gemgis/vector.py index 77c0b3ab..303ff910 100644 --- a/gemgis/vector.py +++ b/gemgis/vector.py @@ -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))] diff --git a/gemgis/visualization.py b/gemgis/visualization.py index 5f0e55f7..05f844ad 100644 --- a/gemgis/visualization.py +++ b/gemgis/visualization.py @@ -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 @@ -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 diff --git a/gemgis/web.py b/gemgis/web.py index e4056526..fd74dedf 100644 --- a/gemgis/web.py +++ b/gemgis/web.py @@ -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( @@ -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] @@ -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: @@ -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] diff --git a/tests/test_gemgis.py b/tests/test_gemgis.py index a00061a9..2677a8fc 100644 --- a/tests/test_gemgis.py +++ b/tests/test_gemgis.py @@ -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', diff --git a/tests/test_misc.py b/tests/test_misc.py index 11ca3b12..98fc92a9 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -370,7 +370,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', @@ -378,7 +378,7 @@ def test_stratigraphic_table_list_comprehension(): 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 @@ -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', @@ -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 diff --git a/tests/test_utils.py b/tests/test_utils.py index 15de00bf..76c21d01 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -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 diff --git a/tests/test_web.py b/tests/test_web.py index 254221c5..baa4ba85 100644 --- a/tests/test_web.py +++ b/tests/test_web.py @@ -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' @@ -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):