Skip to content
This repository has been archived by the owner on Feb 11, 2023. It is now read-only.

Commit

Permalink
struct. docs
Browse files Browse the repository at this point in the history
* flake8
  • Loading branch information
Borda committed May 22, 2020
1 parent 104094d commit 421a778
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 19 deletions.
9 changes: 6 additions & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
'data-images',
'*tests.*', '*.test_*',
'*.so', '*.dll',
'modules.rst',
'api/modules.rst',
'*/transform-img-plane_inter-circle.ipynb'
]

Expand Down Expand Up @@ -258,8 +258,11 @@

def run_apidoc(_):
for pkg in PACKAGES:
argv = ['-e', '-o', PATH_HERE, os.path.join(PATH_HERE, PATH_ROOT, pkg),
'tests/*', '--force']
argv = ['-e',
'-o', os.path.join(PATH_HERE, 'api'),
os.path.join(PATH_HERE, PATH_ROOT, pkg),
'tests/*',
'--force']
try:
# Sphinx 1.7+
from sphinx.ext import apidoc
Expand Down
2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Contents
:maxdepth: 2

readme
imsegm
api/imsegm
examples

Indices and tables
Expand Down
4 changes: 2 additions & 2 deletions imsegm/classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,8 @@ def compute_classif_metrics(y_true, y_pred, metric_averages=METRIC_AVERAGES):
eval_str = 'EVALUATION: {:<2} PRE: {:.3f} REC: {:.3f} F1: {:.3f} S: {:>6}'
try:
p, r, f, s = metrics.precision_recall_fscore_support(y_true, y_pred)
for l, _ in enumerate(p):
logging.debug(eval_str.format(l, p[l], r[l], f[l], s[l]))
for lb, _ in enumerate(p):
logging.debug(eval_str.format(lb, p[lb], r[lb], f[lb], s[lb]))
except Exception:
logging.exception('metrics.precision_recall_fscore_support')

Expand Down
6 changes: 3 additions & 3 deletions imsegm/labeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,8 @@ def mask_segm_labels(img_labeling, labels, mask_init=None):
mask = np.full(img_labeling.shape, False, dtype=bool)
else:
mask = mask_init.copy()
for l in labels:
mask = np.logical_or(mask, (img_labeling == l))
for lb in labels:
mask = np.logical_or(mask, (img_labeling == lb))
return mask


Expand Down Expand Up @@ -422,7 +422,7 @@ def sequence_labels_merge(labels_stack, dict_colors, labels_free, change_label=-
im_labels = np.full(labels_stack.shape[1:], change_label, dtype=np.int)
labels_used = [lb for lb in dict_colors if lb not in labels_free]
lb_all = labels_used + labels_free + [change_label]
assert all(l in lb_all for l in np.unique(labels_stack)), 'some extra labels in image stack'
assert all(lb in lb_all for lb in np.unique(labels_stack)), 'some extra labels in image stack'
# generate mask of free labels
mask_free = mask_segm_labels(labels_stack, labels_free)
for lb in labels_used:
Expand Down
2 changes: 1 addition & 1 deletion imsegm/region_growing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1371,7 +1371,7 @@ def prepare_graphcut_variables(candidates, slic_points, slic_neighbours,
assert np.max(candidates) < len(slic_points), \
'max candidate idx: %d for %d centres' \
% (np.max(candidates), len(slic_points))
max_slic_neighbours = max(max(l) for l in slic_neighbours)
max_slic_neighbours = max(max(lb) for lb in slic_neighbours)
assert max_slic_neighbours < len(slic_points), \
'max slic neighbours idx: %d for %d centres' \
% (max_slic_neighbours, len(slic_points))
Expand Down
8 changes: 4 additions & 4 deletions imsegm/utilities/data_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ def sample_segment_vertical_2d(seg_size=SAMPLE_SEG_SIZE_2D_SMALL,
"""
cls_vals = []
cls_size = (seg_size[1], int(seg_size[0] / nb_labels))
for l in range(nb_labels):
cls_vals.append(l * np.ones(cls_size))
for lb in range(nb_labels):
cls_vals.append(lb * np.ones(cls_size))
seg = np.hstack(tuple(cls_vals))
seg = np.array(seg, dtype=np.int)
return seg
Expand All @@ -108,10 +108,10 @@ def sample_segment_vertical_3d(seg_size=SAMPLE_SEG_SIZE_3D_SMALL,
[4, 4, 4, 4, 4]])
"""
seg = []
for l in range(int(levels)):
for lb in range(int(levels)):
seg_2d = sample_segment_vertical_2d(seg_size[:2], nb_labels)
for _ in range(int(seg_size[2] / levels)):
seg.append(seg_2d.copy() + l * nb_labels)
seg.append(seg_2d.copy() + lb * nb_labels)
seg = np.array(seg, dtype=np.int)
return seg

Expand Down
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ def finalize_options(self):
def _parse_requirements(file_path):
with open(file_path) as fp:
reqs = [r.rstrip() for r in fp.readlines() if not r.startswith('#')]
# drop all proprietary packages missing from PiPy
reqs = filter(lambda r: not r.startswith('http'), reqs)
# parse egg names if there are paths
reqs = [r[r.index(TEMP_EGG) + len(TEMP_EGG):] if TEMP_EGG in r else r for r in reqs]
return reqs
# drop all proprietary packages missing from PiPy
reqs = filter(lambda r: not r.startswith('http'), reqs)
# parse egg names if there are paths
reqs = [r[r.index(TEMP_EGG) + len(TEMP_EGG):] if TEMP_EGG in r else r for r in reqs]
return reqs


setup_reqs = ['Cython', 'numpy'] # numpy v1.17 drops support for py2
Expand Down

0 comments on commit 421a778

Please sign in to comment.