Skip to content

Commit

Permalink
Fix CI Failures (#731)
Browse files Browse the repository at this point in the history
* update envs

* fix issues in point raster

* fix dask issues

* remove left over attributes

* add comments
  • Loading branch information
philipc2 authored Mar 22, 2024
1 parent cb9dd73 commit d72a5ca
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 53 deletions.
2 changes: 1 addition & 1 deletion ci/asv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies:
- pandas<2.1.0
- pathlib
- pre_commit
- pyarrow<13.0.0 # pin due to CI faliures on macOS & ubuntu
- pyarrow
- pytest
- pytest-cov
- requests
Expand Down
2 changes: 1 addition & 1 deletion ci/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ dependencies:
- dask
- netcdf4
- numba
- numpy<=1.24
- numpy
- pathlib
- pre_commit
- pytest
Expand Down
2 changes: 1 addition & 1 deletion test/test_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,4 @@ def test_clabel(self):

raster_no_clabel = uxds['v1'][0][0].plot.rasterize(method='point')

raster_no_clabel = uxds['v1'][0][0].plot.rasterize(method='point', clabel="Foo")
raster_with_clabel = uxds['v1'][0][0].plot.rasterize(method='point', clabel='Foo')
2 changes: 0 additions & 2 deletions uxarray/grid/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,6 @@ def __init__(
self._gdf_exclude_am = None
self._poly_collection = None
self._line_collection = None
self._centroid_points_df_proj = [None, None]
self._corner_points_df_proj = [None, None]
self._raster_data_id = None

# initialize cached data structures (nearest neighbor operations)
Expand Down
61 changes: 13 additions & 48 deletions uxarray/plot/dataarray_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

from uxarray.plot.constants import N_FACE_THRESHOLD

import pandas as pd

import numpy as np

Expand Down Expand Up @@ -214,65 +213,31 @@ def _point_raster(

if uxda._face_centered():
# data mapped to face centroid coordinates
lon = uxda.uxgrid.face_lon.values
lat = uxda.uxgrid.face_lat.values
lon, lat = uxda.uxgrid.face_lon.values, uxda.uxgrid.face_lat.values
elif uxda._node_centered():
# data mapped to face corner coordinates
lon = uxda.uxgrid.node_lon.values
lat = uxda.uxgrid.node_lat.values
lon, lat = uxda.uxgrid.node_lon.values, uxda.uxgrid.node_lat.values
elif uxda._edge_centered():
# data mapped to face corner coordinates
lon = uxda.uxgrid.edge_lon.values
lat = uxda.uxgrid.edge_lat.values
lon, lat = uxda.uxgrid.edge_lon.values, uxda.uxgrid.edge_lat.values
else:
raise ValueError(
f"The Dimension of Data Variable {uxda.name} is not Node or Face centered."
)

# determine whether we need to recompute points, typically when a new projection is selected
recompute = True
if uxda._face_centered() == "center":
if (
uxda.uxgrid._centroid_points_df_proj[0] is not None
and uxda.uxgrid._centroid_points_df_proj[1] == projection
):
recompute = False
points_df = uxda.uxgrid._centroid_points_df_proj[0]

else:
if (
uxda.uxgrid._corner_points_df_proj[0] is not None
and uxda.uxgrid._corner_points_df_proj[1] == projection
):
recompute = False
points_df = uxda.uxgrid._corner_points_df_proj[0]

if recompute:
# need to recompute points and/or projection
if projection is not None:
lon, lat, _ = projection.transform_points(ccrs.PlateCarree(), lon, lat).T

point_dict = {"lon": lon, "lat": lat, "var": uxda.values}

# Construct Dask DataFrame
point_ddf = dd.from_dict(data=point_dict, npartitions=npartitions)
if projection is not None:
# apply projection to coordinates
lon, lat, _ = projection.transform_points(ccrs.PlateCarree(), lon, lat).T

hv.extension("bokeh")
points = hv.Points(point_ddf, ["lon", "lat"]).opts(size=size)
# this will be fixed in #733
hv.extension("bokeh")

# cache computed points & projection
if cache:
if uxda._face_centered() == "center":
uxda.uxgrid._centroid_points_df_proj[0] = point_ddf
uxda.uxgrid._centroid_points_df_proj[1] = projection
else:
uxda.uxgrid._corner_points_df_proj[0] = point_ddf
uxda.uxgrid._corner_points_df_proj[1] = projection
# construct a dask dataframe from coordinates and data
point_dict = {"lon": lon, "lat": lat, "var": uxda.data}
point_ddf = dd.from_dict(data=point_dict, npartitions=npartitions)

else:
# use existing cached points & projection
points_df["var"] = pd.Series(uxda.values)
points = hv.Points(points_df, ["lon", "lat"]).opts(size=size)
# construct a holoviews points oobject
points = hv.Points(point_ddf, ["lon", "lat"]).opts(size=size)

if backend == "matplotlib":
# use holoviews matplotlib backend
Expand Down

0 comments on commit d72a5ca

Please sign in to comment.