From ee0fd867daecc442d022c4a1812af4da104cf4e0 Mon Sep 17 00:00:00 2001 From: Andreas Mueller Date: Fri, 22 Jun 2012 23:40:42 +0200 Subject: [PATCH] COSMIT fix ugly line breaks. --- skimage/filter/tests/test_tv_denoise.py | 4 ++-- skimage/filter/tv_denoise.py | 4 ++-- skimage/graph/tests/test_mcp.py | 2 +- skimage/io/_plugins/q_color_mixer.py | 7 +++---- skimage/io/_plugins/util.py | 5 ++--- skimage/io/collection.py | 8 ++++---- skimage/io/tests/test_freeimage.py | 4 ++-- skimage/io/tests/test_plugin_util.py | 3 +-- skimage/io/video.py | 24 ++++++++++++------------ 9 files changed, 29 insertions(+), 32 deletions(-) diff --git a/skimage/filter/tests/test_tv_denoise.py b/skimage/filter/tests/test_tv_denoise.py index 323c40cb..27db4894 100644 --- a/skimage/filter/tests/test_tv_denoise.py +++ b/skimage/filter/tests/test_tv_denoise.py @@ -27,8 +27,8 @@ class TestTvDenoise(): grad_denoised = ndimage.morphological_gradient( denoised_lena, size=((3, 3))) # test if the total variation has decreased - assert np.sqrt( - (grad_denoised ** 2).sum()) < np.sqrt((grad ** 2).sum()) / 2 + assert (np.sqrt((grad_denoised ** 2).sum()) + < np.sqrt((grad ** 2).sum()) / 2) denoised_lena_int = filter.tv_denoise(img_as_uint(lena), weight=60.0, keep_type=True) assert denoised_lena_int.dtype is np.dtype('uint16') diff --git a/skimage/filter/tv_denoise.py b/skimage/filter/tv_denoise.py index db45d63e..37abdbb5 100644 --- a/skimage/filter/tv_denoise.py +++ b/skimage/filter/tv_denoise.py @@ -252,8 +252,8 @@ def tv_denoise(im, weight=50, eps=2.e-4, keep_type=False, n_iter_max=200): elif im.ndim == 3: out = _tv_denoise_3d(im, weight, eps, n_iter_max) else: - raise ValueError( - 'only 2-d and 3-d images may be denoised with this function') + raise ValueError('only 2-d and 3-d images may be denoised with this' + 'function') if keep_type: return out.astype(im_type) else: diff --git a/skimage/graph/tests/test_mcp.py b/skimage/graph/tests/test_mcp.py index f983d87f..e7b75cdc 100644 --- a/skimage/graph/tests/test_mcp.py +++ b/skimage/graph/tests/test_mcp.py @@ -145,7 +145,7 @@ def _test_random(shape): starts = [[0] * len(shape), [-1] * len(shape), (np.random.random(len(shape)) * shape).astype(int)] ends = [(np.random.random(len(shape)) * shape).astype(int) - for i in range(4)] + for i in range(4)] m = mcp.MCP(a, fully_connected=True) costs, offsets = m.find_costs(starts) for point in [(np.random.random(len(shape)) * shape).astype(int) diff --git a/skimage/io/_plugins/q_color_mixer.py b/skimage/io/_plugins/q_color_mixer.py index 5b6a461a..3fe9e29c 100644 --- a/skimage/io/_plugins/q_color_mixer.py +++ b/skimage/io/_plugins/q_color_mixer.py @@ -1,7 +1,6 @@ # the module for the qt color_mixer plugin from PyQt4 import QtGui, QtCore -from PyQt4.QtGui import (QWidget, QStackedWidget, QSlider, QVBoxLayout, - QGridLayout, QLabel) +from PyQt4.QtGui import (QWidget, QStackedWidget, QSlider, QGridLayout, QLabel) from util import ColorMixer @@ -36,8 +35,8 @@ class IntelligentSlider(QWidget): self.name_label.setAlignment(QtCore.Qt.AlignCenter) self.value_label = QLabel() - self.value_label.setText( - '%2.2f' % (self.slider.value() * self.a + self.b)) + self.value_label.setText('%2.2f' % (self.slider.value() * self.a + + self.b)) self.value_label.setAlignment(QtCore.Qt.AlignCenter) self.layout = QGridLayout(self) diff --git a/skimage/io/_plugins/util.py b/skimage/io/_plugins/util.py index f40a04a8..7c095e82 100644 --- a/skimage/io/_plugins/util.py +++ b/skimage/io/_plugins/util.py @@ -64,8 +64,8 @@ class WindowManager(object): self._gui_lock = False self._guikit = '' else: - raise RuntimeError( - 'Only the toolkit that owns the lock may release it') + raise RuntimeError('Only the toolkit that owns the lock may' + 'release it') def add_window(self, win): self._check_locked() @@ -191,7 +191,6 @@ class ImgThread(threading.Thread): class ThreadDispatch(object): def __init__(self, img, stateimg, func, *args): - width = img.shape[1] height = img.shape[0] self.cores = CPU_COUNT self.threads = [] diff --git a/skimage/io/collection.py b/skimage/io/collection.py index 973d9b30..e698b52b 100644 --- a/skimage/io/collection.py +++ b/skimage/io/collection.py @@ -118,8 +118,8 @@ class MultiImage(object): if -numframes <= n < numframes: n = n % numframes else: - raise IndexError( - "There are only %s frames in the image" % numframes) + raise IndexError("There are only %s frames in the image" + % numframes) if self.conserve_memory: if not self._cached == n: @@ -280,8 +280,8 @@ class ImageCollection(object): if -num <= n < num: n = n % num else: - raise IndexError( - "There are only %s images in the collection" % num) + raise IndexError("There are only %s images in the collection" + % num) return n def __iter__(self): diff --git a/skimage/io/tests/test_freeimage.py b/skimage/io/tests/test_freeimage.py index e58c18cc..565f37bd 100644 --- a/skimage/io/tests/test_freeimage.py +++ b/skimage/io/tests/test_freeimage.py @@ -85,8 +85,8 @@ def test_metadata(): assert meta[('EXIF_MAIN', 'Orientation')] == 1 assert meta[('EXIF_MAIN', 'Software')].startswith('ImageMagick') - meta = fi.read_multipage_metadata( - os.path.join(si.data_dir, 'multipage.tif')) + meta = fi.read_multipage_metadata(os.path.join(si.data_dir, + 'multipage.tif')) assert len(meta) == 2 assert meta[0][('EXIF_MAIN', 'Orientation')] == 1 assert meta[1][('EXIF_MAIN', 'Software')].startswith('ImageMagick') diff --git a/skimage/io/tests/test_plugin_util.py b/skimage/io/tests/test_plugin_util.py index c302b3f2..09b758d8 100644 --- a/skimage/io/tests/test_plugin_util.py +++ b/skimage/io/tests/test_plugin_util.py @@ -13,8 +13,7 @@ class TestPrepareForDisplay: assert x.dtype == np.dtype(np.uint8) def test_grey(self): - x = prepare_for_display( - np.arange(12, dtype=float).reshape((4, 3)) / 11.) + x = prepare_for_display(np.arange(12, dtype=float).reshape((4, 3)) / 11) assert_array_equal(x[..., 0], x[..., 2]) assert x[0, 0, 0] == 0 assert x[3, 2, 0] == 255 diff --git a/skimage/io/video.py b/skimage/io/video.py index 92d46e9c..6cb1a8e9 100644 --- a/skimage/io/video.py +++ b/skimage/io/video.py @@ -1,6 +1,5 @@ import numpy as np import os -import time from skimage.io import ImageCollection try: @@ -57,8 +56,8 @@ class CvVideo(object): else: cv.Resize(img, cv.fromarray(img_mat)) # opencv stores images in BGR format - cv.CvtColor( - cv.fromarray(img_mat), cv.fromarray(img_mat), cv.CV_BGR2RGB) + cv.CvtColor(cv.fromarray(img_mat), cv.fromarray(img_mat), + cv.CV_BGR2RGB) return img_mat def seek_frame(self, frame_number): @@ -70,8 +69,8 @@ class CvVideo(object): frame_number : int Frame position """ - cv.SetCaptureProperty( - self.capture, cv.CV_CAP_PROP_POS_FRAMES, frame_number) + cv.SetCaptureProperty(self.capture, cv.CV_CAP_PROP_POS_FRAMES, + frame_number) def seek_time(self, milliseconds): """ @@ -82,8 +81,8 @@ class CvVideo(object): milliseconds : int Time position """ - cv.SetCaptureProperty( - self.capture, cv.CV_CAP_PROP_POS_MSEC, milliseconds) + cv.SetCaptureProperty(self.capture, cv.CV_CAP_PROP_POS_MSEC, + milliseconds) def frame_count(self): """ @@ -120,9 +119,9 @@ class GstVideo(object): size: tuple, optional Size of returned array. sync: bool, optional (default False) - Frames are extracted per frame or per time basis. - If enabled the video time step continues onward according to the play rate. - Useful for ip cameras and other real time video feeds. + Frames are extracted per frame or per time basis. If enabled the video + time step continues onward according to the play rate. Useful for ip + cameras and other real time video feeds. """ def __init__(self, source=None, size=None, sync=False): if not gstreamer_available: @@ -178,7 +177,7 @@ class GstVideo(object): self.appsink.set_property('caps', gst.caps_from_string(caps)) if self.pipeline.set_state(gst.STATE_PLAYING) == gst.STATE_CHANGE_FAILURE: raise NameError("Failed to load video source %s" % self.source) - buff = self.appsink.emit('pull-preroll') + self.appsink.emit('pull-preroll') def get(self): """ @@ -190,7 +189,8 @@ class GstVideo(object): Retrieved image. """ buff = self.appsink.emit('pull-buffer') - img_mat = np.ndarray(shape=(self.size[1], self.size[0], 3), dtype=np.uint8, buffer=buff.data) + img_mat = np.ndarray(shape=(self.size[1], self.size[0], 3), + dtype=np.uint8, buffer=buff.data) return img_mat def seek_frame(self, frame_number):