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
Added indicator streams and reference indicators #60
Conversation
I'm open to suggestions on naming. Also, I'm thinking that Should |
It all looks good to me. Yes, returning an error code is a good idea, we must be consistent. In the code I've seen so far, all the testing for erroneous conditions was performed prior to any calculations, conceptually at the |
Have you benchmarked it yet? |
@@ -272,15 +276,26 @@ long int ti_build(); | |||
typedef int (*ti_indicator_start_function)($fun_args_start); | |||
typedef int (*ti_indicator_function)($fun_args); | |||
|
|||
|
|||
struct ti_stream; typedef struct ti_stream ti_stream; | |||
typedef int (*ti_indicator_stream_new)($fun_stream_new_args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not to return the pointer just like malloc does? we would still be able to check for errors, wouldn't we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can only have one return value, so it's either:
int stream_new(TI_REAL const *options, ti_stream **stream);
or
ti_stream *stream_new(TI_REAL const *options, int *return_code);
I don't think either is better or worse, really. The normal functions return int
, so I just did that for consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think returning "ti_stream" would have been a better choice, since that's the actual return type and that is what the client needs to pass again and again to compute streaming indicator. Its req. in get_info/ progress/ stream_run / stream_free.
I haven't benchmarked anything. I think the next step is to integrate this with the benchmark program. Also, either expand Finally, it should be integrated into
I think it would be very uncommon, but we may as well keep the return value. Maybe it'll come in handy at some point. About the only thing I can imagine is if a really complicated indicator needs to do memory allocation and that fails. The other failure cases should usually be handled by just returning NaNs. |
I changed smoke so that it test streaming indicators both 1 bar at a time and all the bars at once. The streaming code is complicated enough that I think it's import to make sure it goes something both ways. |
Merged to 0.9. I won't have time to work on TI for a while. Feel free to build on it. |
I will. Thanks for the work done! |
Indicator streams #57
Reference indicators #59
indicators.tcl
now takes an extra parametr for each indicator. This option can be "ref" or "stream" or both. It'll generate code accordingly.I used ATR as the first example. ATR is easy to make a reference for (call
ti_tr
, callti_wilders
) and it's easy (but not trivial) to make a streaming indicator for.I updated
smoke
to check ref and stream if available.I updated the Makefile to c99. It's a lot easier.