-
Notifications
You must be signed in to change notification settings - Fork 22
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
Discussion: input and output argument type casting #5
Comments
I have myself second thoughts about supporting all array-like inputs - it makes type transformation very opaque for the user. To put it differently, I'm convinced now that converting lists to ndarrays and back should be a user's headache. If we can design a decorator for it - it would be nice, but not a must. More interesting question - could we make the ndarray as a default input type, but than still design all algorithms/ function to work directly with pd.Series as well? Basically, repeat what NumPy does already. |
pandas.Series is in a way a wrapper around numpy.ndarray so my expectation is that in most cases it will just work. E.g.
I want to prevent if-statements in the algorithms like: if isinstance(power, pd.Series):
# do this
else:
# do that |
@sladkovm This is the discussion we started before. Shall we continue here?
For algorithms it is possible to accept multiple input argument types and cast them to a desirable type and cast the output to a type similar to the input type (example of a method that does this in the vmpy source code).
Benefits:
Drawbacks:
I have a preference for accepting (i.e. developing for) one input type.
Alternative solution: It might be possible to add input and output argument type casting by decorating the algorithms "on the fly" by calling a helper function after import (sort of similar to this). It's not the cleanest way to do it but it might work, I'll try to make a POC for this. For me this would solve the drawbacks and it would still offer input/output type casting for users that do want it.
The text was updated successfully, but these errors were encountered: