http://www.mediawiki.org/wiki/Special:Code/MediaWiki/90970
Revision: 90970
Author: jeroendedauw
Date: 2011-06-28 15:35:39 +0000 (Tue, 28 Jun 2011)
Log Message:
-----------
added mean format
Modified Paths:
--------------
trunk/extensions/SemanticResultFormats/Math/SRF_Math.php
trunk/extensions/SemanticResultFormats/RELEASE-NOTES
trunk/extensions/SemanticResultFormats/SemanticResultFormats.php
Modified: trunk/extensions/SemanticResultFormats/Math/SRF_Math.php
===================================================================
--- trunk/extensions/SemanticResultFormats/Math/SRF_Math.php 2011-06-28
15:32:13 UTC (rev 90969)
+++ trunk/extensions/SemanticResultFormats/Math/SRF_Math.php 2011-06-28
15:35:39 UTC (rev 90970)
@@ -12,7 +12,6 @@
* @author Yaron Koren
* @author Nathan Yergler
*/
-
class SRFMath extends SMWResultPrinter {
/**
@@ -56,6 +55,11 @@
case 'average':
return array_sum( $numbers ) / count( $numbers
);
break;
+ case 'mean':
+ sort( $numbers, SORT_NUMERIC );
+ $position = ( count( $numbers ) + 1 ) / 2 - 1;
+ return ( $numbers[ceil( $position )] +
$numbers[floor( $position )] ) / 2;
+ break;
}
}
Modified: trunk/extensions/SemanticResultFormats/RELEASE-NOTES
===================================================================
--- trunk/extensions/SemanticResultFormats/RELEASE-NOTES 2011-06-28
15:32:13 UTC (rev 90969)
+++ trunk/extensions/SemanticResultFormats/RELEASE-NOTES 2011-06-28
15:35:39 UTC (rev 90970)
@@ -6,7 +6,7 @@
Changes in this version:
* Added compatibility with SMW 1.6.
-* Added product format.
+* Added product and mean formats.
* Rewrote math formats for efficiency, correct recursion and handling of
multiple numerical properties.
* Cleaned up the graph format.
* Fixed division by zero issue (oh shii~) in the tagcloud format.
Modified: trunk/extensions/SemanticResultFormats/SemanticResultFormats.php
===================================================================
--- trunk/extensions/SemanticResultFormats/SemanticResultFormats.php
2011-06-28 15:32:13 UTC (rev 90969)
+++ trunk/extensions/SemanticResultFormats/SemanticResultFormats.php
2011-06-28 15:35:39 UTC (rev 90970)
@@ -113,6 +113,7 @@
'average' => 'SRFMath',
'min' => 'SRFMath',
'max' => 'SRFMath',
+ 'mean' => 'SRFMath',
'exhibit' => 'SRFExhibit',
'googlebar' => 'SRFGoogleBar',
'googlepie' => 'SRFGooglePie',
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs