r90970 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90969‎ | r90970 | r90971 >
Date:15:35, 28 June 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
added mean format
Modified paths:
  • /trunk/extensions/SemanticResultFormats/Math/SRF_Math.php (modified) (history)
  • /trunk/extensions/SemanticResultFormats/RELEASE-NOTES (modified) (history)
  • /trunk/extensions/SemanticResultFormats/SemanticResultFormats.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticResultFormats/SemanticResultFormats.php
@@ -113,6 +113,7 @@
114114 'average' => 'SRFMath',
115115 'min' => 'SRFMath',
116116 'max' => 'SRFMath',
 117+ 'mean' => 'SRFMath',
117118 'exhibit' => 'SRFExhibit',
118119 'googlebar' => 'SRFGoogleBar',
119120 'googlepie' => 'SRFGooglePie',
Index: trunk/extensions/SemanticResultFormats/Math/SRF_Math.php
@@ -12,7 +12,6 @@
1313 * @author Yaron Koren
1414 * @author Nathan Yergler
1515 */
16 -
1716 class SRFMath extends SMWResultPrinter {
1817
1918 /**
@@ -56,6 +55,11 @@
5756 case 'average':
5857 return array_sum( $numbers ) / count( $numbers );
5958 break;
 59+ case 'mean':
 60+ sort( $numbers, SORT_NUMERIC );
 61+ $position = ( count( $numbers ) + 1 ) / 2 - 1;
 62+ return ( $numbers[ceil( $position )] + $numbers[floor( $position )] ) / 2;
 63+ break;
6064 }
6165 }
6266
Index: trunk/extensions/SemanticResultFormats/RELEASE-NOTES
@@ -6,7 +6,7 @@
77
88 Changes in this version:
99 * Added compatibility with SMW 1.6.
10 -* Added product format.
 10+* Added product and mean formats.
1111 * Rewrote math formats for efficiency, correct recursion and handling of multiple numerical properties.
1212 * Cleaned up the graph format.
1313 * Fixed division by zero issue (oh shii~) in the tagcloud format.