From f267ba1965a0ef494aef5901236cfd832564ce99 Mon Sep 17 00:00:00 2001 From: John Kerl Date: Tue, 27 Oct 2015 17:06:21 -0400 Subject: [PATCH] make mlr bar arguments resemble mlr histogram arguments --- c/mapping/mapper_bar.c | 30 +++++++++++++++--------------- c/reg_test/expected/out | 24 ++++++++++++------------ c/reg_test/run | 4 ++-- c/todo.txt | 5 ----- 4 files changed, 29 insertions(+), 34 deletions(-) diff --git a/c/mapping/mapper_bar.c b/c/mapping/mapper_bar.c index 43e4fd0a1..204f31865 100644 --- a/c/mapping/mapper_bar.c +++ b/c/mapping/mapper_bar.c @@ -25,7 +25,7 @@ static mapper_t* mapper_bar_parse_cli(int* pargi, int argc, char** argv); #define DEFAULT_FILL_CHAR '*' #define DEFAULT_OOB_CHAR '#' -#define DEFAULT_BLANK_CHAR ' ' +#define DEFAULT_BLANK_CHAR '.' #define DEFAULT_LO 0.0 #define DEFAULT_HI 100.0 #define DEFAULT_WIDTH 40 @@ -43,13 +43,13 @@ static void mapper_bar_usage(FILE* o, char* argv0, char* verb) { fprintf(o, "Replaces a numeric field with a number of asterisks, allowing for cheesy bar plots.\n"); fprintf(o, "These align best with --opprint or --oxtab output format.\n"); fprintf(o, "Options:\n"); - fprintf(o, "-f {a,b,c} Field names to convert to bars.\n"); - fprintf(o, "-c {character} Fill character: default '%c'.\n", DEFAULT_FILL_CHAR); - fprintf(o, "-x {character} Out-of-bounds character: default '%c'.\n", DEFAULT_OOB_CHAR); - fprintf(o, "-b {character} Blank character: default '%c'.\n", DEFAULT_BLANK_CHAR); - fprintf(o, "-l {lo} Lower-limit value for min-width bar: default '%lf'.\n", DEFAULT_LO); - fprintf(o, "-u {hi} Upper-limit value for max-width bar: default '%lf'.\n", DEFAULT_HI); - fprintf(o, "-w {n} Bar-field width: default '%d'.\n", DEFAULT_WIDTH); + fprintf(o, "-f {a,b,c} Field names to convert to bars.\n"); + fprintf(o, "-c {character} Fill character: default '%c'.\n", DEFAULT_FILL_CHAR); + fprintf(o, "-x {character} Out-of-bounds character: default '%c'.\n", DEFAULT_OOB_CHAR); + fprintf(o, "-b {character} Blank character: default '%c'.\n", DEFAULT_BLANK_CHAR); + fprintf(o, "--lo {lo} Lower-limit value for min-width bar: default '%lf'.\n", DEFAULT_LO); + fprintf(o, "--hi {hi} Upper-limit value for max-width bar: default '%lf'.\n", DEFAULT_HI); + fprintf(o, "-w {n} Bar-field width: default '%d'.\n", DEFAULT_WIDTH); } // ---------------------------------------------------------------- @@ -65,13 +65,13 @@ static mapper_t* mapper_bar_parse_cli(int* pargi, int argc, char** argv) { char* verb = argv[(*pargi)++]; ap_state_t* pstate = ap_alloc(); - ap_define_string_array_flag(pstate, "-f", &pfield_names); - ap_define_string_flag(pstate, "-c", &fill_string); - ap_define_string_flag(pstate, "-x", &oob_string); - ap_define_string_flag(pstate, "-b", &blank_string); - ap_define_double_flag(pstate, "-l", &lo); - ap_define_double_flag(pstate, "-u", &hi); - ap_define_int_flag(pstate, "-w", &width); + ap_define_string_array_flag(pstate, "-f", &pfield_names); + ap_define_string_flag(pstate, "-c", &fill_string); + ap_define_string_flag(pstate, "-x", &oob_string); + ap_define_string_flag(pstate, "-b", &blank_string); + ap_define_double_flag(pstate, "--lo", &lo); + ap_define_double_flag(pstate, "--hi", &hi); + ap_define_int_flag(pstate, "-w", &width); if (!ap_parse(pstate, verb, pargi, argc, argv)) { mapper_bar_usage(stderr, argv[0], verb); diff --git a/c/reg_test/expected/out b/c/reg_test/expected/out index 11afa3db1..a5b790b00 100644 --- a/c/reg_test/expected/out +++ b/c/reg_test/expected/out @@ -357,20 +357,20 @@ a=1,c=2,b=3 e=4,d=5 a=6,c=7,b=8 -mlr --opprint bar -f x,y -l 0 -u 1 ./reg_test/input/abixy +mlr --opprint bar -f x,y --lo 0 --hi 1 ./reg_test/input/abixy a b i x y -pan pan 1 ************* ***************************** -eks pan 2 ****************************** ******************** -wye wye 3 ******** ************* -eks wye 4 *************** ***** -wye pan 5 ********************** ********************************** -zee pan 6 ********************* ******************* -eks zee 7 ************************ ******* -zee wye 8 *********************** *************************************** -hat wye 9 * ***************************** -pan wye 10 ******************** ************************************** +pan pan 1 *************........................... *****************************........... +eks pan 2 ******************************.......... ********************.................... +wye wye 3 ********................................ *************........................... +eks wye 4 ***************......................... *****................................... +wye pan 5 **********************.................. **********************************...... +zee pan 6 *********************................... *******************..................... +eks zee 7 ************************................ *******................................. +zee wye 8 ***********************................. ***************************************. +hat wye 9 *....................................... *****************************........... +pan wye 10 ********************.................... **************************************.. -mlr --opprint bar -f x,y -c c -x x -b b -l 0.1 -u 0.9 -w 20 ./reg_test/input/abixy +mlr --opprint bar -f x,y -c c -x x -b b --lo 0.1 --hi 0.9 -w 20 ./reg_test/input/abixy a b i x y pan pan 1 ccccccbbbbbbbbbbbbbb cccccccccccccccbbbbb eks pan 2 ccccccccccccccccbbbb ccccccccccbbbbbbbbbb diff --git a/c/reg_test/run b/c/reg_test/run index c2ad8c5ff..64c720c59 100755 --- a/c/reg_test/run +++ b/c/reg_test/run @@ -123,8 +123,8 @@ run_mlr --csvlite rename -r -g '"e"i,EEE' $indir/date1.csv $indir/da run_mlr regularize $indir/regularize.dkvp -run_mlr --opprint bar -f x,y -l 0 -u 1 $indir/abixy -run_mlr --opprint bar -f x,y -c c -x x -b b -l 0.1 -u 0.9 -w 20 $indir/abixy +run_mlr --opprint bar -f x,y --lo 0 --hi 1 $indir/abixy +run_mlr --opprint bar -f x,y -c c -x x -b b --lo 0.1 --hi 0.9 -w 20 $indir/abixy # ---------------------------------------------------------------- announce TRIVIAL RETAINERS diff --git a/c/todo.txt b/c/todo.txt index 91e3358a3..d5ea5e475 100644 --- a/c/todo.txt +++ b/c/todo.txt @@ -13,11 +13,6 @@ TOP OF LIST ! join on partial value-field matches -MINOR: popall and/or xfer method; use @ sort; replace append @ streamer & where else? - - rid of sllv_append - - decide where to put the free of pthat (caller or callee) - - rid of while-pop loops - - sllv_xfer UT x bar --lo/--hi : imitate histogram x bar bg char default to '.' x bar fg char default to 'o'