[Genabel-commits] r1057 - pkg/OmicABEL/src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Dec 15 17:11:08 CET 2012


Author: dfabregat
Date: 2012-12-15 17:11:08 +0100 (Sat, 15 Dec 2012)
New Revision: 1057

Modified:
   pkg/OmicABEL/src/utils.c
Log:
[FEATURE] Check for infs as well as for nans in "average".
* "checkNoNans" also checks for infs.


Modified: pkg/OmicABEL/src/utils.c
===================================================================
--- pkg/OmicABEL/src/utils.c	2012-12-14 18:13:23 UTC (rev 1056)
+++ pkg/OmicABEL/src/utils.c	2012-12-15 16:11:08 UTC (rev 1057)
@@ -320,23 +320,29 @@
 {
 	int i, j;
 	double sum, avg;
-	int nans;
+	int nans, infs;
 
 	for ( j = 0; j < ncols; j++ )
 	{
 		sum = 0.0;
 		nans = 0;
+		infs = 0;
 		for ( i = 0; i < n; i++ )
 		{
 			if ( isnan(data[j*n + i]) )
 				nans++;
+			else if ( isinf(data[j*n + i]) )
+			{
+				fprintf(stderr, "[WARNING] Infinity found in %s %s\n", obj_type, &obj_name[j*namelength]);
+				infs++;
+			}
 			else
 				sum += data[j*n + i];
 		}
-		avg = sum / (n-nans);
+		avg = sum / (n-nans-infs);
 		for ( i = 0; i < n; i++ )
 		{
-			if ( isnan(data[j*n + i]) )
+			if ( isnan(data[j*n + i]) || isinf(data[j*n + i]) )
 				data[j*n + i] = avg;
 		}
 		if ( ((float)nans / n) > (100 - threshold)/(float)100 && verbose )
@@ -349,7 +355,7 @@
 {
 	size_t i;
 	for ( i = 0; i < n; i++ )
-		if ( isnan( buff[i] ) )
+		if ( isnan( buff[i] ) || isinf( buff[i] ) )
 		{
 			fprintf( stderr, err_msg );
 			exit( EXIT_FAILURE );



More information about the Genabel-commits mailing list