[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master c0102de: gal_statistics_no_blank_sorted works
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master c0102de: gal_statistics_no_blank_sorted works on zero-length datasets |
Date: |
Tue, 11 Sep 2018 12:57:27 -0400 (EDT) |
branch: master
commit c0102dec24574c0be295d65b6b528c050ebe6177
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>
gal_statistics_no_blank_sorted works on zero-length datasets
Until now, if the input dataset had a lenght of zero, we were just using it
for the output. But that was not good behavior: it ignored fixing of flags
and it also ignored the `inplace' argument. With this option, both are now
taken into account.
---
doc/gnuastro.texi | 14 +++++++++-----
lib/statistics.c | 17 +++++++++++++++--
2 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index 87d4639..d96f174 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -27485,10 +27485,10 @@ sort-related bit flags accordingly.
@deftypefun {gal_data_t *} gal_statistics_no_blank_sorted (gal_data_t
@code{*input}, int @code{inplace})
Remove all the blanks and sort the input dataset. If @code{inplace} is
-non-zero this will happen on the input dataset (and the output dataset will
-be the input dataset). However, if @code{inplace} is zero, this function
-will allocate a new copy of the dataset that is sorted and has no blank
-values.
+non-zero this will happen on the input dataset (in the allocated space of
+the input dataset). However, if @code{inplace} is zero, this function will
+allocate a new copy of the dataset and work on that. Therefore if
address@hidden, the input dataset will be modified.
This function uses the bit flags of the input, so if you have modified the
dataset, set @code{input->flags=0} before calling this function. Also note
@@ -27500,7 +27500,11 @@ If all the elements were blank, then the returned
dataset's @code{size}
will be zero. This is thus a good parameter to check after calling this
function to see if there actually were any non-blank elements in the input
or not and take the appropriate measure. This can help avoid strange bugs
-in later steps.
+in later steps. The flags of a zero-sized returned dataset will indicate
+that it has no blanks and is sorted in an increasing order. Even if having
+blank values or being sorted is not defined on a zero-element dataset, it
+is up to the caller to choose what they will do with a zero-element
+dataset. The flags have to be set after this function any way.
@end deftypefun
@deftypefun {gal_data_t *} gal_statistics_regular_bins (gal_data_t
@code{*input}, gal_data_t @code{*inrange}, size_t @code{numbins}, double
@code{onebinstart})
diff --git a/lib/statistics.c b/lib/statistics.c
index ea3dee5..981bbec 100644
--- a/lib/statistics.c
+++ b/lib/statistics.c
@@ -1421,10 +1421,23 @@ gal_statistics_no_blank_sorted(gal_data_t *input, int
inplace)
else
sorted=noblank;
}
-
/* When the input's size is zero, just return the actual input. */
else
- sorted=input;
+ sorted = inplace ? input : gal_data_copy(input);
+
+ /* Set the blank and sorted flags if the dataset has zero-elements. Even
+ if having blank values or being sorted is not defined on a
+ zero-element dataset, it is up to different functions to choose what
+ they will do with a zero-element dataset. The flags have to be set
+ after this function any way. */
+ if(sorted->size==0)
+ {
+ sorted->flag |= GAL_DATA_FLAG_SORT_CH;
+ sorted->flag |= GAL_DATA_FLAG_BLANK_CH;
+ sorted->flag |= GAL_DATA_FLAG_SORTED_I;
+ sorted->flag &= ~GAL_DATA_FLAG_HASBLANK;
+ sorted->flag &= ~GAL_DATA_FLAG_SORTED_D;
+ }
/* Return final array. */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnuastro-commits] master c0102de: gal_statistics_no_blank_sorted works on zero-length datasets,
Mohammad Akhlaghi <=