gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master 27a61e0: Statistics program resets blank flags


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 27a61e0: Statistics program resets blank flags after applying limits
Date: Mon, 26 Feb 2018 18:08:41 -0500 (EST)

branch: master
commit 27a61e00c3aa223111bd4da3c60969b53e4aff98
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>

    Statistics program resets blank flags after applying limits
    
    After applying the limits, the Statistics program wouldn't reset the blank
    flags of the dataset. Even though the out-of-range fields of the dataset
    are set to blank. This wasn't visible in most tests until now because they
    were mostly on floating point types were the blank value is NaN is wouldn't
    cause any problem in minimum and maximum checks.
    
    Because of this, the `CHECK_BLANK' argument to `GAL_TILE_PARSE_OPERATE' in
    `gal_statistics_minimum' and `gal_statistics_maximum' were also set to 1.
    
    This fixes bug #53230.
---
 NEWS                        |  2 ++
 bin/statistics/statistics.c |  2 --
 bin/statistics/ui.c         |  7 ++++++-
 lib/statistics.c            | 10 ++++------
 4 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/NEWS b/NEWS
index f8a8585..7e83d09 100644
--- a/NEWS
+++ b/NEWS
@@ -28,6 +28,8 @@ GNU Astronomy Utilities NEWS                          -*- 
outline -*-
 
   Match output directory ignored when making multiple files (bug #53226).
 
+  Statistics program bad results on integer columns with limits (bug #53230).
+
 
 
 
diff --git a/bin/statistics/statistics.c b/bin/statistics/statistics.c
index 62bf0ec..1d10f8e 100644
--- a/bin/statistics/statistics.c
+++ b/bin/statistics/statistics.c
@@ -97,7 +97,6 @@ statistics_print_one_row(struct statisticsparams *p)
   gal_data_t *tmpv, *out=NULL, *num=NULL, *min=NULL, *max=NULL;
   gal_data_t *sum=NULL, *med=NULL, *meanstd=NULL, *modearr=NULL;
 
-
   /* The user can ask for any of the operators more than once, also some
      operators might return more than one usable value (like mode). So we
      will calculate the desired values once, and then print them. */
@@ -1016,5 +1015,4 @@ statistics(struct statisticsparams *p)
   /* If nothing was requested print the simple statistics. */
   if(print_basic_info)
     print_basics(p);
-
 }
diff --git a/bin/statistics/ui.c b/bin/statistics/ui.c
index 2e1d57f..bed2975 100644
--- a/bin/statistics/ui.c
+++ b/bin/statistics/ui.c
@@ -654,7 +654,7 @@ ui_out_of_range_to_blank(struct statisticsparams *p)
   /* Allocate a blank value to mask all pixels that don't satisfy the
      condition. */
   blank=gal_data_alloc(NULL, GAL_TYPE_FLOAT32, 1, &one, NULL,
-                     0, -1, NULL, NULL, NULL);
+                       0, -1, NULL, NULL, NULL);
   *((float *)(blank->array)) = NAN;
 
 
@@ -662,6 +662,11 @@ ui_out_of_range_to_blank(struct statisticsparams *p)
      blank value will be used in the proper type of the input in the
      `where' operator.*/
   gal_arithmetic(GAL_ARITHMETIC_OP_WHERE, flagsor, p->input, cond, blank);
+
+
+  /* Reset the blank flags so they are checked again if necessary. */
+  p->input->flag &= ~GAL_DATA_FLAG_BLANK_CH;
+  p->input->flag &= ~GAL_DATA_FLAG_HASBLANK;
 }
 
 
diff --git a/lib/statistics.c b/lib/statistics.c
index 4ff9b79..ce71667 100644
--- a/lib/statistics.c
+++ b/lib/statistics.c
@@ -80,9 +80,7 @@ gal_statistics_number(gal_data_t *input)
 
 
 /* Return the minimum (non-blank) value of a dataset in the same type as
-   the dataset. Note that a NaN (blank in floating point) will fail on any
-   comparison. So when finding the minimum or maximum, when the blank value
-   is NaN, we can safely assume there is no blank value at all. */
+   the dataset. */
 gal_data_t *
 gal_statistics_minimum(gal_data_t *input)
 {
@@ -94,7 +92,7 @@ gal_statistics_minimum(gal_data_t *input)
   gal_type_max(out->type, out->array);
 
   /* Parse the full input. */
-  GAL_TILE_PARSE_OPERATE(input, out, 0, 0, {*o = *i < *o ? *i : *o; ++n;});
+  GAL_TILE_PARSE_OPERATE(input, out, 0, 1, {*o = *i < *o ? *i : *o; ++n;});
 
   /* If there were no usable elements, set the output to blank, then
      return. */
@@ -107,7 +105,7 @@ gal_statistics_minimum(gal_data_t *input)
 
 
 /* Return the maximum (non-blank) value of a dataset in the same type as
-   the dataset. See explanations of `gal_statistics_minimum'. */
+   the dataset. */
 gal_data_t *
 gal_statistics_maximum(gal_data_t *input)
 {
@@ -119,7 +117,7 @@ gal_statistics_maximum(gal_data_t *input)
   gal_type_min(out->type, out->array);
 
   /* Parse the full input. */
-  GAL_TILE_PARSE_OPERATE(input, out, 0, 0, {*o = *i > *o ? *i : *o; ++n;});
+  GAL_TILE_PARSE_OPERATE(input, out, 0, 1, {*o = *i > *o ? *i : *o; ++n;});
 
   /* If there were no usable elements, set the output to blank, then
      return. */



reply via email to

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