[{"id":18496,"web_url":"https://patchwork.libcamera.org/comment/18496/","msgid":"<YQguQbPBnlmtUdH4@pendragon.ideasonboard.com>","date":"2021-08-02T17:41:21","subject":"Re: [libcamera-devel] [PATCH v1 1/3] utils: raspberrypi: ctt: Fix\n\tnamespace for sklearn NearestCentroid function","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi David,\n\nThank you for the patch.\n\nOn Mon, Aug 02, 2021 at 09:20:34AM +0100, David Plowman wrote:\n> The NearestCentroid function is in the sklearn.neighbors namespace\n> since version 0.22.\n> \n> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> Reviewed-by: Naushir Patuck <naush@raspberrypi.com>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> ---\n>  utils/raspberrypi/ctt/ctt_tools.py | 7 ++++++-\n>  1 file changed, 6 insertions(+), 1 deletion(-)\n> \n> diff --git a/utils/raspberrypi/ctt/ctt_tools.py b/utils/raspberrypi/ctt/ctt_tools.py\n> index 48e0aac2..41c4efb6 100644\n> --- a/utils/raspberrypi/ctt/ctt_tools.py\n> +++ b/utils/raspberrypi/ctt/ctt_tools.py\n> @@ -14,7 +14,12 @@ import imutils\n>  import sys\n>  import matplotlib.pyplot as plt\n>  from sklearn import cluster as cluster\n> -from sklearn.neighbors.nearest_centroid import NearestCentroid as get_centroids\n> +try:\n> +    # From sklearn version 0.22 onwards, NearestCentroid is no longer in the\n> +    # nearest_centroid module\n> +    from sklearn.neighbors.nearest_centroid import NearestCentroid as get_centroids\n> +except (ModuleNotFoundError):\n> +    from sklearn.neighbors import NearestCentroid as get_centroids\n\nActually, NearestCentroid has always been available directly from\nsklearn.neighbors. The change in 0.22 is that it's not available from\nsklearn.neighbors.nearest_centroid anymore. I've just tested importing\n\nfrom sklearn.neighbors import NearestCentroid as get_centroids\n\nwith 0.21.0, and it works fine. Sorry for the misleading review of the\nprevious version. The code was fine, it's just the commit message that\nneeded updating. If you're fine with the following, I can update when\napplying.\n\n\"Starting in version 0.22, the NearestCentroid function is only\navailable in the sklearn.neighbors namespace, when it was previously\navailable in both the sklearn.neighbors.nearest_centroid and\nsklearn.neighbors namespaces. Use sklearn.neighbors as it works on all\nversions of sklearn.\"\n\n>  \n>  \"\"\"\n>  This file contains some useful tools, the details of which aren't important to","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id E8D17C3232\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  2 Aug 2021 17:41:34 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 686E1687C3;\n\tMon,  2 Aug 2021 19:41:34 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0B3656026F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  2 Aug 2021 19:41:33 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 765F29FB;\n\tMon,  2 Aug 2021 19:41:32 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"PHiRg3oq\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1627926092;\n\tbh=+UjUbWkt/h7tzEJk0KMb+s2SgX5UWiw+fy+kZbaTG1k=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=PHiRg3oqcJiKRV+PPe5qEYY4B558DdWcgRLp96rVnkTqfKJxBOAh3362Fo9etu3Jp\n\t7DYZfJTxCdgWrIvVNgNpRd/iGwwNMk8/PPSdWipnnQO9eQzSs3M7/FlGRIVRbcGiBd\n\tESEc2+yW0nHLaNv2KUOq/LFRh7ff3ZO/mdgXLrNM=","Date":"Mon, 2 Aug 2021 20:41:21 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"David Plowman <david.plowman@raspberrypi.com>","Message-ID":"<YQguQbPBnlmtUdH4@pendragon.ideasonboard.com>","References":"<20210721115220.5090-2-david.plowman@raspberrypi.com>\n\t<20210802082034.6008-1-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20210802082034.6008-1-david.plowman@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH v1 1/3] utils: raspberrypi: ctt: Fix\n\tnamespace for sklearn NearestCentroid function","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":18497,"web_url":"https://patchwork.libcamera.org/comment/18497/","msgid":"<CAHW6GY+5VPH+87nRRig=6iQGM5_xUQGciogvH6wktT4Phui1LQ@mail.gmail.com>","date":"2021-08-02T17:50:17","subject":"Re: [libcamera-devel] [PATCH v1 1/3] utils: raspberrypi: ctt: Fix\n\tnamespace for sklearn NearestCentroid function","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"content":"Hi Laurent\n\nWhat a confusing story, it was perhaps a bit unlucky that our original\nversion was the one that was going to break! But thank you very much\nfor the suggestion - if you could do that it would be greatly\nappreciated.\n\nThanks!\nDavid\n\nOn Mon, 2 Aug 2021 at 18:41, Laurent Pinchart\n<laurent.pinchart@ideasonboard.com> wrote:\n>\n> Hi David,\n>\n> Thank you for the patch.\n>\n> On Mon, Aug 02, 2021 at 09:20:34AM +0100, David Plowman wrote:\n> > The NearestCentroid function is in the sklearn.neighbors namespace\n> > since version 0.22.\n> >\n> > Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> > Reviewed-by: Naushir Patuck <naush@raspberrypi.com>\n> > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> > ---\n> >  utils/raspberrypi/ctt/ctt_tools.py | 7 ++++++-\n> >  1 file changed, 6 insertions(+), 1 deletion(-)\n> >\n> > diff --git a/utils/raspberrypi/ctt/ctt_tools.py b/utils/raspberrypi/ctt/ctt_tools.py\n> > index 48e0aac2..41c4efb6 100644\n> > --- a/utils/raspberrypi/ctt/ctt_tools.py\n> > +++ b/utils/raspberrypi/ctt/ctt_tools.py\n> > @@ -14,7 +14,12 @@ import imutils\n> >  import sys\n> >  import matplotlib.pyplot as plt\n> >  from sklearn import cluster as cluster\n> > -from sklearn.neighbors.nearest_centroid import NearestCentroid as get_centroids\n> > +try:\n> > +    # From sklearn version 0.22 onwards, NearestCentroid is no longer in the\n> > +    # nearest_centroid module\n> > +    from sklearn.neighbors.nearest_centroid import NearestCentroid as get_centroids\n> > +except (ModuleNotFoundError):\n> > +    from sklearn.neighbors import NearestCentroid as get_centroids\n>\n> Actually, NearestCentroid has always been available directly from\n> sklearn.neighbors. The change in 0.22 is that it's not available from\n> sklearn.neighbors.nearest_centroid anymore. I've just tested importing\n>\n> from sklearn.neighbors import NearestCentroid as get_centroids\n>\n> with 0.21.0, and it works fine. Sorry for the misleading review of the\n> previous version. The code was fine, it's just the commit message that\n> needed updating. If you're fine with the following, I can update when\n> applying.\n>\n> \"Starting in version 0.22, the NearestCentroid function is only\n> available in the sklearn.neighbors namespace, when it was previously\n> available in both the sklearn.neighbors.nearest_centroid and\n> sklearn.neighbors namespaces. Use sklearn.neighbors as it works on all\n> versions of sklearn.\"\n>\n> >\n> >  \"\"\"\n> >  This file contains some useful tools, the details of which aren't important to\n>\n> --\n> Regards,\n>\n> Laurent Pinchart","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id E4022C3235\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  2 Aug 2021 17:50:30 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 69A37687C3;\n\tMon,  2 Aug 2021 19:50:30 +0200 (CEST)","from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com\n\t[IPv6:2a00:1450:4864:20::32a])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E7CC96026F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  2 Aug 2021 19:50:28 +0200 (CEST)","by mail-wm1-x32a.google.com with SMTP id\n\tl34-20020a05600c1d22b02902573c214807so5656wms.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 02 Aug 2021 10:50:28 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"a5Qu5vaF\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=Yhak6v0BzbEO0/CuTHBqjLLuDJvZwWn4Kht1QfOLSEU=;\n\tb=a5Qu5vaFPxiUDPUqVi6u6Bmc7B9DVVQ4iSVJInqq+gVQPPbPL37RFeJc/eCFcGtcqL\n\tR2BCqKW80ot13trfrxJxBxM/0LKyCg78qG8RYkwfkZUEOICnVqPFPHjy3AD5CXpDHe1o\n\t8vaozXqCnOjdXB5h9diQI4nnNpkVitIYt0s4SmYQGFhjQsfHNkeATOvcVWFc3MoV5N3R\n\tWsNyhDZKs62tS7vjnkAiJ+njzPC9/0H9VVMfpWH6skIu9fbm1Nxs1mhR3wBxbUTU27RH\n\tkK748s2AErgQCqn8zHb01drDAItu7DtKfrWJrx02aGB9yJTfmXMwZ37NB/LqwBnfI0ys\n\t4qjg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=Yhak6v0BzbEO0/CuTHBqjLLuDJvZwWn4Kht1QfOLSEU=;\n\tb=V7dg7JIj0qhPK6JEMPkiWeiuiHr2LTKvQRV5KCeJQAlsQwBV9vph5eGYBIBlfW+mwu\n\t9SjmL+3dOW3gcjqpdlHU+wif2WuN6lnCYvNXFm+F5oHEXFHivO5KtH4EUO3CpEFryC4r\n\taxhmalajHb356axQG4ag3WcqOy45rE1sJvu/0uk+S7uowivv63RJqHKjHYp2KLEkBBCL\n\tqf7M/Xs5FE+qBBwQugh/L04+ZVg4IkpxTMiawb7PCyDqL40p6IqZmxahUVcU2O1PkPjE\n\ttpRZQ8fOyzEUOdlg2y4vrTtlapCkysb63fTuYcoZea30B3hIi7L8jxl+ofuFFPLmccOy\n\tRRww==","X-Gm-Message-State":"AOAM530JyOaZexHJPLdZeAZ3qMOe0TD4tY4+qchv+H642h3Ffns8dvXY\n\tgQoFGaKqzoH6KEA6W9FWwcqECI2h4uDcnjR0npSFezXbfV4=","X-Google-Smtp-Source":"ABdhPJzulPb+pDd+Y7cBWR6Eky2cX59tDjs+05Gt+p+n0pKeuHZ0uUXoQwhuN/BnvT687rmTFQeJU9+5q+swjoM00HY=","X-Received":"by 2002:a7b:c8d9:: with SMTP id\n\tf25mr17381525wml.40.1627926628543; \n\tMon, 02 Aug 2021 10:50:28 -0700 (PDT)","MIME-Version":"1.0","References":"<20210721115220.5090-2-david.plowman@raspberrypi.com>\n\t<20210802082034.6008-1-david.plowman@raspberrypi.com>\n\t<YQguQbPBnlmtUdH4@pendragon.ideasonboard.com>","In-Reply-To":"<YQguQbPBnlmtUdH4@pendragon.ideasonboard.com>","From":"David Plowman <david.plowman@raspberrypi.com>","Date":"Mon, 2 Aug 2021 18:50:17 +0100","Message-ID":"<CAHW6GY+5VPH+87nRRig=6iQGM5_xUQGciogvH6wktT4Phui1LQ@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH v1 1/3] utils: raspberrypi: ctt: Fix\n\tnamespace for sklearn NearestCentroid function","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]