[libcamera-devel,v2] utils: raspberrypi: ctt: Fix pycodestyle W605

Message ID 20200628123730.31992-1-laurent.pinchart@ideasonboard.com
State Accepted
Commit e7aa92a883c170c7f14a6aa93f13a6d75c2b7d62
Headers show
Series
  • [libcamera-devel,v2] utils: raspberrypi: ctt: Fix pycodestyle W605
Related show

Commit Message

Laurent Pinchart June 28, 2020, 12:37 p.m. UTC
W605 invalid escape sequence '\.'

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
Changes since v1:

- Use raw strings for regular expressions
---
 utils/raspberrypi/ctt/ctt.py     | 4 ++--
 utils/raspberrypi/ctt/ctt_awb.py | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

Comments

Niklas Söderlund June 28, 2020, 6:06 p.m. UTC | #1
Hi Laurent,

Thanks for your work.

On 2020-06-28 15:37:30 +0300, Laurent Pinchart wrote:
> W605 invalid escape sequence '\.'
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

> ---
> Changes since v1:
> 
> - Use raw strings for regular expressions
> ---
>  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 d7e38c31986d..30d35ae4e3d4 100755
> --- a/utils/raspberrypi/ctt/ctt.py
> +++ b/utils/raspberrypi/ctt/ctt.py
> @@ -42,8 +42,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(r'([0-9]+)[kK](\.(jpg|jpeg|brcm|dng)|_.*\.(jpg|jpeg|brcm|dng))$', string)
> +    lux = re.search(r'([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 7055b8639178..3c8cd9027a1a 100644
> --- a/utils/raspberrypi/ctt/ctt_awb.py
> +++ b/utils/raspberrypi/ctt/ctt_awb.py
> @@ -257,8 +257,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,
> 
> Laurent Pinchart
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
David Plowman June 29, 2020, 7:41 a.m. UTC | #2
Hi Laurent

Thanks for tidying this up!

On Sun, 28 Jun 2020 at 19:06, Niklas Söderlund
<niklas.soderlund@ragnatech.se> wrote:
>
> Hi Laurent,
>
> Thanks for your work.
>
> On 2020-06-28 15:37:30 +0300, Laurent Pinchart wrote:
> > W605 invalid escape sequence '\.'
> >
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>
> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

Reviewed-by: David Plowman <david.plowman@raspberrypi.com>

Best regards
David

>
> > ---
> > Changes since v1:
> >
> > - Use raw strings for regular expressions
> > ---
> >  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 d7e38c31986d..30d35ae4e3d4 100755
> > --- a/utils/raspberrypi/ctt/ctt.py
> > +++ b/utils/raspberrypi/ctt/ctt.py
> > @@ -42,8 +42,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(r'([0-9]+)[kK](\.(jpg|jpeg|brcm|dng)|_.*\.(jpg|jpeg|brcm|dng))$', string)
> > +    lux = re.search(r'([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 7055b8639178..3c8cd9027a1a 100644
> > --- a/utils/raspberrypi/ctt/ctt_awb.py
> > +++ b/utils/raspberrypi/ctt/ctt_awb.py
> > @@ -257,8 +257,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,
> >
> > Laurent Pinchart
> >
> > _______________________________________________
> > libcamera-devel mailing list
> > libcamera-devel@lists.libcamera.org
> > https://lists.libcamera.org/listinfo/libcamera-devel
>
> --
> Regards,
> Niklas Söderlund
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/utils/raspberrypi/ctt/ctt.py b/utils/raspberrypi/ctt/ctt.py
index d7e38c31986d..30d35ae4e3d4 100755
--- a/utils/raspberrypi/ctt/ctt.py
+++ b/utils/raspberrypi/ctt/ctt.py
@@ -42,8 +42,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(r'([0-9]+)[kK](\.(jpg|jpeg|brcm|dng)|_.*\.(jpg|jpeg|brcm|dng))$', string)
+    lux = re.search(r'([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 7055b8639178..3c8cd9027a1a 100644
--- a/utils/raspberrypi/ctt/ctt_awb.py
+++ b/utils/raspberrypi/ctt/ctt_awb.py
@@ -257,8 +257,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