Skip to content

Commit

Permalink
Qualify warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
bjlittle committed Oct 16, 2023
1 parent 9fc3b94 commit acc4a15
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/geovista/bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,7 @@ def from_unstructured(
n_invalid = n_faces - np.sum(valid_faces_mask)
plural = "s" if n_invalid > 1 else ""
wmsg = (
f"Masked connectivity defines {n_invalid:,} face{plural} "
f"geovista masked connectivity defines {n_invalid:,} face{plural} "
"with no vertices."
)
warnings.warn(wmsg, stacklevel=2)
Expand Down
4 changes: 2 additions & 2 deletions src/geovista/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ def slice_cells(
plural = "s" if (n_cells := bad_cids.size) > 1 else ""
naughty = ", ".join([f"{cid}" for cid in bad_cids])
wmsg = (
f"Unable to remesh {n_cells} cell{plural}. Removing the "
f"geovista unable to remesh {n_cells} cell{plural}. Removing the "
f"following mesh cell-id{plural} [{naughty}]."
)
warnings.warn(wmsg, stacklevel=2)
Expand Down Expand Up @@ -727,7 +727,7 @@ def slice_lines(
n_points = SPLINE_N_POINTS

if n_points < 1:
wmsg = f"Ignoring 'n_points={n_points}', defaulting to 'n_points=1'."
wmsg = f"geovista ignoring 'n_points={n_points}', defaulting to 'n_points=1'."
warnings.warn(wmsg, stacklevel=2)

# check whether the line is completely aligned with the slice plane
Expand Down
6 changes: 3 additions & 3 deletions src/geovista/geodesic.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,9 @@ def __init__(
lons, lats = lons[-1], lats[-1]
else:
wmsg = (
"The bounding-box was specified with 5 longitude/latitude values, "
"however the first and last values are not close enough to specify "
"a closed geometry - ignoring last value."
"geovista bounding-box was specified with 5 longitude/latitude"
"values, however the first and last values are not close enough to "
"specify a closed geometry - ignoring last value."
)
warnings.warn(wmsg, stacklevel=2)
lons, lats = lons[:-1], lats[:-1]
Expand Down
11 changes: 7 additions & 4 deletions src/geovista/geoplotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def __init__(self, *args: Any | None, **kwargs: Any | None) -> None:
klass = f"'{self.__class__.__name__}'"
if len(args) == 1 and ("crs" not in kwargs or kwargs["crs"] is None):
wmsg = (
f"{klass} received an unexpected argument. "
f"geovista {klass} received an unexpected argument. "
"Assuming 'crs' keyword argument instead..."
)
warn(wmsg, stacklevel=2)
Expand Down Expand Up @@ -574,7 +574,10 @@ def add_mesh(self, mesh: Any, **kwargs: Any | None) -> pv.Actor:
src_crs = from_wkt(mesh)

if src_crs is None:
wmsg = "Found no coordinate reference system (CRS) attached to mesh."
wmsg = (
"geovista found no coordinate reference system (CRS) attached "
"to mesh."
)
warn(wmsg, stacklevel=2)

tgt_crs = self.crs
Expand Down Expand Up @@ -1110,8 +1113,8 @@ def add_points(

if isinstance(scalars, str):
wmsg = (
f"Ignoring the 'scalars' string name '{scalars}', as no 'points' "
"mesh was provided."
f"geovista ignoring the 'scalars' string name '{scalars}', as no "
"'points' mesh was provided."
)
warn(wmsg, stacklevel=2)

Expand Down
2 changes: 1 addition & 1 deletion src/geovista/samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ def lfric(resolution: str | None = None) -> pv.PolyData:

if resolution not in LFRIC_RESOLUTIONS:
wmsg = (
f"Unknown LFRic cubed-sphere resolution {original!r}, "
f"geovista detected unknown LFRic cubed-sphere resolution {original!r}, "
f"using {LFRIC_RESOLUTION!r} instead."
)
warn(wmsg, stacklevel=2)
Expand Down
2 changes: 1 addition & 1 deletion tests/core/test_slice_lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_no_lines(mesh):
@pytest.mark.parametrize("n_points", [0, -1])
def test_n_points_warning(coastlines, n_points):
"""Test invalid domain for n_points warning is raised."""
wmsg = f"Ignoring 'n_points={n_points}'"
wmsg = f"geovista ignoring 'n_points={n_points}'"
with pytest.warns(UserWarning, match=wmsg):
_ = slice_lines(coastlines, n_points=n_points)

Expand Down
2 changes: 1 addition & 1 deletion tests/geoplotter/test_add_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def test_xy_ys_scalars_name_warnings(mocker):
xs, ys = mocker.sentinel.xs, mocker.sentinel.ys
scalars = "invalid"
wmsg = (
f"Ignoring the 'scalars' string name '{scalars}', "
f"geovista ignoring the 'scalars' string name '{scalars}', "
"as no 'points' mesh was provided"
)
with pytest.warns(UserWarning, match=wmsg):
Expand Down

0 comments on commit acc4a15

Please sign in to comment.