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

less verbose error messages? #233

Closed
grahamstark opened this issue Aug 29, 2021 · 5 comments
Closed

less verbose error messages? #233

grahamstark opened this issue Aug 29, 2021 · 5 comments

Comments

@grahamstark
Copy link
Contributor

When running a regression, if I mistype a variable name I'm given a stack trace which runs to three pages after the lines are wrapped (it's actually an 11 line stack trace, with very long lines). A screenshot of the 1st page is attached. This seems quite an impediment to new users. Would it be possible to intercept the exception and replace it with a simple "variable not found" message? I'm interested in contributing to JuliaStats so could have a go at this myself if someone could point me in the right direction, and if I was confident such a patch would be welcomed.

Thanks,

Graham

error message

@kleinschmidt
Copy link
Member

Thanks for reporting this! I agree that this is ugly and makes it hard for new users to figure out what's going on. I think that probably the underlying cause is that we're always converting table input to a Tables.columntable, which is a named tuple of vectors. Because the names are part of the type of a named tuple, they will be printed as part of the stack trace.

I think there are a few places this could be fixed. The first would be (like you suggest) to manually intercept this error in statsmodels and replace it with something nicer. The second would be to use Tables.getcolumn (or something like that) to access columns, and if the error messages/stacktraces for that are not nice then to make an upstream PR. This would also have the added benefit of getting us closer to being able to consume any kind of table without converting (there's some discussion of this in #220 ). For reference, DataFrames DOES have a very nice error message when a column is not found.

@grahamstark
Copy link
Contributor Author

Hi,
thank you for this. I had a wee play at this but didn't get very far :(

The version here: https://github.com/grahamstark/StatsModels.jl reproduces the nice DataFrames error message and produces only one of the huge messages in the stack trace rather than 3, but apart from that isn't much of an improvement. From issue 220 it looks as if there's not much more that can be done so long as the data is of type ColumnTable - is that right? I tried taking the type off and just having an istable() check but various tests broke in ways I don't understand.

I'm happy to open a pull request for my changes if you think it helps, though it's quite a few changes for a marginal improvement.

thanks for all your very useful work on this,

Graham

@kleinschmidt
Copy link
Member

a PR is definitely welcome! easier to review possible changes that way :) you can always mark it as a draft if it doesn't feel finished

@grahamstark
Copy link
Contributor Author

OK, thanks. Duly submitted.

@kleinschmidt
Copy link
Member

Fixed by #235

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

2 participants