emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [BUG] Error in data input and output format for  org-columns--summary-estimate
@ 2023-07-09 12:46 andrea
  2023-07-09 14:17 ` Ihor Radchenko
  0 siblings, 1 reply; 11+ messages in thread
From: andrea @ 2023-07-09 12:46 UTC (permalink / raw)
  To: emacs-orgmode

[-- 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 --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-08-18  9:30 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-09 12:46 [BUG] Error in data input and output format for org-columns--summary-estimate andrea
2023-07-09 14:17 ` 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

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