PEP8: comparison

This commit is contained in:
François Boulogne
2013-10-02 18:14:20 +02:00
parent 27d1a5e70a
commit 741d6fda95
3 changed files with 6 additions and 6 deletions
+1 -1
View File
@@ -256,7 +256,7 @@ class Video(object):
Backend to use.
"""
def __init__(self, source=None, size=None, sync=False, backend=None):
if backend == None:
if backend is None:
# select backend that is available
if gstreamer_available:
self.video = GstVideo(source, size, sync)
+1 -1
View File
@@ -133,7 +133,7 @@ def reconstruction(seed, mask, method='dilation', selem=None, offset=None):
else:
selem = selem.copy()
if offset == None:
if offset is None:
if not all([d % 2 == 1 for d in selem.shape]):
ValueError("Footprint dimensions must all be odd")
offset = np.array([d // 2 for d in selem.shape])
+4 -4
View File
@@ -124,13 +124,13 @@ def watershed(image, markers, connectivity=None, offset=None, mask=None):
separate overlapping spheres.
"""
if connectivity == None:
if connectivity is None:
c_connectivity = scipy.ndimage.generate_binary_structure(image.ndim, 1)
else:
c_connectivity = np.array(connectivity, bool)
if c_connectivity.ndim != image.ndim:
raise ValueError("Connectivity dimension must be same as image")
if offset == None:
if offset is None:
if any([x % 2 == 0 for x in c_connectivity.shape]):
raise ValueError("Connectivity array must have an unambiguous "
"center")
@@ -162,7 +162,7 @@ def watershed(image, markers, connectivity=None, offset=None, mask=None):
"as image (ndim=%d)" % (c_markers.ndim, c_image.ndim))
if c_markers.shape != c_image.shape:
raise ValueError("image and markers must have the same shape")
if mask != None:
if mask is not None:
c_mask = np.ascontiguousarray(mask, dtype=bool)
if c_mask.ndim != c_markers.ndim:
raise ValueError("mask must have same # of dimensions as image")
@@ -398,7 +398,7 @@ def _slow_watershed(image, markers, connectivity=8, mask=None):
continue
if labels[x, y]:
continue
if mask != None and not mask[x, y]:
if mask is not None and not mask[x, y]:
continue
# label the pixel
labels[x, y] = pix_label