emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: andrea@fedeli.eu
To: emacs-orgmode@gnu.org
Subject: [BUG] Error in data input and output format for  org-columns--summary-estimate
Date: Sun,  9 Jul 2023 14:46:51 +0200	[thread overview]
Message-ID: <RXJ4U3$C6D44098F78E9824538618D9BEAECEDA@fedeli.eu> (raw)

[-- Attachment #1: Type: text/plain, Size: 2136 bytes --]


   Howdy!

   This has been tested to happen with org 9.5.5, a few of the

   following, and on the HEAD version on git (9.6.7+); it's a source

   matter, afflicting org independently of the running platform (GNU/Linux,

   Windows, etc.)

   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

   the unit is removed making impossible to distinguish between 1y and 1min . Similarly, on output, the two margins are produced a (format "%.0f" <value>), which --again-- is generally wrong as it does not tell anything about the utilized time unit.

   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)

   Here is the patched code with the wrong code lines commented out.

   (defun org-columns--summary-estimate (estimates _)

     "Combine a list of estimates, using mean and variance.

   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))

       (dolist (e estimates)

   ;;      (pcase (mapcar #'string-to-number (split-string e "-"))

         (pcase (mapcar #'org-duration-to-minutes (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))))

           (`(,value) (cl-incf mean (org-duration-to-minutes value)))))

       (let ((sd (sqrt var)))

         (format "%s-%s"

   ;;              (format "%.0f" (- mean sd))

   ;;              (format "%.0f" (+ mean sd))))))

                 (org-duration-from-minutes (- mean sd))

                 (org-duration-from-minutes (+ mean sd))))))

   Cheers!
     Andrea Fedeli.

[-- Attachment #2: Type: text/html, Size: 3347 bytes --]

             reply	other threads:[~2023-07-09 13:04 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-09 12:46 andrea [this message]
2023-07-09 14:17 ` [BUG] Error in data input and output format for org-columns--summary-estimate Ihor Radchenko
2023-07-09 14:33   ` andrea
2023-07-10  8:57     ` Ihor Radchenko
     [not found]       ` <RXR2XJ$F3602788F3665C159BAF986799B1995C@fedeli.eu>
2023-07-14  9:02         ` Ihor Radchenko
2023-07-14 11:39           ` andrea
2023-07-18  9:10             ` Ihor Radchenko
2023-08-15 15:53               ` andrea
2023-08-16 10:15                 ` Ihor Radchenko
2023-08-18  6:20                   ` andrea
2023-08-18  9:29                     ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='RXJ4U3$C6D44098F78E9824538618D9BEAECEDA@fedeli.eu' \
    --to=andrea@fedeli.eu \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).