From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:403:478a::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id yEQBKTXIq2RR8AAASxT56A (envelope-from ) for ; Mon, 10 Jul 2023 10:58:29 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:478a::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id 0FfNKDXIq2QRvgAAauVa8A (envelope-from ) for ; Mon, 10 Jul 2023 10:58:29 +0200 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 833CE62E41 for ; Mon, 10 Jul 2023 10:58:28 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b="A7O9dOr/"; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=posteo.net ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1688979508; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=I6rkL9HHXkFjKe7RWDL9ICxaeZV26O7+YuptBG+wa3s=; b=mGkBjD5/pKUAI5TjAO8XQSZyCsGeRQdEby2BlUcd8Ii9o3X0pIXSbrwSILbbNQm7PSwt4o 3OogsUjulYE0zgqyuNla6ukC1Wz71lYb31vN47QJUfOwp1+vf/2VhIjjw4JscxuKU69ej8 aU6n56fWMnP4WmfvDC6HGPNy9ER3kkPMv2wTRz+F1vADKIxckBYrGY/HBm66/N0Iw0dWDM dc9CUzL5Utv70GQKsbfvLXVifNRdT3rsLJvPWSvsZxzREMEs1qKCL/cyGbVveGRCLJ1axr KmWTVi7BTWfHqYI9lQysrVcQOzOLSnfVe6Bi2ouFK5YuLnihxXetxZMphOj34A== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b="A7O9dOr/"; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=posteo.net ARC-Seal: i=1; s=key1; d=yhetil.org; t=1688979508; a=rsa-sha256; cv=none; b=UUEuMiGOWAraxwNRtT9YGJrg3xIZKbKv4RLL3XsM/jCcyFod5zoBwCWmVCe+VsBjg/JptS 92E+H8q/fQCE7NObnXJAUu854QWLz6NS5t/n0JLGCaot0etQ0vZNx79QgseUpV8zjleTB/ O/sEEJzuLYpi0GMAJZA/zlFdQqgfG60feJxuv3KXzEgP5bZtTvZ8IR3MtdI3OnOc4rjWo8 LzZK36zbfT0SQfJ7+Ykd9d9X6yvDMrMO+M7XznUt/GpbvUH5Wy6w/SJFZ2D2fctI5AFqwT 0GoIQ5BWAVrdrX9WAYE3VzKb9k8gnRzqj+3ytbwUDc24PpGzvBykzDj992Nwag== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qImi9-0002uW-4r; Mon, 10 Jul 2023 04:57:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qImi5-0002tZ-Vr for emacs-orgmode@gnu.org; Mon, 10 Jul 2023 04:57:33 -0400 Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qImi3-0004jH-EM for emacs-orgmode@gnu.org; Mon, 10 Jul 2023 04:57:33 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id CF80F24002A for ; Mon, 10 Jul 2023 10:57:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1688979448; bh=4LGPUoIJQzOlF+gJCIJPtQy2yfKDGAgijL9Hqee0S0I=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:From; b=A7O9dOr/wcQgFtteEjHawEJ8OW8oG9G1ETeQIFTeMrrg4MtV1aN1jRZPgdCl6g5w0 X0RHCMnizIgV1/T1iQ7kbQYVxmVOjKRxwJAAz+quBQ+XVwk7ibaal8r4yg1P5aHd4S veF8+jszzfgAkwO6apvKqsfVuOot4Vw2dPmIbS8z6hsm7yTVCkx4aWv2qz/90ziG53 ESYSb1HLK9sE7+MxerxXCVoAqb+AStbtRlP7Yx2frZwQLkHpB31KOHPiOdHnlc2gFc WIaKLxxWhTO3lVdiv1Y6luT8TmzFAejH0km5xo/k5JM7PPIcB8jKcW6SRuqywKkHHc NYoikklJUCHGg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4QzyYz6qxlz9rxS; Mon, 10 Jul 2023 10:57:27 +0200 (CEST) From: Ihor Radchenko To: andrea@fedeli.eu Cc: emacs-orgmode@gnu.org Subject: Re: [BUG] Error in data input and output format for org-columns--summary-estimate In-Reply-To: References: <87y1jp6ueg.fsf@localhost> Date: Mon, 10 Jul 2023 08:57:36 +0000 Message-ID: <87ilas6t4v.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.65; envelope-from=yantar92@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -53 X-Spam_score: -5.4 X-Spam_bar: ----- X-Spam_report: (-5.4 / 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_MED=-2.3, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Spam-Score: -7.67 X-Migadu-Queue-Id: 833CE62E41 X-Migadu-Spam-Score: -7.67 X-Migadu-Scanner: mx0.migadu.com X-TUID: u6IV0yZbfhK3 --=-=-= Content-Type: text/plain andrea@fedeli.eu writes: > #+PROPERTY: Effort_ALL 0 0:10 0:30 1:00 2:00 3:00 4:00 5:00 6:00 7:00 > > #+COLUMNS: %30ITEM(Task) %30Effort(Estimated Effort){est+} %CLOCKSUM >... > Originally produces > image.png > That shows that days and months are wrongly counted the same Thanks! Confirmed. > > The matter is related to the fact that org-columns--summary-estimate, from org-colview.el, uses function string-to-number to take value on ranges; acting this way > Both issues can be very simply addressed by adoption of org-duration-to-minutes as > > input adapted and org-duration-from-minutes as output adapter. > A similar concern affects also the simpler case of a single value instead of a range (second pcase branch) This will not be backwards-compatible. Some people may abuse this summary type to count something that is not time, like cost. We rather need something like the attached diff. However, this will use `org-duration-format', which may not always be desirable - the default value will force days even when all the estimates are months: 3m 3m-4m --- 180d 0:00 - 210d 0:00 --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=org-columns-est.diff diff --git a/lisp/org-colview.el b/lisp/org-colview.el index 7aa5ef645..da9a11104 100644 --- a/lisp/org-colview.el +++ b/lisp/org-colview.el @@ -1345,18 +1345,32 @@ (defun org-columns--summary-estimate (estimates _) The mean and variance of the result will be the sum of the means and variances (respectively) of the individual estimates." (let ((mean 0) - (var 0)) + (var 0) + (durationp + (catch :no-match + (dolist (e estimates) + (dolist (val (split-string e "-")) + (unless (org-duration-p val) (throw :no-match nil)))) + 'all-values-are-durations))) (dolist (e estimates) - (pcase (mapcar #'string-to-number (split-string e "-")) + (pcase (mapcar + (if durationp + #'org-duration-to-minutes + #'string-to-number) + (split-string e "-")) (`(,low ,high) (let ((m (/ (+ low high) 2.0))) (cl-incf mean m) (cl-incf var (- (/ (+ (* low low) (* high high)) 2.0) (* m m))))) (`(,value) (cl-incf mean value)))) (let ((sd (sqrt var))) - (format "%s-%s" - (format "%.0f" (- mean sd)) - (format "%.0f" (+ mean sd)))))) + (if durationp + (format "%s - %s" + (org-duration-from-minutes (- mean sd)) + (org-duration-from-minutes (+ mean sd))) + (format "%s-%s" + (format "%.0f" (- mean sd)) + (format "%.0f" (+ mean sd))))))) --=-=-= Content-Type: text/plain -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at --=-=-=--