scorecardpy
scorecardpy copied to clipboard
Exception in woebin_adj function
Thank you for python version! My issue is about woebin_adj function:
def menu(i, xs_len, x_i):
...
adj_brk = input("Selection: ")
adj_brk = int(adj_brk)
if adj_brk not in [0,1,2,3]:
warnings.warn('Enter an item from the menu, or 0 to exit.')
adj_brk = input("Selection: ")
adj_brk = int(adj_brk)
return adj_brk
If you make any mistake in selection, action adj_brk = int(adj_brk)
will cause ValueError exception and throw you out of interactive mode.
I think you should change code as something like:
def menu(i, xs_len, x_i):
print('>>> Adjust breaks for ({}/{}) {}?'.format(i, xs_len, x_i))
print('1: next \n2: yes \n3: back')
adj_brk = input("Selection: ")
while(True):
if adj_brk not in ['0', '1', '2', '3']:
warnings.warn('Enter an item from the menu, or 0 to exit.')
adj_brk = input("Selection: ")
continue
else:
break
return int(adj_brk)
In addition, 'warnings' don't work for me in interactive mode. May be we should try to use logging instead of 'warnings' module.