Skip to content

Commit

Permalink
test cases for mlr label
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkerl committed Sep 2, 2019
1 parent 453691d commit c6ba387
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
51 changes: 51 additions & 0 deletions c/reg_test/expected/out
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,57 @@ a=zee,b=wye,i=8,EKS=0.5985540091064224,y=0.976181385699006
a=hat,b=wye,i=9,EKS=0.03144187646093577,y=0.7495507603507059
a=pan,b=wye,i=10,EKS=0.5026260055412137,y=0.9526183602969864

mlr label NEW ./reg_test/input/abixy
NEW=pan,b=pan,i=1,x=0.3467901443380824,y=0.7268028627434533
NEW=eks,b=pan,i=2,x=0.7586799647899636,y=0.5221511083334797
NEW=wye,b=wye,i=3,x=0.20460330576630303,y=0.33831852551664776
NEW=eks,b=wye,i=4,x=0.38139939387114097,y=0.13418874328430463
NEW=wye,b=pan,i=5,x=0.5732889198020006,y=0.8636244699032729
NEW=zee,b=pan,i=6,x=0.5271261600918548,y=0.49322128674835697
NEW=eks,b=zee,i=7,x=0.6117840605678454,y=0.1878849191181694
NEW=zee,b=wye,i=8,x=0.5985540091064224,y=0.976181385699006
NEW=hat,b=wye,i=9,x=0.03144187646093577,y=0.7495507603507059
NEW=pan,b=wye,i=10,x=0.5026260055412137,y=0.9526183602969864

mlr label a,NEW,c ./reg_test/input/abixy
a=pan,NEW=pan,c=1,x=0.3467901443380824,y=0.7268028627434533
a=eks,NEW=pan,c=2,x=0.7586799647899636,y=0.5221511083334797
a=wye,NEW=wye,c=3,x=0.20460330576630303,y=0.33831852551664776
a=eks,NEW=wye,c=4,x=0.38139939387114097,y=0.13418874328430463
a=wye,NEW=pan,c=5,x=0.5732889198020006,y=0.8636244699032729
a=zee,NEW=pan,c=6,x=0.5271261600918548,y=0.49322128674835697
a=eks,NEW=zee,c=7,x=0.6117840605678454,y=0.1878849191181694
a=zee,NEW=wye,c=8,x=0.5985540091064224,y=0.976181385699006
a=hat,NEW=wye,c=9,x=0.03144187646093577,y=0.7495507603507059
a=pan,NEW=wye,c=10,x=0.5026260055412137,y=0.9526183602969864

mlr label 1,2,3,4,5,6,7,8 ./reg_test/input/abixy
1=pan,2=pan,3=1,4=0.3467901443380824,5=0.7268028627434533
1=eks,2=pan,3=2,4=0.7586799647899636,5=0.5221511083334797
1=wye,2=wye,3=3,4=0.20460330576630303,5=0.33831852551664776
1=eks,2=wye,3=4,4=0.38139939387114097,5=0.13418874328430463
1=wye,2=pan,3=5,4=0.5732889198020006,5=0.8636244699032729
1=zee,2=pan,3=6,4=0.5271261600918548,5=0.49322128674835697
1=eks,2=zee,3=7,4=0.6117840605678454,5=0.1878849191181694
1=zee,2=wye,3=8,4=0.5985540091064224,5=0.976181385699006
1=hat,2=wye,3=9,4=0.03144187646093577,5=0.7495507603507059
1=pan,2=wye,3=10,4=0.5026260055412137,5=0.9526183602969864

mlr label d,x,f ./reg_test/input/abixy
d=pan,x=pan,f=1,y=0.7268028627434533
d=eks,x=pan,f=2,y=0.5221511083334797
d=wye,x=wye,f=3,y=0.33831852551664776
d=eks,x=wye,f=4,y=0.13418874328430463
d=wye,x=pan,f=5,y=0.8636244699032729
d=zee,x=pan,f=6,y=0.49322128674835697
d=eks,x=zee,f=7,y=0.1878849191181694
d=zee,x=wye,f=8,y=0.976181385699006
d=hat,x=wye,f=9,y=0.7495507603507059
d=pan,x=wye,f=10,y=0.9526183602969864

mlr label d,x,d ./reg_test/input/abixy
mlr label: labels must be unique; got "d"

mlr --csvlite rename -r ^Date_[0-9].*$,Date ./reg_test/input/date1.csv ./reg_test/input/date2.csv
Name,Date,Extraneous
Alice,2015-05-14,foo
Expand Down
6 changes: 6 additions & 0 deletions c/reg_test/run
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,12 @@ run_mlr having-fields --none-matching '"^[a-z][a-z][a-z]$"i' $indir/having-field
run_mlr rename b,BEE,x,EKS $indir/abixy
run_mlr rename nonesuch,nonesuch,x,EKS $indir/abixy

run_mlr label NEW $indir/abixy
run_mlr label a,NEW,c $indir/abixy
run_mlr label 1,2,3,4,5,6,7,8 $indir/abixy
run_mlr label d,x,f $indir/abixy
mlr_expect_fail label d,x,d $indir/abixy

run_mlr --csvlite rename -r '^Date_[0-9].*$,Date' $indir/date1.csv $indir/date2.csv
run_mlr --csvlite rename -r '(.*)e(.*),\1EEE\2' $indir/date1.csv $indir/date2.csv
run_mlr --csvlite rename -r '"(.*)e(.*)"i,\1EEE\2' $indir/date1.csv $indir/date2.csv
Expand Down

0 comments on commit c6ba387

Please sign in to comment.