-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Design: flexible number of returns #2367
Comments
For more complex generic functions like predict I prefer the bunch option, with unfilled slots as appropriate. I did this for predict in PHReg without thinking of the implications. I wanted to return the predicted log hazard, cumulative hazard, standard errors, etc. Then I tried to use this with new generic procedures like MICE and Mediation and ran into trouble because predict usually just returns the fitted values. So I had to (temporarily) special case PHReg, or leave it broken. |
For the special case of Can you split it up this way in PHReg, so the plain predict is compatible with MICE and Mediation? |
I'm not such a heavy user of statsmodels so perhaps my opinion isn't worth much but this may be a better idea: assuming that most of the time, there is one (or two, but a fixed number) of "main" results and a number of additional results that should be computed only on request, provide two functions, This way, the generic user can just call A properly designed decorator should be able to make this not so hard on the library side, e.g.
The decorator would generate a first wrapper function that would call the wrappee while disallowing requests for extra args, and drop the additional info (which should be set to None). It would also generate a second wrapper function (the |
@anntzer Changing to this doesn't really change the "feature" that we have different returns based on the keyword arguments, does it? In general I don't like decorators, although we make heavy use of our cache decorators. Also we already have one level of wrapping in the results for pandas objects. |
No, now the return value would always be the same: a single value for |
What are the functions that have a variable number of returns based on the keyword arguments?
acf return see #2366
design options
None
, so the number of returns remains unchanged (proposed in Uniform return value from {,p}acf #2366 )Any changes in number and types of returns will break backwards compatibility, and we should settle on a pattern so we have to break it only once
The text was updated successfully, but these errors were encountered: