gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master 6351cac8: Library (arithmetic.h): isnotblank w


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 6351cac8: Library (arithmetic.h): isnotblank works on input with no blanks
Date: Fri, 7 Jul 2023 07:27:24 -0400 (EDT)

branch: master
commit 6351cac8bba4b23ba5339fa608e067596ad5456c
Author: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>

    Library (arithmetic.h): isnotblank works on input with no blanks
    
    Until now, when the 'isnotblank' operator was run on a dataset that didn't
    have any blank values, the output would be all zeros (while it should have
    been all ones!). This was happening because a separate route was defined
    for datasets that don't have any blanks; and in that route, we hadn't
    accounted for the flagging of non-blank values!
    
    With this commit, the problem was fixed by setting all the values to 1 when
    the input has no blanks.
---
 lib/blank.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/lib/blank.c b/lib/blank.c
index 85f1debe..c1bdf19b 100644
--- a/lib/blank.c
+++ b/lib/blank.c
@@ -625,11 +625,22 @@ blank_flag(gal_data_t *input, int blank1_not0)
                 __func__, input->type);
         }
     }
+
+  /* Input had no blanks */
   else
-    /* Allocate a CLEAR data structure (all zeros). */
-    out=gal_data_alloc(NULL, GAL_TYPE_UINT8, input->ndim, input->dsize,
-                       input->wcs, 1, input->minmapsize, input->quietmmap,
-                       NULL, "bool", NULL);
+    {
+      /* Allocate the output data structure (if the caller wants to flag
+         blanks, then we will "clear" the output also). */
+      out=gal_data_alloc(NULL, GAL_TYPE_UINT8, input->ndim, input->dsize,
+                         input->wcs, blank1_not0 ? 1 : 0,
+                         input->minmapsize, input->quietmmap,
+                         NULL, "bool", NULL);
+
+      /* If the caller wants to flag the non-blank elements, we should now
+         set all the output values to 1 (the input had no blanks!). */
+      if(blank1_not0==0)
+        { of=(o=out->array)+out->size; do *o++=1; while(o<of); }
+    }
 
   /* Return */
   return out;



reply via email to

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