Skip to content

Commit cf2cac1

Browse files
committed
style: simplify colab setup block
1 parent f6ae8b8 commit cf2cac1

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

Python/01_Image_Basics.ipynb

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,19 @@
2323
"outputs": [],
2424
"source": [
2525
"# Setup to enable running the notebook in the Google Colab environment\n",
26-
"import pathlib\n",
2726
"\n",
28-
"def _in_colab() -> bool:\n",
29-
" try:\n",
30-
" import google.colab # noqa: F401\n",
31-
" return True\n",
32-
" except Exception:\n",
33-
" return False\n",
27+
"try:\n",
28+
" import google.colab # noqa: F401\n",
29+
" import pathlib\n",
3430
"\n",
35-
"if _in_colab():\n",
3631
" repo_dir = pathlib.Path(\"SimpleITK-Notebooks\")\n",
3732
" if not repo_dir.exists():\n",
3833
" !git clone --depth 1 https://github.com/InsightSoftwareConsortium/SimpleITK-Notebooks\n",
3934
" %cd SimpleITK-Notebooks/Python\n",
40-
" !pip install -q -r requirements.txt\n"
35+
" !pip install -q -r requirements.txt\n",
36+
"\n",
37+
"except ImportError:\n",
38+
" pass # not on Colab\n"
4139
]
4240
},
4341
{

0 commit comments

Comments
 (0)