If "type" is "logical" cast according to "as.logical()" logic
Closed this issue · 2 comments
trevorld commented
- instead of Python's
bool()
logic (everything but""
is TRUE instead use R'sas.logical()
's logic) - write a custom function in our Python code and use that as our "type"
trevorld commented
- @Lain-inrae although #37 hasn't been supported, casting to the "logical" type now follows R's logic instead of Python's logic.
- Doesn't seem to be quite what you wanted with a custom bool type but perhaps closer than before. "T", "True", "TRUE", "true", "F", "False", "FALSE", "false" (but not "0" / "1") now cast to "reasonable" values.
parser <- ArgumentParser(prog='PROG')
parser$add_argument('-p', type="logical", action="append", help="a list of booleans")
args <- strsplit("-p T -p F -p True -p False -p 1 -p 0 -p badValue", " ")[[1]]
parser$parse_args(args)
[1] TRUE FALSE TRUE FALSE NA NA NA
Lain-inrae commented
Thanks that's great!