Skip to content

Commit e15c6e6

Browse files
authored
Merge pull request #71 from lagru/prep-euroscipy22
Prepare tooling and lectures for EuroSciPy 2022
2 parents e06284c + 4ae63bb commit e15c6e6

File tree

7 files changed

+53
-47
lines changed

7 files changed

+53
-47
lines changed

.github/workflows/deploy.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
-screen 0 1920x1200x24 -ac +extension GLX
5151
# Install Python dependencies
5252
pip install --upgrade pip
53-
pip install -r requirements.txt
53+
pip install -r requirements.txt -r requirements_dev.txt
5454
# Install Node.js dependencies
5555
# TODO Uncomment when skimage theme is ready
5656
# npm install -g npm

check_setup.py

+16-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1+
"""Check if runtime dependencies are installed.
2+
3+
The script currently does not check for specified optional requirements, e.g.
4+
'scikit-image[data]'.
5+
"""
6+
17
import sys
28
import os
3-
from distutils.version import LooseVersion
9+
from packaging.version import parse
410

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

1723
pkg_names = {
24+
'scikit-image[data]': 'skimage',
1825
'scikit-image': 'skimage',
1926
'scikit-learn': 'sklearn'
2027
}
@@ -23,7 +30,11 @@
2330
module_name = pkg_names.get(pkg, pkg)
2431
try:
2532
m = __import__(module_name)
26-
status = '✓'
33+
version_installed = m.__version__
34+
if parse(version_wanted) > parse(version_installed):
35+
status = 'X'
36+
else:
37+
status = '✓'
2738
except ImportError as e:
2839
m = None
2940
if (pkg != 'numpy' and 'numpy' in str(e)):
@@ -32,11 +43,6 @@
3243
else:
3344
version_installed = 'Not installed'
3445
status = 'X'
35-
36-
if m is not None:
37-
version_installed = m.__version__
38-
if LooseVersion(version_wanted) > LooseVersion(version_installed):
39-
status = 'X'
40-
print('[{}] {:<11} {}'.format(
41-
status, pkg.ljust(13), version_installed)
42-
)
46+
print(
47+
'[{}] {:<20} {}'.format(status, pkg.ljust(13), version_installed)
48+
)

lectures/4_segmentation.ipynb

+7-7
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"source": [
2222
"# Segmentation\n",
2323
"\n",
24-
"--------------\n",
24+
"\n",
2525
"\n",
2626
"## Separating an image into one or more regions of interest.\n",
2727
"\n",
@@ -259,13 +259,13 @@
259259
" \"\"\"Generate points defining a circle on an image.\"\"\"\n",
260260
" radians = np.linspace(0, 2*np.pi, resolution)\n",
261261
"\n",
262-
" c = center[1] + radius*np.cos(radians)\n",
263262
" r = center[0] + radius*np.sin(radians)\n",
263+
" c = center[1] + radius*np.cos(radians)\n",
264264
" \n",
265-
" return np.array([c, r]).T\n",
265+
" return np.array([r, c]).T\n",
266266
"\n",
267267
"# Exclude last point because a closed path should not have duplicate points\n",
268-
"points = circle_points(200, [100, 220], 100)[:-1]"
268+
"points = circle_points(resolution=200, center=[100, 220], radius=100)[:-1]"
269269
]
270270
},
271271
{
@@ -284,8 +284,8 @@
284284
"outputs": [],
285285
"source": [
286286
"fig, ax = image_show(astronaut)\n",
287-
"ax.plot(points[:, 0], points[:, 1], '--r', lw=3)\n",
288-
"ax.plot(snake[:, 0], snake[:, 1], '-b', lw=3);"
287+
"ax.plot(points[:, 1], points[:, 0], '--r', lw=3)\n",
288+
"ax.plot(snake[:, 1], snake[:, 0], '-b', lw=3);"
289289
]
290290
},
291291
{
@@ -338,7 +338,7 @@
338338
"indices = draw.circle_perimeter(100, 220, 25)\n",
339339
"\n",
340340
"astronaut_labels[indices] = 1\n",
341-
"astronaut_labels[points[:, 1].astype(int), points[:, 0].astype(int)] = 2\n",
341+
"astronaut_labels[points[:, 0].astype(int), points[:, 1].astype(int)] = 2\n",
342342
"\n",
343343
"image_show(astronaut_labels);"
344344
]

lectures/solutions/4_segmentation.ipynb

+8-10
Original file line numberDiff line numberDiff line change
@@ -343,18 +343,16 @@
343343
"outputs": [],
344344
"source": [
345345
"def circle_points(resolution, center, radius):\n",
346-
" \"\"\"\n",
347-
" Generate points defining a circle on an image.\n",
348-
" \"\"\"\n",
346+
" \"\"\"Generate points defining a circle on an image.\"\"\"\n",
349347
" radians = np.linspace(0, 2*np.pi, resolution)\n",
350348
"\n",
351-
" c = center[1] + radius*np.cos(radians)\n",
352349
" r = center[0] + radius*np.sin(radians)\n",
350+
" c = center[1] + radius*np.cos(radians)\n",
353351
" \n",
354-
" return np.array([c, r]).T\n",
352+
" return np.array([r, c]).T\n",
355353
"\n",
356354
"# Exclude last point because a closed path should not have duplicate points\n",
357-
"points = circle_points(200, [100, 220], 100)[:-1]"
355+
"points = circle_points(resolution=200, center=[100, 220], radius=100)[:-1]"
358356
]
359357
},
360358
{
@@ -363,7 +361,7 @@
363361
"metadata": {},
364362
"outputs": [],
365363
"source": [
366-
"snake = seg.active_contour(astronaut_gray, points, alpha=0.1, w_edge=1.3)"
364+
"snake = seg.active_contour(astronaut_gray, points, alpha=0.1)"
367365
]
368366
},
369367
{
@@ -390,8 +388,8 @@
390388
],
391389
"source": [
392390
"fig, ax = image_show(astronaut)\n",
393-
"ax.plot(points[:, 0], points[:, 1], '--r', lw=3)\n",
394-
"ax.plot(snake[:, 0], snake[:, 1], '-b', lw=3);"
391+
"ax.plot(points[:, 1], points[:, 0], '--r', lw=3)\n",
392+
"ax.plot(snake[:, 1], snake[:, 0], '-b', lw=3);"
395393
]
396394
},
397395
{
@@ -461,7 +459,7 @@
461459
"indices = draw.circle_perimeter(100, 220, 25)\n",
462460
"\n",
463461
"astronaut_labels[indices] = 1\n",
464-
"astronaut_labels[points[:, 1].astype(np.int), points[:, 0].astype(np.int)] = 2\n",
462+
"astronaut_labels[points[:, 0].astype(int), points[:, 1].astype(int)] = 2\n",
465463
"\n",
466464
"image_show(astronaut_labels);"
467465
]

preparation.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ required packages installed in order to participate fully.
1616
Everyone else, feel free to use your favorite distribution, but
1717
please ensure the requirements below are met:
1818

19-
- `numpy` >= 1.12
20-
- `scipy` >= 1.0
21-
- `matplotlib` >= 2.1
22-
- `scikit-image` >= 0.15
23-
- `scikit-learn` >= 0.18
19+
- `numpy` >= 1.21
20+
- `scipy` >= 1.7
21+
- `matplotlib` >= 3.5
22+
- `scikit-image` >= 0.19
23+
- `scikit-learn` >= 1.0
24+
- `notebook` >= 6.4 (or `jupyterlab` >= 3.3)
2425

2526
Please see "Test your setup" below.
2627

requirements.txt

+6-14
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
scikit-image[data] >= 0.19
2-
numpy >= 1.12
3-
scipy >= 1.0
4-
matplotlib >= 2.1
5-
notebook >= 4.0
6-
scikit-learn >= 0.18
7-
jupyter-book >= 0.10.2
8-
napari[all]
9-
jupytext >=1.10.3
10-
sphinx_autodoc_typehints>=1.11.0
11-
ghp-import
12-
pytest
13-
pytest-qt
14-
pooch
15-
furo
2+
numpy >= 1.21
3+
scipy >= 1.7
4+
matplotlib >= 3.5
5+
notebook >= 6.4
6+
scikit-learn >= 1.0
7+
packaging >= 21.3

requirements_dev.txt

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
jupyter-book >= 0.10.2
2+
napari[all]
3+
jupytext >=1.10.3
4+
sphinx_autodoc_typehints>=1.11.0
5+
ghp-import
6+
pytest
7+
pytest-qt
8+
pooch
9+
furo

0 commit comments

Comments
 (0)