Skip to content

Commit

Permalink
Merge pull request #200 from freemansw1/deprecate_wrapper
Browse files Browse the repository at this point in the history
Add DeprecationWarnings to several old functions
  • Loading branch information
freemansw1 authored Nov 15, 2022
2 parents dfe3b38 + 44b9dd5 commit 094dda7
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tobac/centerofgravity.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""

import logging
import warnings


def calculate_cog(tracks, mass, mask):
Expand Down Expand Up @@ -31,6 +32,11 @@ def calculate_cog(tracks, mass, mask):
from .utils import mask_cube_cell
from iris import Constraint

warnings.warn(
"calculate_cog is depreciated and will be removed or significantly changed in v2.0.",
DeprecationWarning,
)

logging.info("start calculating centre of gravity for tracked cells")

tracks_out = tracks[["time", "frame", "cell", "time_cell"]]
Expand Down Expand Up @@ -77,6 +83,11 @@ def calculate_cog_untracked(mass, mask):
from .utils import mask_cube_untracked
from iris import Constraint

warnings.warn(
"calculate_cog_untracked is depreciated and will be removed or significantly changed in v2.0.",
DeprecationWarning,
)

logging.info(
"start calculating centre of gravity for untracked parts of the domain"
)
Expand Down Expand Up @@ -123,6 +134,11 @@ def calculate_cog_domain(mass):
from pandas import DataFrame
from iris import Constraint

warnings.warn(
"calculate_cog_domain is depreciated and will be removed or significantly changed in v2.0.",
DeprecationWarning,
)

logging.info("start calculating centre of gravity for entire domain")

time_coord = mass.coord("time")
Expand Down Expand Up @@ -173,6 +189,11 @@ def center_of_gravity(cube_in):
from iris.analysis import SUM
import numpy as np

warnings.warn(
"center_of_gravity is depreciated and will be removed or significantly changed in v2.0.",
DeprecationWarning,
)

cube_sum = cube_in.collapsed(["bottom_top", "south_north", "west_east"], SUM)
z = cube_in.coord("geopotential_height")
x = cube_in.coord("projection_x_coordinate")
Expand Down
39 changes: 39 additions & 0 deletions tobac/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,10 @@ def plot_mask_cell_track_follow(
Input:
Output:
"""
warnings.warn(
"plot_mask_cell_track_follow is depreciated and will be removed or significantly changed in v2.0.",
DeprecationWarning,
)

mpl_backend = mpl.get_backend()
if mpl_backend != "agg":
Expand Down Expand Up @@ -705,6 +709,11 @@ def plot_mask_cell_individual_follow(
from mpl_toolkits.axes_grid1 import make_axes_locatable
from matplotlib.colors import Normalize

warnings.warn(
"plot_mask_cell_individual_follow is depreciated and will be removed or significantly changed in v2.0.",
DeprecationWarning,
)

divider = make_axes_locatable(axes)

x_pos = track[track["cell"] == cell_i]["projection_x_coordinate"].item()
Expand Down Expand Up @@ -891,6 +900,12 @@ def plot_mask_cell_track_static(
Input:
Output:
"""

warnings.warn(
"plot_mask_cell_track_static is depreciated and will be removed or significantly changed in v2.0.",
DeprecationWarning,
)

mpl_backend = mpl.get_backend()
if mpl_backend != "agg":
warnings.warn(
Expand Down Expand Up @@ -1057,6 +1072,11 @@ def plot_mask_cell_individual_static(
from mpl_toolkits.axes_grid1 import make_axes_locatable
from matplotlib.colors import Normalize

warnings.warn(
"plot_mask_cell_individual_static is depreciated and will be removed or significantly changed in v2.0.",
DeprecationWarning,
)

divider = make_axes_locatable(axes)

if field_filled is not None:
Expand Down Expand Up @@ -1252,6 +1272,11 @@ def plot_mask_cell_track_2D3Dstatic(
Input:
Output:
"""
warnings.warn(
"plot_mask_cell_track_2D3Dstatic is depreciated and will be removed or significantly changed in v2.0.",
DeprecationWarning,
)

mpl_backend = mpl.get_backend()
if mpl_backend != "agg":
warnings.warn(
Expand Down Expand Up @@ -1426,6 +1451,11 @@ def plot_mask_cell_track_3Dstatic(
Input:
Output:
"""
warnings.warn(
"plot_mask_cell_track_3Dstatic is depreciated and will be removed or significantly changed in v2.0.",
DeprecationWarning,
)

mpl_backend = mpl.get_backend()
if mpl_backend != "agg":
warnings.warn(
Expand Down Expand Up @@ -1603,6 +1633,11 @@ def plot_mask_cell_individual_3Dstatic(
# from matplotlib.colors import Normalize
from mpl_toolkits.mplot3d import Axes3D

warnings.warn(
"plot_mask_cell_individual_3Dstatic is depreciated and will be removed or significantly changed in v2.0.",
DeprecationWarning,
)

axes.view_init(elev=ele, azim=azim)
axes.grid(b=False)
axes.set_frame_on(False)
Expand Down Expand Up @@ -1782,6 +1817,10 @@ def plot_mask_cell_track_static_timeseries(
Input:
Output:
"""
warnings.warn(
"plot_mask_cell_track_static_timeseries is depreciated and will be removed or significantly changed in v2.0.",
DeprecationWarning,
)

mpl_backend = mpl.get_backend()
if mpl_backend != "agg":
Expand Down
11 changes: 11 additions & 0 deletions tobac/wrapper.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import numpy as np
import logging
import warnings


def tracking_wrapper(
Expand All @@ -17,6 +18,11 @@ def tracking_wrapper(
from .segmentation import segmentation_3D, segmentation_2D
from .utils import get_spacings

warnings.warn(
"tracking_wrapper is depreciated and will be removed in v2.0.",
DeprecationWarning,
)

logger = logging.getLogger("trackpy")
logger.propagate = False
logger.setLevel(logging.WARNING)
Expand Down Expand Up @@ -147,6 +153,11 @@ def maketrack(
"""
from copy import deepcopy

warnings.warn(
"maketrack is depreciated and will be removed in v2.0.",
DeprecationWarning,
)

logger = logging.getLogger("trackpy")
logger.propagate = False
logger.setLevel(logging.WARNING)
Expand Down

0 comments on commit 094dda7

Please sign in to comment.