Skip to content

Commit

Permalink
improved import statements try except (try import in environment, els…
Browse files Browse the repository at this point in the history
…e add path)
  • Loading branch information
casvbem committed Aug 21, 2023
1 parent 3871f3f commit 89284bf
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 21 deletions.
10 changes: 9 additions & 1 deletion examples/xbeach-post-2D.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,17 @@
"metadata": {},
"outputs": [],
"source": [
"# import default modules\n",
"import matplotlib.pyplot as plt\n",
"import sys\n",
"import os"
"import os\n",
"\n",
"# method to import xbtools with try routine\n",
"try:\n",
" import xbTools\n",
"except ImportError:\n",
" print('**no xbTools installation found in environment, adding parent path of notebook to see if it works')\n",
" sys.path.append(os.path.abspath(os.path.join('..', '..', 'xbeach-toolbox')))"
]
},
{
Expand Down
10 changes: 9 additions & 1 deletion examples/xbeach-setup-1D.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,19 @@
"metadata": {},
"outputs": [],
"source": [
"# import default modules\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"from matplotlib import cm\n",
"import sys\n",
"import os"
"import os\n",
"\n",
"# method to import xbtools with try routine\n",
"try:\n",
" import xbTools\n",
"except ImportError:\n",
" print('**no xbTools installation found in environment, adding parent path of notebook to see if it works')\n",
" sys.path.append(os.path.abspath(os.path.join('..', '..', 'xbeach-toolbox')))"
]
},
{
Expand Down
Loading

0 comments on commit 89284bf

Please sign in to comment.