Skip to content

Commit

Permalink
Resolve warnings from pandas, geopandas
Browse files Browse the repository at this point in the history
  • Loading branch information
mwtoews committed May 26, 2024
1 parent 72d1446 commit f89a8c7
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions swn/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1092,7 +1092,7 @@ def locate_geoms(
if v in missng_segnum_idx_s:
del override[k]
if override:
res.segnum.update(override)
res.update({"segnum": override})
res.loc[override.keys(), "method"] = "override"

# Mark empty geometries
Expand Down Expand Up @@ -1254,7 +1254,7 @@ def find_downstream_in_min_stream_order(segnum):
from shapely.ops import nearest_points

with ignore_shapely_warnings_for_object_array():
res.geometry.loc[sel] = res.loc[sel].apply(
res.loc[sel, "geometry"] = res.loc[sel].apply(
lambda f: nearest_points(
self.segments.geometry[f.segnum], f.geometry
)[1],
Expand Down
2 changes: 1 addition & 1 deletion swn/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def write_formatted_frame(df, fname, index=True, comment_header=True):
for icol, name in enumerate(df.columns):
# add single quotes around items with space chars
try:
sel = df[name].str.contains(" ").fillna(False)
sel = df[name].str.contains(" ").astype(bool)
except AttributeError:
continue
na = df[name].isna()
Expand Down
4 changes: 2 additions & 2 deletions swn/modflow/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ def model(self, model):

# Build stress period DataFrame from modflow model
stress_df = pd.DataFrame({"perlen": perlen})
stress_df["duration"] = pd.TimedeltaIndex(perlen, modeltime.time_units)
stress_df["duration"] = pd.to_timedelta(perlen, modeltime.time_units)
end_time = stress_df["duration"].cumsum()
stress_df["start_time"] = end_time - stress_df["duration"]
stress_df["end_time"] = end_time
Expand All @@ -376,10 +376,10 @@ def model(self, model):
self_crs = getattr(self, "crs", None)
modelgrid_crs = None
epsg = modelgrid.epsg
proj4_str = modelgrid.proj4
if epsg is not None:
segments_crs, modelgrid_crs, same = compare_crs(self_crs, epsg)
else:
proj4_str = modelgrid.proj4
segments_crs, modelgrid_crs, same = compare_crs(self_crs, proj4_str)
if segments_crs is not None and modelgrid_crs is not None and not same:
self.logger.warning(
Expand Down
1 change: 1 addition & 0 deletions tests/test_modflow_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1502,6 +1502,7 @@ def test_get_location_frame_reach_info_coastal(caplog, coastal_swn, coastal_poin
geopandas.GeoSeries(
[Point(1810531, 5869152), Point(1806822.5, 5869173.5)],
index=pd.Index([11, 12], name="id"),
crs=coastal_points.crs,
),
]
)
Expand Down

0 comments on commit f89a8c7

Please sign in to comment.