-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* module renaming deprecation * changelog * add version info
- Loading branch information
Showing
9 changed files
with
160 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from mplotutils import _cartopy_utils | ||
from mplotutils._deprecate import _module_renamed_warning | ||
|
||
|
||
def __getattr__(attr_name): | ||
attr = getattr(_cartopy_utils, attr_name) | ||
_module_renamed_warning(attr_name, "cartopy_utils") | ||
return attr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from mplotutils import _colormaps | ||
from mplotutils._deprecate import _module_renamed_warning | ||
|
||
|
||
def __getattr__(attr_name): | ||
attr = getattr(_colormaps, attr_name) | ||
_module_renamed_warning(attr_name, "colormaps") | ||
return attr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from mplotutils import _map_layout | ||
from mplotutils._deprecate import _module_renamed_warning | ||
|
||
|
||
def __getattr__(attr_name): | ||
attr = getattr(_map_layout, attr_name) | ||
_module_renamed_warning(attr_name, "map_layout") | ||
return attr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from mplotutils import _mpl | ||
from mplotutils._deprecate import _module_renamed_warning | ||
|
||
|
||
def __getattr__(attr_name): | ||
attr = getattr(_mpl, attr_name) | ||
_module_renamed_warning(attr_name, "mpl") | ||
return attr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import importlib | ||
|
||
import pytest | ||
|
||
import mplotutils as mpu | ||
|
||
DEPRECATED_MODULES = { | ||
"cartopy_utils": ( | ||
"cyclic_dataarray", | ||
"sample_data_map", | ||
"sample_dataarray", | ||
"xlabel_map", | ||
"xticklabels", | ||
"ylabel_map", | ||
"yticklabels", | ||
), | ||
"colormaps": ("from_levels_and_cmap",), | ||
"map_layout": ("set_map_layout",), | ||
"mpl": ("_get_renderer",), | ||
"xrcompat": ("infer_interval_breaks",), | ||
} | ||
|
||
|
||
def test_00_deprecated_not_in_dir(): | ||
|
||
dir = mpu.__dir__() | ||
|
||
for module in DEPRECATED_MODULES: | ||
assert module not in dir | ||
|
||
|
||
def test_01_in_dir(): | ||
|
||
dir = mpu.__dir__() | ||
|
||
assert "hatch" in dir | ||
|
||
|
||
@pytest.mark.parametrize("mod", DEPRECATED_MODULES) | ||
def test_01_deprecated_modules_from_import(mod): | ||
|
||
with pytest.warns(FutureWarning, match=f"``mplotutils.{mod}`` is deprecated"): | ||
importlib.__import__("mplotutils", fromlist=[mod]) | ||
|
||
|
||
@pytest.mark.parametrize("mod, functions", DEPRECATED_MODULES.items()) | ||
def test_depm3(mod, functions): | ||
|
||
module = importlib.import_module(f"mplotutils.{mod}") | ||
|
||
for function in functions: | ||
with pytest.warns(FutureWarning, match=f"``mplotutils.{mod}`` is deprecated"): | ||
getattr(module, function) | ||
|
||
|
||
def test_fcn_warns(): | ||
|
||
# NOTE: this is the only import that does not warn | ||
import mplotutils.cartopy_utils | ||
|
||
with pytest.warns(FutureWarning): | ||
mplotutils.cartopy_utils.sample_data_map(6, 6) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from mplotutils import _xrcompat | ||
from mplotutils._deprecate import _module_renamed_warning | ||
|
||
|
||
def __getattr__(attr_name): | ||
attr = getattr(_xrcompat, attr_name) | ||
_module_renamed_warning(attr_name, "xrcompat") | ||
return attr |