From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id yGqWHXPp514nZQAA0tVLHw (envelope-from ) for ; Mon, 15 Jun 2020 21:34:43 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id sPODGXPp5147KwAA1q6Kng (envelope-from ) for ; Mon, 15 Jun 2020 21:34:43 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 3B1F59404D4 for ; Mon, 15 Jun 2020 21:34:42 +0000 (UTC) Received: from localhost ([::1]:57100 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jkwka-0008Ry-L3 for larch@yhetil.org; Mon, 15 Jun 2020 17:34:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36246) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jkw60-000580-P2 for emacs-orgmode@gnu.org; Mon, 15 Jun 2020 16:52:44 -0400 Received: from devianza.investici.org ([198.167.222.108]:51613) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jkw5x-0002W4-9M for emacs-orgmode@gnu.org; Mon, 15 Jun 2020 16:52:44 -0400 Received: from mx2.investici.org (unknown [127.0.0.1]) by devianza.investici.org (Postfix) with ESMTP id 4D889E0574; Mon, 15 Jun 2020 20:52:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anche.no; s=stigmate; t=1592254357; bh=57WhKGxRas0Fm5ERWNZxjrQJBj9rWRNGkHD6F8DKaLA=; h=Subject:From:To:References:Date:In-Reply-To:From; b=KwN+VoUkADtGWvN7gUZJgJFwp933+jAUpGWDl2EoIROqJSPRnio9giE0IYd+NVs6H ZHqjCWcCbHlyJ5xN9Quq1uWIEGPzft2SuDfyrHp/N/NPBhySyonSVjUVvKuqGhuZXk q1B0mvEVr0q2zbvzHDOsDnh3VYibqaouqVMNzAP0= Received: from [198.167.222.108] (mx2.investici.org [198.167.222.108]) (Authenticated sender: mariotomo@inventati.org) by localhost (Postfix) with ESMTPSA id B4028E056D; Mon, 15 Jun 2020 20:52:35 +0000 (UTC) Subject: Re: [PATCH] may we focus on readability? From: Mario Frasca To: emacs-orgmode@gnu.org References: <871rmhe93z.fsf@nicolasgoaziou.fr> <1a4fa99e-26b3-db80-e292-1001d762f8d5@anche.no> Message-ID: Date: Mon, 15 Jun 2020 15:52:11 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <1a4fa99e-26b3-db80-e292-1001d762f8d5@anche.no> Content-Type: multipart/mixed; boundary="------------C68A68ACE4BEDCE1C6FCFE18" Content-Language: en-US Received-SPF: pass client-ip=198.167.222.108; envelope-from=mario@anche.no; helo=devianza.investici.org X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/15 16:52:37 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=anche.no header.s=stigmate header.b=KwN+VoUk; dmarc=none; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: -0.21 X-TUID: oKc31A3O79O6 This is a multi-part message in MIME format. --------------C68A68ACE4BEDCE1C6FCFE18 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit second thought about testing: if I did that, it would become longer than 15 lines, I would need refactoring quite a bit of stuff, and both things would require time, bureaucratic time, and programming time. I had a closer look at my changes, re-read it, and used it a bit, and I think this is o.k. see it yourself, when we have the agreement allowing you accept changes longer than 15 lines, I'll consider the needed refactoring and test-writing. ciao, Mario On 15/06/2020 09:49, Mario Frasca wrote: > Hi Nicolas, I think that the hint on testing is very correct, I'm > afraid I changed the semantics of one of the original tests, and I > found that there's other cl functions other than just cl-some, also > cl-every, cl-notevery, and cl-notany.  I'll have a closer look at > this.  and write some tests before changing the code. > > I also looked for the strange idiom used here, and these two are the > only two locations I found. > > how do I run tests from the command line (I'm using make test) but > then limited to one lisp file?  or one specific test? > > ciao, > > Mario > > On 14/06/2020 14:32, Nicolas Goaziou wrote: >> […] >> Also, further nit: (not (cl-every ...)) will apply `not' only once. >> >> In any case, it would be better if refactoring happens while introducing >> unit tests *hint*. >> >> Regards, --------------C68A68ACE4BEDCE1C6FCFE18 Content-Type: text/x-patch; charset=UTF-8; name="0001-lisp-org-plot.el-reducing-complexity-of-test.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-lisp-org-plot.el-reducing-complexity-of-test.patch" >From 49f1cfbb80a3d5ffdbac4eea60bb3d45991c4423 Mon Sep 17 00:00:00 2001 From: mfrasca Date: Sun, 14 Jun 2020 10:52:41 -0500 Subject: [PATCH] lisp/org-plot.el: reducing complexity of test. * lisp/org-plot.el (org-plot/gnuplot): readability of test, looking for some non satisfying elements. I'm rewriting a complicated construction where there's an equality test on the length of the list of non matching elements, with a simpler cl-some invocation. The replacing code is self explanatory. --- lisp/org-plot.el | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/lisp/org-plot.el b/lisp/org-plot.el index a23195d2a..bf81d3c37 100644 --- a/lisp/org-plot.el +++ b/lisp/org-plot.el @@ -309,26 +309,20 @@ line directly before or after the table." (`grid (let ((y-labels (org-plot/gnuplot-to-grid-data table data-file params))) (when y-labels (plist-put params :ylabels y-labels))))) - ;; Check for timestamp ind column. - (let ((ind (1- (plist-get params :ind)))) - (when (and (>= ind 0) (eq '2d (plist-get params :plot-type))) - (if (= (length - (delq 0 (mapcar - (lambda (el) - (if (string-match org-ts-regexp3 el) 0 1)) - (mapcar (lambda (row) (nth ind row)) table)))) - 0) - (plist-put params :timeind t) - ;; Check for text ind column. - (if (or (string= (plist-get params :with) "hist") - (> (length - (delq 0 (mapcar - (lambda (el) - (if (string-match org-table-number-regexp el) - 0 1)) - (mapcar (lambda (row) (nth ind row)) table)))) - 0)) - (plist-put params :textind t))))) + ;; Check type of ind column (timestamp? text?) + (when (eq `2d (plist-get params :plot-type)) + (let* ((ind (1- (plist-get params :ind))) + (ind-column (mapcar (lambda (row) (nth ind row)) table))) + (cond ((< ind 0) nil) ; ind is implicit + ((cl-every (lambda (el) + (string-match org-ts-regexp3 el)) + ind-column) + (plist-put params :timeind t)) ; ind holds timestamps + ((or (string= (plist-get params :with) "hist") + (cl-notevery (lambda (el) + (string-match org-table-number-regexp el)) + ind-column)) + (plist-put params :textind t))))) ; ind holds text ;; Write script. (with-temp-buffer (if (plist-get params :script) ; user script -- 2.20.1 --------------C68A68ACE4BEDCE1C6FCFE18--