Skip to content

Commit b8a797c

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 81d28d7 commit b8a797c

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

cf_xarray/accessor.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@
4949

5050

5151
try:
52-
import pyproj
5352
import cartopy.crs
53+
import pyproj
5454
except ImportError:
5555
pyproj = None
5656

@@ -2756,14 +2756,16 @@ def grid_mapping_names(self) -> dict[str, list[str]]:
27562756
def crs(self):
27572757
"""Cartopy CRS of the dataset's grid mapping."""
27582758
if pyproj is None:
2759-
raise ImportError('`crs` accessor requires optional packages `pyproj` and `cartopy`.')
2759+
raise ImportError(
2760+
"`crs` accessor requires optional packages `pyproj` and `cartopy`."
2761+
)
27602762
gmaps = list(itertools.chain(*self.grid_mapping_names.values()))
27612763
if len(gmaps) > 1:
27622764
raise ValueError("Multiple grid mappings found.")
27632765
if len(gmaps) == 0:
2764-
if 'longitude' in self:
2766+
if "longitude" in self:
27652767
return cartopy.crs.PlateCarree()
2766-
raise ValueError('No grid mapping nor longitude found in dataset.')
2768+
raise ValueError("No grid mapping nor longitude found in dataset.")
27672769
return cartopy.crs.Projection(pyproj.CRS.from_cf(self._obj[gmaps[0]].attrs))
27682770

27692771
def decode_vertical_coords(
@@ -2962,13 +2964,15 @@ def grid_mapping_name(self) -> str:
29622964
def crs(self):
29632965
"""Cartopy CRS of the dataset's grid mapping."""
29642966
if pyproj is None:
2965-
raise ImportError('`crs` accessor requires optional packages `pyproj` and `cartopy`.')
2967+
raise ImportError(
2968+
"`crs` accessor requires optional packages `pyproj` and `cartopy`."
2969+
)
29662970

29672971
grid_mapping_var = self._get_grid_mapping(ignore_missing=True)
29682972
if grid_mapping_var is None:
2969-
if 'longitude' in self:
2973+
if "longitude" in self:
29702974
return cartopy.crs.PlateCarree()
2971-
raise ValueError('No grid mapping nor longitude found.')
2975+
raise ValueError("No grid mapping nor longitude found.")
29722976
return cartopy.crs.Projection(pyproj.CRS.from_cf(grid_mapping_var.attrs))
29732977

29742978
def __getitem__(self, key: Hashable | Iterable[Hashable]) -> DataArray:

0 commit comments

Comments
 (0)