emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[BUG] Error in data input and output format for org-columns--summary-es


From: andrea
Subject: [BUG] Error in data input and output format for org-columns--summary-estimate
Date: Sun, 9 Jul 2023 14:46:51 +0200

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.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]