From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id sL8sIhqN41+QTwAA0tVLHw (envelope-from ) for ; Wed, 23 Dec 2020 18:31:54 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id ePsEHhqN418vcAAAB5/wlQ (envelope-from ) for ; Wed, 23 Dec 2020 18:31:54 +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 5681A9401BF for ; Wed, 23 Dec 2020 18:31:54 +0000 (UTC) Received: from localhost ([::1]:57702 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ks8vQ-0002PB-53 for larch@yhetil.org; Wed, 23 Dec 2020 13:31:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33836) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ks8ue-0002Oz-Qc for emacs-orgmode@gnu.org; Wed, 23 Dec 2020 13:31:04 -0500 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]:45732) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ks8ub-0001pq-6H; Wed, 23 Dec 2020 13:31:04 -0500 Received: by mail-pl1-x62e.google.com with SMTP id e2so79447plt.12; Wed, 23 Dec 2020 10:31:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:cc:subject:date:message-id :in-reply-to:mime-version; bh=CU+tj2+JD1reqeJQh2Q7ozmfo4YhKLzP2dXOnGHAVEg=; b=GDsE7OQux/KokINEzxrKdMO3tE5aaWNoaUrg3jg4LLCAbE5PzQJQDNa3tBUPj5sdbw a7HmBVjgDs5J9ilIwgfGgJo6uquGtj4bQ8+0m3T4eOvmumM3ENyIXzYl2K+NQXjgVgOd aNfbGECEAXJA67USLdrqP8iSyIs/o0s6782tduba8U82OQ+jQATnt3oWsXlrI1FBAr+c P0R7UhRSREkvRFPqsOmucgKv/tgBZq6wjA3KAyeUmgr9LF76ju0V1Mwlqzby0LuGi3Wf XKbRXGPOlBLXrEWjD0qAMTUD/uMVPlGmqfIhyX+kMW1RAFyu2Xc7U6VVBIcxlaSmEiom FdtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject:date :message-id:in-reply-to:mime-version; bh=CU+tj2+JD1reqeJQh2Q7ozmfo4YhKLzP2dXOnGHAVEg=; b=fk/XXZiCYL+NOm8iQTnFv2dpLATOvqKEe7yLU7Wy2ZkqtOVfKLHi2wkxz2dbvMNPdt QpJC6gE50LYZZVmxGfgEFrGc/Bn+z2kc14YuuiuDqdt6XSw8ocV8H85OenRe0ejaQxwS 3CUaKS1IiWSLKBcyyY9FZ7kBX6HV56ko6aKzVTsm1tevUrUdRNVcTdh5NxOhbjlk5VuV g8RUk+ZPhIHqPkXGKHDXx4kbcwaQ6itU0ZaEFTxy9En3lnwD+Xx1iZcx/YqAYa6GMpr/ DSa6/2gBNka6cn9Js4U9cwMma+BEXxbb70F8oUohM5fINR5g7MaSsMDSf+at/Rmdu5Qw 25Vg== X-Gm-Message-State: AOAM5322AI5ziE4sXL0nYO+VoAQRocryvaH3sLeBoFFHtZ4ZdUwZdS+A nJXesC01fR7mhh5AceUMpQnOBLoU4b0= X-Google-Smtp-Source: ABdhPJyqXaXuSgHJGwuXe5IWdFRw5fQrC5fRr3VrG04fBRe/hHlmAWJ+l5NaJ9jfa8Qk0wbbazTYuQ== X-Received: by 2002:a17:90a:f194:: with SMTP id bv20mr868357pjb.11.1608748258923; Wed, 23 Dec 2020 10:30:58 -0800 (PST) Received: from localhost (180-150-91-8.b4965b.per.nbn.aussiebb.net. [180.150.91.8]) by smtp.gmail.com with ESMTPSA id jx4sm332629pjb.24.2020.12.23.10.30.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Dec 2020 10:30:57 -0800 (PST) References: <87imcrfntf.fsf@gmail.com> <87blijmnv9.fsf@gnu.org> <87lfhbhfhe.fsf@gmail.com> <87r1qp3fu1.fsf@gmail.com> <871rhxd2ib.fsf@gmail.com> <87r1pnoo5y.fsf@bzg.fr> <87lffv8oy5.fsf@gmail.com> <87zh2hosex.fsf@bzg.fr> <87im8tglbl.fsf@kyleam.com> <87zh25t8cj.fsf@gmail.com> <87y2hpt568.fsf@gmail.com> <87czz1gfje.fsf@kyleam.com> <87wnx8ud5k.fsf@gmail.com> <871rfgh36z.fsf@kyleam.com> User-agent: mu4e 1.4.13; emacs 27.1 From: TEC To: Kyle Meyer Subject: Re: [PATCH] org-plot abstractions and extension Date: Thu, 24 Dec 2020 02:19:32 +0800 Message-ID: <87v9cstlze.fsf@gmail.com> In-reply-to: <871rfgh36z.fsf@kyleam.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=tecosaur@gmail.com; helo=mail-pl1-x62e.google.com 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: , Cc: Bastien , org-mode-email Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -4.00 Authentication-Results: aspmx1.migadu.com; none X-Migadu-Queue-Id: 5681A9401BF X-Spam-Score: -4.00 X-Migadu-Scanner: scn1.migadu.com X-TUID: Z+ZQntNrZ48B --=-=-= Content-Type: text/plain Kyle Meyer writes: > Regardless of what you tend to use, you used "case" here in 73c99bf42; > the minimal fix is to add a cl- prefix, and any other switch with the > justification that "case is obsolete" is likely to raise a reviewer's > eyebrow. This makes sense. > cl-case isn't in cl-lib, and there is no need to load anything. Huh, interesting. > recent org-plot example from 8d5122fc5: > [...] > That could be rewritten as [...] Would you like me to bundle that change in somewhere? >>>> @@ -210,9 +210,9 @@ values, namely regarding the range." >>>> "From a the values in a TABLE of data, attempt to guess an appropriate number of ticks." >>>> (let* ((row-data >>>> (mapcar (lambda (row) (org--plot/values-stats >>>> - (mapcar #'string-to-number (cdr row)) >>>> - hard-min >>>> - hard-max)) table)) >>>> + (mapcar #'string-to-number (cdr row)) >>>> + hard-min >>>> + hard-max)) table)) >>> >>> Please drop this unrelated space change. >> >> Erm, this isn't unrelated. As the function being called changed length, >> the indentation of the arguments is thus also changed. > > This change is in org--plot/sensible-tick-num. I don't spot any > non-whitespace changes there. Git appears to agree with me: > > $ git show | grep '@@ -210,9' > @@ -210,9 +210,9 @@ (defun org--plot/sensible-tick-num (table &optional hard-min hard-max) > $ git show -w | grep '@@ -210,9' Ooops, I thought you were referring to one of the other regions (I saw the "let" and "mapcar" and my brain pattern-matched the rest :P) One question, I saw Bastien say that we didn't want whitespace-only commits, so how should whitespace-fixups be done? >> Subject: [PATCH] org-plot.el: fix compiler warnings >> >> * (org--plot/values-stats): Replace `log10' with `log'. > > Please add a file name ("lisp/org-plot.el") to the start of the > changelog entry. Ah, forgot I needed that. Sorted :) (final?) patch revision attached. -- Timothy --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-org-plot.el-fix-compiler-warnings.patch >From c4c7b835f27b65111859d030af58a8317a82b0a0 Mon Sep 17 00:00:00 2001 From: TEC Date: Thu, 24 Dec 2020 02:26:17 +0800 Subject: [PATCH] org-plot.el: fix compiler warnings * lisp/org-plot.el (org--plot/values-stats): Replace `log10' with `log'. (org--plot/nice-frequency-pick): Replace obsolete `case' with `pcase`. (org--plot/radar): Replace `s-join' with `mapconcat', removing the implicit dependency on s.el. (org-plot/gnuplot-script): Remove unused let bindings. (org-plot/gnuplot-script): Replace free variable reference with expression only using given variables. --- lisp/org-plot.el | 109 ++++++++++++++++++++++------------------------- 1 file changed, 52 insertions(+), 57 deletions(-) diff --git a/lisp/org-plot.el b/lisp/org-plot.el index 4aa8276..5c6c834 100644 --- a/lisp/org-plot.el +++ b/lisp/org-plot.el @@ -196,7 +196,7 @@ values, namely regarding the range." (maximum (or hard-max (apply #'max nums))) (range (- maximum minimum)) (rangeOrder (if (= range 0) 0 - (ceiling (- 1 (log10 range))))) + (ceiling (- 1 (log range 10))))) (range-factor (expt 10 rangeOrder)) (nice-min (if (= range 0) (car nums) (/ (float (floor (* minimum range-factor))) range-factor))) @@ -229,34 +229,34 @@ values, namely regarding the range." (defun org--plot/nice-frequency-pick (frequencies) "From a list of frequences, try to sensibly pick a sample of the most frequent." ;; TODO this mosly works decently, but counld do with some tweaking to work more consistently. - (case (length frequencies) - (1 (list (car (nth 0 frequencies)))) - (2 (if (<= 3 (/ (cdr (nth 0 frequencies)) - (cdr (nth 1 frequencies)))) - (make-list 2 - (car (nth 0 frequencies))) - (list (car (nth 0 frequencies)) - (car (nth 1 frequencies))))) - (t - (let* ((total-count (apply #'+ (mapcar #'cdr frequencies))) - (n-freq (mapcar (lambda (freq) `(,(car freq) . ,(/ (float (cdr freq)) total-count))) frequencies)) - (f-pick (list (car (car n-freq)))) - (1-2-ratio (/ (cdr (nth 0 n-freq)) - (cdr (nth 1 n-freq)))) - (2-3-ratio (/ (cdr (nth 1 n-freq)) - (cdr (nth 2 n-freq)))) - (1-3-ratio (* 1-2-ratio 2-3-ratio)) - (1-val (car (nth 0 n-freq))) - (2-val (car (nth 1 n-freq))) - (3-val (car (nth 2 n-freq)))) - (when (> 1-2-ratio 4) (push 1-val f-pick)) - (when (and (< 1-2-ratio 2-val) - (< (* (apply #'* f-pick) 2-val) 30)) - (push 2-val f-pick)) - (when (and (< 1-3-ratio 3-val) - (< (* (apply #'* f-pick) 3-val) 30)) - (push 3-val f-pick)) - f-pick)))) + (cl-case (length frequencies) + (1 (list (car (nth 0 frequencies)))) + (2 (if (<= 3 (/ (cdr (nth 0 frequencies)) + (cdr (nth 1 frequencies)))) + (make-list 2 + (car (nth 0 frequencies))) + (list (car (nth 0 frequencies)) + (car (nth 1 frequencies))))) + (t + (let* ((total-count (apply #'+ (mapcar #'cdr frequencies))) + (n-freq (mapcar (lambda (freq) `(,(car freq) . ,(/ (float (cdr freq)) total-count))) frequencies)) + (f-pick (list (car (car n-freq)))) + (1-2-ratio (/ (cdr (nth 0 n-freq)) + (cdr (nth 1 n-freq)))) + (2-3-ratio (/ (cdr (nth 1 n-freq)) + (cdr (nth 2 n-freq)))) + (1-3-ratio (* 1-2-ratio 2-3-ratio)) + (1-val (car (nth 0 n-freq))) + (2-val (car (nth 1 n-freq))) + (3-val (car (nth 2 n-freq)))) + (when (> 1-2-ratio 4) (push 1-val f-pick)) + (when (and (< 1-2-ratio 2-val) + (< (* (apply #'* f-pick) 2-val) 30)) + (push 2-val f-pick)) + (when (and (< 1-3-ratio 3-val) + (< (* (apply #'* f-pick) 3-val) 30)) + (push 3-val f-pick)) + f-pick)))) (defun org--plot/merge-alists (function default alist1 alist2 &rest alists) "Using FUNCTION, combine the elements of all given ALISTS. When an element is @@ -473,34 +473,34 @@ EOD (defun org--plot/radar (table params) (let* ((data - (concat "\"" (s-join "\" \"" (plist-get params :labels)) "\"" + (concat "\"" (mapconcat #'identity (plist-get params :labels) "\" \"") "\"" "\n" - (s-join "\n" - (mapcar (lambda (row) - (format - "\"%s\" %s" - (car row) - (s-join " " (cdr row)))) - (append table (list (car table))))))) + (mapconcat (lambda (row) + (format + "\"%s\" %s" + (car row) + (mapconcat #'identity (cdr row) " "))) + (append table (list (car table))) + "\n"))) (ticks (or (plist-get params :ticks) (org--plot/sensible-tick-num table (plist-get params :ymin) (plist-get params :ymax)))) (settings - (s-join "\n" - (mapcar (lambda (row) - (let ((data (org--plot/values-stats - (mapcar #'string-to-number (cdr row))))) - (format - "\"%s\" %s %s %s" - (car row) - (or (plist-get params :ymin) - (plist-get data :nice-min)) - (or (plist-get params :ymax) - (plist-get data :nice-max)) - (if (eq ticks 0) 2 ticks) - ))) - (append table (list (car table)))))) + (mapconcat (lambda (row) + (let ((data (org--plot/values-stats + (mapcar #'string-to-number (cdr row))))) + (format + "\"%s\" %s %s %s" + (car row) + (or (plist-get params :ymin) + (plist-get data :nice-min)) + (or (plist-get params :ymax) + (plist-get data :nice-max)) + (if (eq ticks 0) 2 ticks) + ))) + (append table (list (car table))) + "\n")) (setup-file (make-temp-file "org-plot-setup"))) (let ((coding-system-for-write 'utf-8)) (write-region (format org--plot/radar-setup-template data settings) nil setup-file nil :silent)) @@ -533,15 +533,10 @@ manner suitable for prepending to a user-specified script." (user-error "Org-plot type `%s' is undefined." type-name)) (let* ((sets (plist-get params :set)) (lines (plist-get params :line)) - (map (plist-get params :map)) (title (plist-get params :title)) (file (plist-get params :file)) - (ind (plist-get params :ind)) (time-ind (plist-get params :timeind)) (timefmt (plist-get params :timefmt)) - (text-ind (plist-get params :textind)) - (deps (if (plist-member params :deps) (plist-get params :deps))) - (col-labels (plist-get params :labels)) (x-labels (plist-get params :xlabels)) (y-labels (plist-get params :ylabels)) (plot-str (or (plist-get type :plot-str) @@ -650,7 +645,7 @@ line directly before or after the table." org-plot/preset-plot-types))) (unless type - (user-error "Org-plot type `%s' is undefined." type-name)) + (user-error "Org-plot type `%s' is undefined." (plist-get params :plot-type))) (run-with-idle-timer 0.1 nil #'delete-file data-file) (when (eq (cadr table) 'hline) -- 2.29.2 --=-=-=--