Skip to content

Commit

Permalink
deprecate set_geomety_points
Browse files Browse the repository at this point in the history
  • Loading branch information
emanuel-schmid committed Sep 16, 2024
1 parent b843362 commit 73252ed
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 12 deletions.
2 changes: 0 additions & 2 deletions climada/entity/exposures/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -928,8 +928,6 @@ def plot_basemap(self, mask=None, ignore_zero=False, pop_name=True,
-------
matplotlib.figure.Figure, cartopy.mpl.geoaxes.GeoAxesSubplot
"""
if 'geometry' not in self.gdf:
self.set_geometry_points()
crs_ori = self.crs
self.to_crs(epsg=3857, inplace=True)
axis = self.plot_scatter(mask, ignore_zero, pop_name, buffer,
Expand Down
5 changes: 0 additions & 5 deletions climada/entity/exposures/test/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@ def test_read_template_pass(self):
def test_io_hdf5_pass(self):
"""write and read hdf5"""
exp_df = Exposures(pd.read_excel(ENT_TEMPLATE_XLS), crs="epsg:32632")
exp_df.set_geometry_points()
exp_df.check()
# set metadata
exp_df.ref_year = 2020
Expand Down Expand Up @@ -429,7 +428,6 @@ def test_copy_pass(self):
def test_to_crs_inplace_pass(self):
"""Test to_crs function inplace."""
exp = good_exposures()
exp.set_geometry_points()
exp.check()
exp.to_crs('epsg:3395', inplace=True)
self.assertIsInstance(exp, Exposures)
Expand All @@ -441,7 +439,6 @@ def test_to_crs_inplace_pass(self):
def test_to_crs_pass(self):
"""Test to_crs function copy."""
exp = good_exposures()
exp.set_geometry_points()
exp.check()
exp_tr = exp.to_crs('epsg:3395')
self.assertIsInstance(exp, Exposures)
Expand Down Expand Up @@ -477,7 +474,6 @@ def test_set_gdf(self):
gdf_without_geometry = good_exposures().gdf
good_exp = good_exposures()
good_exp.set_crs(crs='epsg:3395')
good_exp.set_geometry_points()
gdf_with_geometry = good_exp.gdf

probe = Exposures()
Expand All @@ -504,7 +500,6 @@ def test_set_crs(self):
empty_gdf = gpd.GeoDataFrame()
gdf_without_geometry = good_exposures().gdf
good_exp = good_exposures()
good_exp.set_geometry_points()
gdf_with_geometry = good_exp.gdf

probe = Exposures(gdf_without_geometry)
Expand Down
2 changes: 1 addition & 1 deletion climada/hazard/centroids/test/test_centr.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ def test_set_region_id_implementationerror(self):
centroids.set_region_id(level='continent',overwrite=True)

def test_set_geometry_points_pass(self):
"""Test set_geometry_points"""
"""Test geometry is set"""
centr_ras = Centroids.from_raster_file(HAZ_DEMO_FL, window=Window(0, 0, 50, 60))
x_flat = np.arange(-69.3326495969998, -68.88264959699978, 0.009000000000000341)
y_flat = np.arange(10.423720966978939, 9.883720966978919, -0.009000000000000341)
Expand Down
4 changes: 2 additions & 2 deletions climada/hazard/tc_tracks.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,9 @@ def tracks_in_exp(self, exposure, buffer=1.0):
if buffer <= 0.0:
raise ValueError(f"buffer={buffer} is invalid, must be above zero.")
try:
exposure.gdf.geometry
exposure.geometry
except AttributeError:
exposure.set_geometry_points()
raise Exception("this is not an Exposures object")

Check warning on line 306 in climada/hazard/tc_tracks.py

View check run for this annotation

Jenkins - WCR / Pylint

raise-missing-from

NORMAL: Consider explicitly re-raising using the 'from' keyword
Raw output
no description found

Check warning on line 306 in climada/hazard/tc_tracks.py

View check run for this annotation

Jenkins - WCR / Code Coverage

Not covered line

Line 306 is not covered by tests

exp_buffer = exposure.gdf.buffer(distance=buffer, resolution=0)
exp_buffer = exp_buffer.unary_union
Expand Down
2 changes: 0 additions & 2 deletions script/applications/eca_san_salvador/functions_ss.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ def plot_salvador_ma():
def load_entity():
ent_file = 'FL_entity_Acelhuate_houses.xlsx'
ent = Entity.from_excel(ent_file)
ent.exposures.set_geometry_points()
ent.check()
return ent

Expand Down Expand Up @@ -196,7 +195,6 @@ def load_accounting():
def generate_plots_risk():
fig_ma = plot_salvador_ma()
ent = load_entity()
ent.exposures.set_geometry_points()
ent.exposures.to_crs(epsg=3857, inplace=True)
fig_point = plot_exposure_ss(ent.exposures, 1064)
fig_houses = plot_exposure_ss(ent.exposures)
Expand Down

0 comments on commit 73252ed

Please sign in to comment.