From patchwork Tue May 12 00:03:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 3763 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 49AB060DFD for ; Tue, 12 May 2020 02:03:37 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="bmOpZ7l7"; dkim-atps=neutral Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id CC37511F3; Tue, 12 May 2020 02:03:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1589241817; bh=4sMYn1cJBGuuSh8FWbz9/sstOgpWR4dBKg1PDOeKqV8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bmOpZ7l7K/tyb4gCGXHPwl3e25o5q5KYGBw4TtFSBLg88o9uBcF1sV0LgP24vJuIn fKSPZ1ikWK7gvBTwzZt/srypvddjVYSx4kqk+p3GyFWKBrmpcmOlc5cJrqsSfJsUot gjzQpqE62jXICkaVmE6iDt3zJYWr52tPc2QQ0aKE= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Tue, 12 May 2020 03:03:07 +0300 Message-Id: <20200512000322.11753-10-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200512000322.11753-1-laurent.pinchart@ideasonboard.com> References: <20200512000322.11753-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 09/24] utils: raspberrypi: ctt: Fix pycodestyle E228 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 May 2020 00:03:39 -0000 E228 missing whitespace around modulo operator Signed-off-by: Laurent Pinchart --- utils/raspberrypi/ctt/ctt_alsc.py | 12 ++++++------ utils/raspberrypi/ctt/ctt_awb.py | 10 +++++----- utils/raspberrypi/ctt/ctt_ccm.py | 4 ++-- utils/raspberrypi/ctt/ctt_image_load.py | 12 ++++++------ utils/raspberrypi/ctt/ctt_tools.py | 2 +- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/utils/raspberrypi/ctt/ctt_alsc.py b/utils/raspberrypi/ctt/ctt_alsc.py index d6e1020f1ccc..e768f8d648a1 100644 --- a/utils/raspberrypi/ctt/ctt_alsc.py +++ b/utils/raspberrypi/ctt/ctt_alsc.py @@ -61,10 +61,10 @@ def alsc_all(Cam, do_alsc_colour, plot): """ force numbers to be stored to 3dp.... :( """ - t_r = np.where((100*t_r)%1 <= 0.05, t_r+0.001, t_r) - t_b = np.where((100*t_b)%1 <= 0.05, t_b+0.001, t_b) - t_r = np.where((100*t_r)%1 >= 0.95, t_r-0.001, t_r) - t_b = np.where((100*t_b)%1 >= 0.95, t_b-0.001, t_b) + t_r = np.where((100*t_r) % 1 <= 0.05, t_r+0.001, t_r) + t_b = np.where((100*t_b) % 1 <= 0.05, t_b+0.001, t_b) + t_r = np.where((100*t_r) % 1 >= 0.95, t_r-0.001, t_r) + t_b = np.where((100*t_b) % 1 >= 0.95, t_b-0.001, t_b) t_r = np.round(t_r, 3) t_b = np.round(t_b, 3) r_corners = (t_r[0], t_r[15], t_r[-1], t_r[-16]) @@ -95,8 +95,8 @@ def alsc_all(Cam, do_alsc_colour, plot): average all values for luminance shading and return one table for all temperatures """ lum_lut = np.mean(list_cg, axis=0) - lum_lut = np.where((100*lum_lut)%1 <= 0.05, lum_lut+0.001, lum_lut) - lum_lut = np.where((100*lum_lut)%1 >= 0.95, lum_lut-0.001, lum_lut) + lum_lut = np.where((100*lum_lut) % 1 <= 0.05, lum_lut+0.001, lum_lut) + lum_lut = np.where((100*lum_lut) % 1 >= 0.95, lum_lut-0.001, lum_lut) lum_lut = list(np.round(lum_lut, 3)) """ diff --git a/utils/raspberrypi/ctt/ctt_awb.py b/utils/raspberrypi/ctt/ctt_awb.py index 3abafbf550b0..58ef8432fb86 100644 --- a/utils/raspberrypi/ctt/ctt_awb.py +++ b/utils/raspberrypi/ctt/ctt_awb.py @@ -183,10 +183,10 @@ def awb(Cam, cal_cr_list, cal_cb_list, plot): """ round to 4dp """ - r_fit = np.where((1000*r_fit)%1 <= 0.05, r_fit+0.0001, r_fit) - r_fit = np.where((1000*r_fit)%1 >= 0.95, r_fit-0.0001, r_fit) - b_fit = np.where((1000*b_fit)%1 <= 0.05, b_fit+0.0001, b_fit) - b_fit = np.where((1000*b_fit)%1 >= 0.95, b_fit-0.0001, b_fit) + r_fit = np.where((1000*r_fit) % 1 <= 0.05, r_fit+0.0001, r_fit) + r_fit = np.where((1000*r_fit) % 1 >= 0.95, r_fit-0.0001, r_fit) + b_fit = np.where((1000*b_fit) % 1 <= 0.05, b_fit+0.0001, b_fit) + b_fit = np.where((1000*b_fit) % 1 >= 0.95, b_fit-0.0001, b_fit) r_fit = np.round(r_fit, 4) b_fit = np.round(b_fit, 4) """ @@ -326,7 +326,7 @@ def get_alsc_patches(Img, colour_cals, grey=True): if img colour is below minimum or above maximum alsc calibration colour, simply pick extreme closest to img colour """ - if pos%(len(cts)) == 0: + if pos % len(cts) == 0: """ this works because -0 = 0 = first and -1 = last index """ diff --git a/utils/raspberrypi/ctt/ctt_ccm.py b/utils/raspberrypi/ctt/ctt_ccm.py index 52fd9744332a..adc4d290ae7e 100644 --- a/utils/raspberrypi/ctt/ctt_ccm.py +++ b/utils/raspberrypi/ctt/ctt_ccm.py @@ -135,8 +135,8 @@ def ccm(Cam, cal_cr_list, cal_cb_list): """ for k, v in ccm_tab.items(): tab = np.mean(v, axis=0) - tab = np.where((10000*tab)%1 <= 0.05, tab+0.00001, tab) - tab = np.where((10000*tab)%1 >= 0.95, tab-0.00001, tab) + tab = np.where((10000*tab) % 1 <= 0.05, tab+0.00001, tab) + tab = np.where((10000*tab) % 1 >= 0.95, tab-0.00001, tab) ccm_tab[k] = list(np.round(tab, 5)) Cam.log += '\nMatrix calculated for colour temperature of {} K'.format(k) diff --git a/utils/raspberrypi/ctt/ctt_image_load.py b/utils/raspberrypi/ctt/ctt_image_load.py index 035256e3fd0b..584e0f8ebaa5 100644 --- a/utils/raspberrypi/ctt/ctt_image_load.py +++ b/utils/raspberrypi/ctt/ctt_image_load.py @@ -112,10 +112,10 @@ class Image: """ assemble 10 bit numbers """ - ch0 = np.left_shift((np.left_shift(ba0, 2) + (ba4%4)), 6) - ch1 = np.left_shift((np.left_shift(ba1, 2) + (np.right_shift(ba4, 2)%4)), 6) - ch2 = np.left_shift((np.left_shift(ba2, 2) + (np.right_shift(ba4, 4)%4)), 6) - ch3 = np.left_shift((np.left_shift(ba3, 2) + (np.right_shift(ba4, 6)%4)), 6) + ch0 = np.left_shift((np.left_shift(ba0, 2) + (ba4 % 4)), 6) + ch1 = np.left_shift((np.left_shift(ba1, 2) + (np.right_shift(ba4, 2) % 4)), 6) + ch2 = np.left_shift((np.left_shift(ba2, 2) + (np.right_shift(ba4, 4) % 4)), 6) + ch3 = np.left_shift((np.left_shift(ba3, 2) + (np.right_shift(ba4, 6) % 4)), 6) """ interleave bits """ @@ -146,8 +146,8 @@ class Image: ba0 = raw[..., 0:3*((self.w+1)>>1):3] ba1 = raw[..., 1:3*((self.w+1)>>1):3] ba2 = raw[..., 2:3*((self.w+1)>>1):3] - ch0 = np.left_shift((np.left_shift(ba0, 4) + ba2%16), 4) - ch1 = np.left_shift((np.left_shift(ba1, 4) + (np.right_shift(ba2, 4))%16), 4) + ch0 = np.left_shift((np.left_shift(ba0, 4) + ba2 % 16), 4) + ch1 = np.left_shift((np.left_shift(ba1, 4) + (np.right_shift(ba2, 4)) % 16), 4) mat = np.empty((self.h, self.w), dtype=ch0.dtype) mat[..., 0::2] = ch0 mat[..., 1::2] = ch1 diff --git a/utils/raspberrypi/ctt/ctt_tools.py b/utils/raspberrypi/ctt/ctt_tools.py index f00f2bbc8299..e5871b60d6a2 100644 --- a/utils/raspberrypi/ctt/ctt_tools.py +++ b/utils/raspberrypi/ctt/ctt_tools.py @@ -53,7 +53,7 @@ argument parser """ def parse_input(): arguments = sys.argv[1:] - if len(arguments)%2 != 0: + if len(arguments) % 2 != 0: raise ArgError('\n\nERROR! Enter value for each arguent passed.') params = arguments[0::2] vals = arguments[1::2]