[libcamera-devel] [PATCH 13/24] utils: raspberrypi: ctt: Fix pycodestyle W605

Kieran Bingham kieran.bingham at ideasonboard.com
Thu May 14 11:08:43 CEST 2020


Hi Laurent

On 12/05/2020 17:38, Laurent Pinchart wrote:
> Hi Kieran,
> 
> On Tue, May 12, 2020 at 09:25:59AM +0100, Kieran Bingham wrote:
>> On 12/05/2020 01:03, Laurent Pinchart wrote:
>>> W605 invalid escape sequence '\.'
>>>
>>
>> Would these be better interpreted as a 'raw' string?:
>>
>>> - col = re.search('([0-9]+)[kK](\.(jpg|jpeg|brcm|dng)|_.*\.(jpg|jpeg|brcm|dng))$', string)
>>> + col = re.search(r'([0-9]+)[kK](\.(jpg|jpeg|brcm|dng)|_.*\.(jpg|jpeg|brcm|dng))$', string)
>>
>> That is how I have been handling regexes in python:
>>
>>   https://docs.python.org/3/howto/regex.html#the-backslash-plague
> 
> It's a good point. I'll submit a new version.
> 
> Would you do the same for the strings in ctt_awb.py, or just for the
> regexp ?

the 'r' prefix is 'raw' not 'regexp', so I believe it applies to the
ct_awb.py edits too.

Might be worth testing the change somehow though to make sure it still
works with the matplot component.

I don't see a reason for it not to work ... but still.

--
Regards

Kieran


>>> Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
>>> ---
>>>  utils/raspberrypi/ctt/ctt.py     | 4 ++--
>>>  utils/raspberrypi/ctt/ctt_awb.py | 4 ++--
>>>  2 files changed, 4 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/utils/raspberrypi/ctt/ctt.py b/utils/raspberrypi/ctt/ctt.py
>>> index ff264176f040..4d8d6addf415 100755
>>> --- a/utils/raspberrypi/ctt/ctt.py
>>> +++ b/utils/raspberrypi/ctt/ctt.py
>>> @@ -41,8 +41,8 @@ def get_col_lux(string):
>>>      """
>>>      Extract colour and lux values from filename
>>>      """
>>> -    col = re.search('([0-9]+)[kK](\.(jpg|jpeg|brcm|dng)|_.*\.(jpg|jpeg|brcm|dng))$', string)
>>> -    lux = re.search('([0-9]+)[lL](\.(jpg|jpeg|brcm|dng)|_.*\.(jpg|jpeg|brcm|dng))$', string)
>>> +    col = re.search('([0-9]+)[kK](\\.(jpg|jpeg|brcm|dng)|_.*\\.(jpg|jpeg|brcm|dng))$', string)
>>> +    lux = re.search('([0-9]+)[lL](\\.(jpg|jpeg|brcm|dng)|_.*\\.(jpg|jpeg|brcm|dng))$', string)
>>>      try:
>>>          col = col.group(1)
>>>      except AttributeError:
>>> diff --git a/utils/raspberrypi/ctt/ctt_awb.py b/utils/raspberrypi/ctt/ctt_awb.py
>>> index 58ef8432fb86..e97d833d0e49 100644
>>> --- a/utils/raspberrypi/ctt/ctt_awb.py
>>> +++ b/utils/raspberrypi/ctt/ctt_awb.py
>>> @@ -256,8 +256,8 @@ def awb(Cam, cal_cr_list, cal_cb_list, plot):
>>>          plt.scatter(rbs_hat[0], rbs_hat[1], color='red')
>>>          for i, ct in enumerate(rbs_hat[2]):
>>>              plt.annotate(str(ct), (rbs_hat[0][i], rbs_hat[1][i]))
>>> -        plt.xlabel('$\hat{r}$')
>>> -        plt.ylabel('$\hat{b}$')
>>> +        plt.xlabel('$\\hat{r}$')
>>> +        plt.ylabel('$\\hat{b}$')
>>>          """
>>>          optional set axes equal to shortest distance so line really does
>>>          looks perpendicular and everybody is happy
> 

-- 
Regards
--
Kieran


More information about the libcamera-devel mailing list