Skip to Content.
Sympa Menu

sm-commit - [SM-Commit] GIT changes to master sorcery by Ismael Luceno (2080a466b0e82498dc218c71f5a479c251f4f785)

sm-commit AT lists.ibiblio.org

Subject: Source Mage code commit list

List archive

Chronological Thread  
  • From: Ismael Luceno <scm AT sourcemage.org>
  • To: sm-commit AT lists.ibiblio.org
  • Subject: [SM-Commit] GIT changes to master sorcery by Ismael Luceno (2080a466b0e82498dc218c71f5a479c251f4f785)
  • Date: Fri, 5 Dec 2014 11:35:50 -0600

GIT changes to master sorcery by Ismael Luceno <ismael AT sourcemage.org>:

var/lib/sorcery/modules/libtime | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)

New commits:
commit 2080a466b0e82498dc218c71f5a479c251f4f785
Author: Ismael Luceno <ismael AT sourcemage.org>
Commit: Ismael Luceno <ismael AT sourcemage.org>

libtime: New compute_median implementation

diff --git a/var/lib/sorcery/modules/libtime b/var/lib/sorcery/modules/libtime
index 0b6e68a..2e05720 100755
--- a/var/lib/sorcery/modules/libtime
+++ b/var/lib/sorcery/modules/libtime
@@ -2,7 +2,7 @@
#---------------------------------------------------------------------
##
## @Synopsis Set of functions used by gaze for time calculations
-## @Copyright (C) 2008 The Source Mage Team <http://www.sourcemage.org>
+## @Copyright (C) 2008-2014 The Source Mage Team <http://www.sourcemage.org>
##
## This file holds various statistical functions and an interface to
## the activity log for getting the input data.
@@ -191,18 +191,17 @@ function compute_weighted_mean() {
## @Stdout median value
#---------------------------------------------------------------------
function compute_median() {
- gawk '
- { numbers[NR] = $0; }
-
+ sort -n | awk '
+ { n[NR] = $0 }
END {
- if (NR == 0) exit
- if (NR == 1) {
- print numbers[0]
+ if (NR > 1) {
+ m = n[1 + int(NR / 2)]
+ print (NR % 2) ? m : (m + n[NR / 2]) / 2
} else {
- asort(numbers)
- print (NR % 2) ? numbers[int(NR/2+1)] : (numbers[NR/2] +
numbers[NR/2+1])/2
+ print n[0]
}
- }'
+ }
+ '
}

#---------------------------------------------------------------------



  • [SM-Commit] GIT changes to master sorcery by Ismael Luceno (2080a466b0e82498dc218c71f5a479c251f4f785), Ismael Luceno, 12/05/2014

Archive powered by MHonArc 2.6.24.

Top of Page