Skip to content

Commit

Permalink
Merge pull request #71 from lagru/prep-euroscipy22
Browse files Browse the repository at this point in the history
Prepare tooling and lectures for EuroSciPy 2022
  • Loading branch information
emmanuelle authored Aug 28, 2022
2 parents e06284c + 4ae63bb commit e15c6e6
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
-screen 0 1920x1200x24 -ac +extension GLX
# Install Python dependencies
pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements.txt -r requirements_dev.txt
# Install Node.js dependencies
# TODO Uncomment when skimage theme is ready
# npm install -g npm
Expand Down
26 changes: 16 additions & 10 deletions check_setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
"""Check if runtime dependencies are installed.
The script currently does not check for specified optional requirements, e.g.
'scikit-image[data]'.
"""

import sys
import os
from distutils.version import LooseVersion
from packaging.version import parse

if sys.version_info.major < 3:
print('[!] You are running an old version of Python. '
Expand All @@ -15,6 +21,7 @@
(req.split() for req in reqs if req.strip())]

pkg_names = {
'scikit-image[data]': 'skimage',
'scikit-image': 'skimage',
'scikit-learn': 'sklearn'
}
Expand All @@ -23,7 +30,11 @@
module_name = pkg_names.get(pkg, pkg)
try:
m = __import__(module_name)
status = '✓'
version_installed = m.__version__
if parse(version_wanted) > parse(version_installed):
status = 'X'
else:
status = '✓'
except ImportError as e:
m = None
if (pkg != 'numpy' and 'numpy' in str(e)):
Expand All @@ -32,11 +43,6 @@
else:
version_installed = 'Not installed'
status = 'X'

if m is not None:
version_installed = m.__version__
if LooseVersion(version_wanted) > LooseVersion(version_installed):
status = 'X'
print('[{}] {:<11} {}'.format(
status, pkg.ljust(13), version_installed)
)
print(
'[{}] {:<20} {}'.format(status, pkg.ljust(13), version_installed)
)
14 changes: 7 additions & 7 deletions lectures/4_segmentation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"source": [
"# Segmentation\n",
"\n",
"--------------\n",
"\n",
"\n",
"## Separating an image into one or more regions of interest.\n",
"\n",
Expand Down Expand Up @@ -259,13 +259,13 @@
" \"\"\"Generate points defining a circle on an image.\"\"\"\n",
" radians = np.linspace(0, 2*np.pi, resolution)\n",
"\n",
" c = center[1] + radius*np.cos(radians)\n",
" r = center[0] + radius*np.sin(radians)\n",
" c = center[1] + radius*np.cos(radians)\n",
" \n",
" return np.array([c, r]).T\n",
" return np.array([r, c]).T\n",
"\n",
"# Exclude last point because a closed path should not have duplicate points\n",
"points = circle_points(200, [100, 220], 100)[:-1]"
"points = circle_points(resolution=200, center=[100, 220], radius=100)[:-1]"
]
},
{
Expand All @@ -284,8 +284,8 @@
"outputs": [],
"source": [
"fig, ax = image_show(astronaut)\n",
"ax.plot(points[:, 0], points[:, 1], '--r', lw=3)\n",
"ax.plot(snake[:, 0], snake[:, 1], '-b', lw=3);"
"ax.plot(points[:, 1], points[:, 0], '--r', lw=3)\n",
"ax.plot(snake[:, 1], snake[:, 0], '-b', lw=3);"
]
},
{
Expand Down Expand Up @@ -338,7 +338,7 @@
"indices = draw.circle_perimeter(100, 220, 25)\n",
"\n",
"astronaut_labels[indices] = 1\n",
"astronaut_labels[points[:, 1].astype(int), points[:, 0].astype(int)] = 2\n",
"astronaut_labels[points[:, 0].astype(int), points[:, 1].astype(int)] = 2\n",
"\n",
"image_show(astronaut_labels);"
]
Expand Down
18 changes: 8 additions & 10 deletions lectures/solutions/4_segmentation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -343,18 +343,16 @@
"outputs": [],
"source": [
"def circle_points(resolution, center, radius):\n",
" \"\"\"\n",
" Generate points defining a circle on an image.\n",
" \"\"\"\n",
" \"\"\"Generate points defining a circle on an image.\"\"\"\n",
" radians = np.linspace(0, 2*np.pi, resolution)\n",
"\n",
" c = center[1] + radius*np.cos(radians)\n",
" r = center[0] + radius*np.sin(radians)\n",
" c = center[1] + radius*np.cos(radians)\n",
" \n",
" return np.array([c, r]).T\n",
" return np.array([r, c]).T\n",
"\n",
"# Exclude last point because a closed path should not have duplicate points\n",
"points = circle_points(200, [100, 220], 100)[:-1]"
"points = circle_points(resolution=200, center=[100, 220], radius=100)[:-1]"
]
},
{
Expand All @@ -363,7 +361,7 @@
"metadata": {},
"outputs": [],
"source": [
"snake = seg.active_contour(astronaut_gray, points, alpha=0.1, w_edge=1.3)"
"snake = seg.active_contour(astronaut_gray, points, alpha=0.1)"
]
},
{
Expand All @@ -390,8 +388,8 @@
],
"source": [
"fig, ax = image_show(astronaut)\n",
"ax.plot(points[:, 0], points[:, 1], '--r', lw=3)\n",
"ax.plot(snake[:, 0], snake[:, 1], '-b', lw=3);"
"ax.plot(points[:, 1], points[:, 0], '--r', lw=3)\n",
"ax.plot(snake[:, 1], snake[:, 0], '-b', lw=3);"
]
},
{
Expand Down Expand Up @@ -461,7 +459,7 @@
"indices = draw.circle_perimeter(100, 220, 25)\n",
"\n",
"astronaut_labels[indices] = 1\n",
"astronaut_labels[points[:, 1].astype(np.int), points[:, 0].astype(np.int)] = 2\n",
"astronaut_labels[points[:, 0].astype(int), points[:, 1].astype(int)] = 2\n",
"\n",
"image_show(astronaut_labels);"
]
Expand Down
11 changes: 6 additions & 5 deletions preparation.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ required packages installed in order to participate fully.
Everyone else, feel free to use your favorite distribution, but
please ensure the requirements below are met:

- `numpy` >= 1.12
- `scipy` >= 1.0
- `matplotlib` >= 2.1
- `scikit-image` >= 0.15
- `scikit-learn` >= 0.18
- `numpy` >= 1.21
- `scipy` >= 1.7
- `matplotlib` >= 3.5
- `scikit-image` >= 0.19
- `scikit-learn` >= 1.0
- `notebook` >= 6.4 (or `jupyterlab` >= 3.3)

Please see "Test your setup" below.

Expand Down
20 changes: 6 additions & 14 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
scikit-image[data] >= 0.19
numpy >= 1.12
scipy >= 1.0
matplotlib >= 2.1
notebook >= 4.0
scikit-learn >= 0.18
jupyter-book >= 0.10.2
napari[all]
jupytext >=1.10.3
sphinx_autodoc_typehints>=1.11.0
ghp-import
pytest
pytest-qt
pooch
furo
numpy >= 1.21
scipy >= 1.7
matplotlib >= 3.5
notebook >= 6.4
scikit-learn >= 1.0
packaging >= 21.3
9 changes: 9 additions & 0 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
jupyter-book >= 0.10.2
napari[all]
jupytext >=1.10.3
sphinx_autodoc_typehints>=1.11.0
ghp-import
pytest
pytest-qt
pooch
furo

0 comments on commit e15c6e6

Please sign in to comment.