Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Silence GDAL exceptions warning and filter out warnings from the test suite #1142

Merged
merged 8 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions hvplot/tests/testui.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def test_explorer_basic():
def test_explorer_settings():
explorer = hvplot.explorer(df)

explorer.param.set_param(
explorer.param.update(
kind='scatter',
x='bill_length_mm',
y_multi=['bill_depth_mm'],
Expand All @@ -43,7 +43,7 @@ def test_explorer_settings():
def test_explorer_plot_code():
explorer = hvplot.explorer(df)

explorer.param.set_param(
explorer.param.update(
kind='scatter',
x='bill_length_mm',
y_multi=['bill_depth_mm'],
Expand All @@ -62,7 +62,7 @@ def test_explorer_plot_code():
def test_explorer_hvplot():
explorer = hvplot.explorer(df)

explorer.param.set_param(
explorer.param.update(
kind='scatter',
x='bill_length_mm',
y_multi=['bill_depth_mm'],
Expand All @@ -78,7 +78,7 @@ def test_explorer_hvplot():
def test_explorer_save(tmp_path):
explorer = hvplot.explorer(df)

explorer.param.set_param(
explorer.param.update(
kind='scatter',
x='bill_length_mm',
y_multi=['bill_depth_mm'],
Expand Down
4 changes: 2 additions & 2 deletions hvplot/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ def __init__(self, df, **params):
cls.name.lower(): cls(df, explorer=self, **cparams)
for cls, cparams in controller_params.items()
}
self.param.set_param(**self._controllers)
self.param.update(**self._controllers)
self.param.watch(self._plot, list(self.param))
for controller in self._controllers.values():
controller.param.watch(self._plot, list(controller.param))
Expand Down Expand Up @@ -478,7 +478,7 @@ def _plot(self, *events):
self._layout[1][1] = self._hvpane
self._alert.visible = False
except Exception as e:
self._alert.param.set_param(
self._alert.param.update(
object=f'**Rendering failed with following error**: {e}',
visible=True
)
Expand Down
20 changes: 15 additions & 5 deletions hvplot/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,21 @@ def proj_to_cartopy(proj):

srs = proj.srs
if has_gdal:
# this is more robust, as srs could be anything (espg, etc.)
s1 = osr.SpatialReference()
s1.ImportFromProj4(proj.srs)
if s1.ExportToProj4():
srs = s1.ExportToProj4()
import warnings
with warnings.catch_warnings():
# Avoiding this warning could be done by setting osr.UseExceptions(),
# except there might be a risk to break the code of users leveraging
# GDAL on their side or through other libraries. So we just silence it.
warnings.filterwarnings('ignore', category=FutureWarning, message=
r'Neither osr\.UseExceptions\(\) nor osr\.DontUseExceptions\(\) has '
r'been explicitly called\. In GDAL 4\.0, exceptions will be enabled '
'by default'
)
# this is more robust, as srs could be anything (espg, etc.)
s1 = osr.SpatialReference()
s1.ImportFromProj4(proj.srs)
if s1.ExportToProj4():
srs = s1.ExportToProj4()

km_proj = {'lon_0': 'central_longitude',
'lat_0': 'central_latitude',
Expand Down
21 changes: 21 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,24 @@ requires = [
"pyct >=0.4.4",
"setuptools >=30.3.0"
]


[tool.pytest.ini_options]
addopts = "-v --pyargs"
norecursedirs = "doc .git dist build _build .ipynb_checkpoints"
# The test suite used to be run with nosetests which collected
# by default files like `testgeo.py` while pytest's default is
# to collect files like `test_geo.py`. This setting allows
# to avoid renaming all the test files.
python_files = "test*.py"
filterwarnings = [
# 2023-09: See https://github.com/matplotlib/matplotlib/issues/25244
"ignore:Deprecated call to `pkg_resources.+?'mpl_toolkits:DeprecationWarning",
"ignore:Deprecated call to `pkg_resources.+?'sphinxcontrib:DeprecationWarning",
# 2023-09: See https://github.com/ibis-project/ibis/pull/6973
"ignore:.+? is deprecated and will be removed in a future version:FutureWarning:ibis.formats.pandas",
# 2023-09: See https://github.com/Unidata/MetPy/pull/3117
"ignore: 'xdrlib' is deprecated and slated for removal in Python 3.13:DeprecationWarning:metpy.io.nexrad",
# 2023-09: See https://github.com/python-streamz/streamz/issues/460
"ignore: pkg_resources is deprecated as an API:DeprecationWarning:streamz.plugins",
]
9 changes: 0 additions & 9 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,6 @@ deps = unit: {[_unit]deps}
examples: {[_examples]deps}
all: {[_all]deps}

[pytest]
addopts = -v --pyargs
norecursedirs = doc .git dist build _build .ipynb_checkpoints
; The test suite used to be run with nosetests which collected
; by default files like `testgeo.py` while pytest's default is
; to collect files like `test_geo.py`. This setting allows
; to avoid renaming all the test files.
python_files = test*.py

[flake8]
include = *.py
# run_tests.py is generated by conda build, which appears to have a
Expand Down