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 oJA+OwXq4l95CQAA0tVLHw (envelope-from ) for ; Wed, 23 Dec 2020 06:56:05 +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 eLVKNwXq4l8PcgAAB5/wlQ (envelope-from ) for ; Wed, 23 Dec 2020 06:56:05 +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 145A29403C9 for ; Wed, 23 Dec 2020 06:56:04 +0000 (UTC) Received: from localhost ([::1]:56172 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kry43-0000dk-ML for larch@yhetil.org; Wed, 23 Dec 2020 01:56:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41810) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1krxVM-0000hc-9O for emacs-orgmode@gnu.org; Wed, 23 Dec 2020 01:20:13 -0500 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]:35216) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1krxVG-0007va-9Z; Wed, 23 Dec 2020 01:20:11 -0500 Received: by mail-pg1-x533.google.com with SMTP id n7so9972880pgg.2; Tue, 22 Dec 2020 22:20:05 -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:in-reply-to :message-id:mime-version; bh=jo7lne2c1Cwnv7PiVyoAu26LoCg8Okg0Y1/bTveMz68=; b=fkRsgUff4eHCUPISTXWy/txya/d10wHPQIMNMLqlXDL75vTVe0FYKfICbCW3yKZZtN AeoNGKHPVw6e9UyWpMww16v0SrCKYYQO6ptOTQ51FohkiOTIZsvCmt45hbXVg5WMTRuk dAnBYB8K7au1+92la6yt53xn2yhKUW3saSm71usbZET1i33dMsOhX1WZsaWyJ/dYoa4Z gRqWMLhkpNiTCiZPr3AVSyMP12yo9w3o1Rc+m42uX9JvXCG71YG8c4XMlaPI0pwNrx0J DNwQpnl9+eC+esLuvk7QcaRTgRLVlC4s0ejO6S7fW8xXslH6L0xv4fQ/sBmYaqsVDOu6 XxVQ== 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 :in-reply-to:message-id:mime-version; bh=jo7lne2c1Cwnv7PiVyoAu26LoCg8Okg0Y1/bTveMz68=; b=pXDhWGW53+F1Sa0rSGYj3rVq8mWiTRupnzzWIYMessj0CCss+kYjgun9PT3KFtXyvT jaHg9aaiVnHzXCQxqVgq51MAScy2u+z1Sqgd9bi2Fbnx/BPt1R4EWIMVhWCp5WcSveaj cou2BJ4m8k9JQ8CG08K4V6QMkbaDfM3MIOoHPrUBju7tyNsnbioGKNBMI4Nkvz0gn7dy O9VgufZIKV0euwKJ1qDvUFPylF2EYaZ6jqH6nrC3ERjkKRQfGWBRaIEnXGPKRvajkSl5 yYwGH/f/hEzGSpH0nBhwbinhRn0g3c88W6hJtzfHbXpj3sowGAkOOZRGkU4Bochb7qfo GNpQ== X-Gm-Message-State: AOAM530PkWYUugyNDaVWtheDrqfBg0y/daa4vJ2cSZrOP7Ucpt1tkoFA IkHJBcso6vvJak4MsfjbVs4= X-Google-Smtp-Source: ABdhPJxFZlW/BR7s3hEW/C5oWHCWn/w+XyRBtryEPPUiX2Rzbe6UZMW6p9JFaNgqo70F4gtRhOrwhg== X-Received: by 2002:a65:68c9:: with SMTP id k9mr23374121pgt.328.1608704404593; Tue, 22 Dec 2020 22:20:04 -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 il14sm20094865pjb.51.2020.12.22.22.20.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Dec 2020 22:20:03 -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> User-agent: mu4e 1.4.13; emacs 27.1 From: TEC To: Kyle Meyer Subject: Re: [PATCH] org-plot abstractions and extension Date: Wed, 23 Dec 2020 14:19:19 +0800 In-reply-to: <87zh25t8cj.fsf@gmail.com> Message-ID: <87y2hpt568.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::533; envelope-from=tecosaur@gmail.com; helo=mail-pg1-x533.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: -1.22 Authentication-Results: aspmx1.migadu.com; dkim=fail (headers rsa verify failed) header.d=gmail.com header.s=20161025 header.b=fkRsgUff; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=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-Migadu-Queue-Id: 145A29403C9 X-Spam-Score: -1.22 X-Migadu-Scanner: scn1.migadu.com X-TUID: vsVfatxhsEFu --=-=-= Content-Type: text/plain TEC writes: > Kyle Meyer writes: > >> This series introduced some compiler warnings. >> >> Timothy, could you please submit a follow-up patch to address these? > > Absolutely. Thanks for raising this, I'll take a look shortly. Here we go :) --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-org-plot.el-fix-compiler-warnings.patch >From 309907af5e76818753b85af84b3e304d8cb4568c Mon Sep 17 00:00:00 2001 From: TEC Date: Wed, 23 Dec 2020 14:13:24 +0800 Subject: [PATCH] org-plot.el: fix compiler warnings * (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 refence with expression only using given variables. --- lisp/org-plot.el | 117 +++++++++++++++++++++++------------------------ 1 file changed, 57 insertions(+), 60 deletions(-) diff --git a/lisp/org-plot.el b/lisp/org-plot.el index 4aa8276..80700e0 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))) @@ -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)) (row-normalised-ranges (mapcar (lambda (r-data) (let ((val (round (* (plist-get r-data :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)))) + (pcase (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))))) + (_ + (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,36 @@ 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 #'identity + (mapcar (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 #'identity + (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)))) + "\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 +535,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 +647,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 --=-=-=--