gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master ca55b437 2/2: Table: --rowrange is new name fo


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master ca55b437 2/2: Table: --rowrange is new name for old --rowlimit
Date: Wed, 15 Jun 2022 15:12:29 -0400 (EDT)

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

    Table: --rowrange is new name for old --rowlimit
    
    Until now, Table used the name '--rowlimit' to only show rows in a certain
    range of positions within the table. However, this name was not clear and
    confusing.
    
    With this commit, this option is now called '--rowrange' since it accepts a
    range of row positions to show.
---
 NEWS              |  7 +++++++
 bin/table/args.h  |  6 +++---
 bin/table/main.h  |  2 +-
 bin/table/table.c | 18 +++++++++---------
 bin/table/ui.c    | 22 +++++++++++-----------
 bin/table/ui.h    |  2 +-
 doc/gnuastro.texi | 12 ++++++------
 7 files changed, 38 insertions(+), 31 deletions(-)

diff --git a/NEWS b/NEWS
index 0158b28f..7f498358 100644
--- a/NEWS
+++ b/NEWS
@@ -83,6 +83,13 @@ See the end of the file for license conditions.
      behavior, use the new '--mcolnocustprof' option. This new
      functionality was proposed by Elham Saremi.
 
+  Table:
+   --rowrange: new name for the old '--rowlimit'. This option takes the
+     range of desired rows based on their position (for example
+     '--rowrange=2,5' will only print rows 2, 3, 4 and 5 of the table). But
+     the old name was very confusing and would not directly convey this
+     behavior.
+
 ** Bugs fixed
   bug #62216: MakeProfiles crash when a 3D cube is requested and input
               catalog is from a pipe. Found by Irene Pintos Castro.
diff --git a/bin/table/args.h b/bin/table/args.h
index b11ab2da..502f0a8e 100644
--- a/bin/table/args.h
+++ b/bin/table/args.h
@@ -342,13 +342,13 @@ struct argp_option program_options[] =
       GAL_OPTIONS_NOT_SET
     },
     {
-      "rowlimit",
-      UI_KEY_ROWLIMIT,
+      "rowrange",
+      UI_KEY_ROWRANGE,
       "INT,INT",
       0,
       "Only rows in this row-counter range.",
       UI_GROUP_OUTROWS,
-      &p->rowlimit,
+      &p->rowrange,
       GAL_TYPE_STRING,
       GAL_OPTIONS_RANGE_GE_0,
       GAL_OPTIONS_NOT_MANDATORY,
diff --git a/bin/table/main.h b/bin/table/main.h
index 98015fe4..c10ff4bb 100644
--- a/bin/table/main.h
+++ b/bin/table/main.h
@@ -107,7 +107,7 @@ struct tableparams
   uint8_t          descending;  /* Sort columns in descending order.    */
   size_t                 head;  /* Output only the no. of top rows.     */
   size_t                 tail;  /* Output only the no. of bottom rows.  */
-  gal_data_t        *rowlimit;  /* Output rows in row-counter range.    */
+  gal_data_t        *rowrange;  /* Output rows in row-counter range.    */
   size_t            rowrandom;  /* Number of rows to show randomly.     */
   uint8_t             envseed;  /* Use the environment for random seed. */
   gal_list_str_t *catcolumnfile; /* Filename to concat column wise.     */
diff --git a/bin/table/table.c b/bin/table/table.c
index 853c554e..0d7c3c2d 100644
--- a/bin/table/table.c
+++ b/bin/table/table.c
@@ -656,7 +656,7 @@ table_select_by_position(struct tableparams *p)
   char **strarr;
   gal_data_t *col;
   size_t i, start, end;
-  double *darr = p->rowlimit ? p->rowlimit->array : NULL;
+  double *darr = p->rowrange ? p->rowrange->array : NULL;
 
   /* If the head or tail values are given and are larger than the number of
      rows, just set them to the number of rows (print the all the final
@@ -685,16 +685,16 @@ table_select_by_position(struct tableparams *p)
       return;
     }
 
-  /* Make sure the given values to '--rowlimit' are within the number of
+  /* Make sure the given values to '--rowrange' are within the number of
      rows until this point. */
-  if(p->rowlimit)
+  if(p->rowrange)
     {
       if(darr[0]>=p->table->size)
-        error(EXIT_FAILURE, 0, "the first value to '--rowlimit' (%g) "
+        error(EXIT_FAILURE, 0, "the first value to '--rowrange' (%g) "
               "is larger than the number of rows (%zu)",
               darr[0]+1, p->table->size);
       else if( darr[1]>=p->table->size )
-        error(EXIT_FAILURE, 0, "the second value to '--rowlimit' (%g) "
+        error(EXIT_FAILURE, 0, "the second value to '--rowrange' (%g) "
               "is larger than the number of rows (%zu)",
               darr[1]+1, p->table->size);
     }
@@ -711,9 +711,9 @@ table_select_by_position(struct tableparams *p)
         {
           /* Parse the rows and free extra pointers. */
           strarr=col->array;
-          if(p->rowlimit)
+          if(p->rowrange)
             {
-              /* Note that the given values to '--rowlimit' started from 1,
+              /* Note that the given values to '--rowrange' started from 1,
                  but in 'ui.c' we subtracted one from it (so at this stage,
                  it starts from 0). */
               start = darr[0];
@@ -734,7 +734,7 @@ table_select_by_position(struct tableparams *p)
         }
 
       /* Make the final adjustment. */
-      if(p->rowlimit)
+      if(p->rowrange)
         {
           /* Move the values up to the top and correct the size. */
           col->size=darr[1]-darr[0]+1;
@@ -1201,7 +1201,7 @@ table(struct tableparams *p)
   if(p->sort) table_sort(p);
 
   /* If the output number of rows is limited, apply them. */
-  if( p->rowlimit
+  if( p->rowrange
       || p->rowrandom
       || p->head!=GAL_BLANK_SIZE_T
       || p->tail!=GAL_BLANK_SIZE_T )
diff --git a/bin/table/ui.c b/bin/table/ui.c
index 8c8dc3c0..9857c7fa 100644
--- a/bin/table/ui.c
+++ b/bin/table/ui.c
@@ -276,37 +276,37 @@ ui_read_check_only_options(struct tableparams *p)
 
   /* Make sure only one of the positional row selection operations is
      called in one run. */
-  if( (p->rowlimit!=NULL)
+  if( (p->rowrange!=NULL)
       + (p->rowrandom!=0)
       + (p->head!=GAL_BLANK_SIZE_T)
       + (p->tail!=GAL_BLANK_SIZE_T) > 1 )
     error(EXIT_FAILURE, 0, "only one of the following options can be "
-          "called in one run: '--head', '--tail', '--rowlimit' and "
+          "called in one run: '--head', '--tail', '--rowrange' and "
           "'--rowrandom'");
 
-  /* Make sure the value to '--rowlimit' is in the correct format. */
-  if(p->rowlimit)
+  /* Make sure the value to '--rowrange' is in the correct format. */
+  if(p->rowrange)
     {
       /* There should only be two values. */
-      if(p->rowlimit->size!=2)
+      if(p->rowrange->size!=2)
         error(EXIT_FAILURE, 0, "only two should be given to "
-              "'--rowlimit' (the top and bottom row numbers specifying "
+              "'--rowrange' (the top and bottom row numbers specifying "
               "your desired range)");
 
       /* Do individual checks. */
-      darr=p->rowlimit->array;
-      for(i=0;i<p->rowlimit->size;++i)
+      darr=p->rowrange->array;
+      for(i=0;i<p->rowrange->size;++i)
         {
           /* Make sure it isn't 0 or negative. */
           if( darr[i]<=0 )
-            error(EXIT_FAILURE, 0, "%g (value given to '--rowlimit') "
+            error(EXIT_FAILURE, 0, "%g (value given to '--rowrange') "
                   "is smaller than, or equal to, zero! This option's "
                   "values are row-counters (starting from 1), so they "
                   "must be positive integers", darr[i]);
 
           /* Make sure its an integer. */
           if( darr[i] != (size_t)(darr[i]) )
-            error(EXIT_FAILURE, 0, "%g (value given to '--rowlimit') is "
+            error(EXIT_FAILURE, 0, "%g (value given to '--rowrange') is "
                   "not an integer! This option's values are row-counters "
                   "so they must be integers.", darr[i]);
 
@@ -316,7 +316,7 @@ ui_read_check_only_options(struct tableparams *p)
 
       /* Make sure that the first value is smaller than the second. */
       if( darr[0] > darr[1] )
-        error(EXIT_FAILURE, 0, "the first value to '--rowlimit' (%g) is "
+        error(EXIT_FAILURE, 0, "the first value to '--rowrange' (%g) is "
               "larger than the second (%g). This option's values defines "
               "a row-counter interval, assuming the first value is the top "
               "of the desired interval (smaller row counter) and the second "
diff --git a/bin/table/ui.h b/bin/table/ui.h
index 2da55b28..b1cd6ced 100644
--- a/bin/table/ui.h
+++ b/bin/table/ui.h
@@ -72,7 +72,7 @@ enum option_keys_enum
      automatically). */
   UI_KEY_POLYGON         = 1000,
   UI_KEY_ENVSEED,
-  UI_KEY_ROWLIMIT,
+  UI_KEY_ROWRANGE,
   UI_KEY_ROWRANDOM,
   UI_KEY_INPOLYGON,
   UI_KEY_OUTPOLYGON,
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index 21f8f44f..1851ac7c 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -13045,7 +13045,7 @@ The column to sort by can only come from the main input 
table columns (not colum
 @item
 @option{--rowrandom}: keep only a random number of rows.
 @item
-@option{--rowlimit}: keep only rows within a certain positional interval.
+@option{--rowrange}: keep only rows within a certain positional interval.
 @end itemize
 
 These options limit/select rows based on their position within the table (not 
their value in any certain column).
@@ -13456,7 +13456,7 @@ When called with @option{--sort}, rows will be sorted 
in descending order.
 Only print the given number of rows from the @emph{top} of the final table.
 Note that this option only affects the @emph{output} table.
 For example if you use @option{--sort}, or @option{--range}, the printed rows 
are the first @emph{after} applying the sort sorting, or selecting a range of 
the full input.
-This option cannot be called with @option{--tail}, @option{--rowlimit} or 
@option{--rowrandom}.
+This option cannot be called with @option{--tail}, @option{--rowrange} or 
@option{--rowrandom}.
 For the precedence of this operation in relation to others, see @ref{Operation 
precedence in Table}.
 
 @cindex GNU Coreutils
@@ -13467,11 +13467,11 @@ This behavior is taken from the @command{head} 
program in GNU Coreutils.
 @itemx --tail=INT
 Only print the given number of rows from the @emph{bottom} of the final table.
 See @option{--head} for more.
-This option cannot be called with @option{--head}, @option{--rowlimit} or 
@option{--rowrandom}.
+This option cannot be called with @option{--head}, @option{--rowrange} or 
@option{--rowrandom}.
 
-@item --rowlimit=INT,INT
+@item --rowrange=INT,INT
 Only return the rows within the requested positional range (inclusive on both 
sides).
-Therefore, @code{--rowlimit=5,7} will return 3 of the input rows, row 5, 6 and 
7.
+Therefore, @code{--rowrange=5,7} will return 3 of the input rows, row 5, 6 and 
7.
 This option will abort if any of the given values is larger than the total 
number of rows in the table.
 For the precedence of this operation in relation to others, see @ref{Operation 
precedence in Table}.
 
@@ -13486,7 +13486,7 @@ Select @code{INT} rows from the input table by random 
(assuming a uniform distri
 This option is applied @emph{after} the value-based selection options (like 
@option{--sort}, @option{--range}, @option{--polygon} and etc).
 On the other hand, only the row counters are randomly selected, this option 
doesn't change the order.
 Therefore, if @option{--rowrandom} is called together with @option{--sort}, 
the returned rows are still sorted.
-This option cannot be called with @option{--head}, @option{--tail}, or 
@option{--rowlimit}.
+This option cannot be called with @option{--head}, @option{--tail}, or 
@option{--rowrange}.
 For the precedence of this operation in relation to others, see @ref{Operation 
precedence in Table}.
 
 This option will only have an effect if @code{INT} is larger than the number 
of rows when it is activated (after the value-based selection options have been 
applied).



reply via email to

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