Skip to content

Commit

Permalink
Update typing
Browse files Browse the repository at this point in the history
  • Loading branch information
mpiannucci committed Oct 31, 2023
1 parent 28a14b3 commit 4f3f8ed
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions xpublish_wms/grid.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from abc import ABC, abstractmethod
from enum import Enum
from typing import Any, Optional, Tuple
from typing import Any, Optional, Tuple, Union

import cartopy.geodesic
import cf_xarray # noqa
Expand Down Expand Up @@ -91,7 +91,9 @@ def select_by_elevation(
da = da.cf.sel({"vertical": elevation}, method="nearest")
return da

def mask(self, da: xr.DataArray | xr.Dataset) -> xr.DataArray | xr.Dataset:
def mask(
self, da: Union[xr.DataArray, xr.Dataset]
) -> Union[xr.DataArray, xr.Dataset]:
"""Mask the given data array"""
return da

Expand Down Expand Up @@ -166,7 +168,9 @@ def render_method(self) -> RenderMethod:
def crs(self) -> str:
return "EPSG:4326"

def mask(self, da: xr.DataArray | xr.Dataset) -> xr.DataArray | xr.Dataset:
def mask(
self, da: Union[xr.DataArray, xr.Dataset]
) -> Union[xr.DataArray, xr.Dataset]:
mask = self.ds[f'mask_{da.cf["latitude"].name.split("_")[1]}']
mask = mask.cf.isel(time=0).squeeze(drop=True).cf.drop_vars("time")
mask[:-1, :] = mask[:-1, :].where(mask[1:, :] == 1, 0)
Expand Down Expand Up @@ -529,7 +533,9 @@ def select_by_elevation(
else:
return self._grid.select_by_elevation(da, elevation)

def mask(self, da: xr.DataArray) -> xr.DataArray:
def mask(
self, da: Union[xr.DataArray, xr.Dataset]
) -> Union[xr.DataArray, xr.Dataset]:
if self._grid is None:
return None
else:
Expand Down

0 comments on commit 4f3f8ed

Please sign in to comment.