Skip to content

Commit 6d80dfd

Browse files
committed
Try and except test on the import of xesmf 2
1 parent abd2664 commit 6d80dfd

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

lenapy/lenapy_geo.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
"""
44

55
# -*- coding: utf-8 -*-
6-
import numpy as np
6+
import warnings
7+
78
import xarray as xr
89

910
try:
1011
import xesmf as xe
1112
except ModuleNotFoundError:
12-
raise Warning(
13-
"No module named 'ESMF', often due to installation with pip instead of conda for the xesmf lib."
13+
raise warnings.warn(
14+
"Warning: No module named 'ESMF', often due to installation with pip instead of conda for the xesmf lib."
1415
"You can try to manually set up the ESMFMKFILE global variable with os.environ() function to solve"
1516
"this issue."
1617
)

lenapy/readers/geo_reader.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33

44
import numbers
55
import os
6+
import warnings
67

78
import numpy as np
89
import xarray as xr
910

1011
try:
1112
import xesmf as xe
1213
except ModuleNotFoundError:
13-
raise Warning(
14-
"No module named 'ESMF', often due to installation with pip instead of conda for the xesmf lib."
14+
raise warnings.warn(
15+
"Warning: No module named 'ESMF', often due to installation with pip instead of conda for the xesmf lib."
1516
"You can try to manually set up the ESMFMKFILE global variable with os.environ() function to solve"
1617
"this issue."
1718
)

0 commit comments

Comments
 (0)