Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception in woebin_adj function #39

Open
loveis98 opened this issue Dec 5, 2019 · 0 comments
Open

Exception in woebin_adj function #39

loveis98 opened this issue Dec 5, 2019 · 0 comments

Comments

@loveis98
Copy link

loveis98 commented Dec 5, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant