-
Notifications
You must be signed in to change notification settings - Fork 72
Start organizing examples, increase test coverage of examples #174
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
ec05cd0
Start organizing examples, increase test coverage of examples, fix ca…
timkpaine 01f6633
Organize dependencies in pyproject.toml, add missing to conda linux env
timkpaine 5c1ef8a
Remove caching example, have first ticking example tick at different …
timkpaine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| # Basics | ||
|
|
||
| - [Simplest Possible Graph](./e1_basic.py) | ||
| - [Ticking Graphs](./e2_ticking.py) | ||
| - [Complete Example (Trading)](./e3_trade_pnl.py) | ||
| - [Visualizing a Graph](./e4_show_graph.py) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| from datetime import datetime | ||
|
|
||
| import csp | ||
| from csp import ts | ||
|
|
||
|
|
||
| @csp.node | ||
| def add(x: ts[int], y: ts[int]) -> ts[int]: | ||
| return x + y | ||
|
|
||
|
|
||
| @csp.graph | ||
| def my_graph(): | ||
| x = csp.const(1) | ||
| y = csp.const(2) | ||
|
|
||
| sum = add(x, y) | ||
|
|
||
| csp.print("x", x) | ||
| csp.print("y", y) | ||
| csp.print("sum", sum) | ||
|
|
||
|
|
||
| def main(): | ||
| csp.run(my_graph, starttime=datetime.now()) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| from datetime import datetime, timedelta | ||
|
|
||
| import csp | ||
| from csp import ts | ||
|
|
||
|
|
||
| @csp.node | ||
| def add(x: ts[int], y: ts[int]) -> ts[int]: | ||
| return x + y | ||
|
|
||
|
|
||
| @csp.node | ||
| def accum(val: ts[int]) -> ts[int]: | ||
| with csp.state(): | ||
| s_sum = 0 | ||
| if csp.ticked(val): | ||
| s_sum += val | ||
| return val | ||
|
|
||
|
|
||
| @csp.graph | ||
| def my_graph(): | ||
| st = datetime(2020, 1, 1) | ||
|
|
||
| # Dummy x values | ||
| x = csp.curve(int, [(st + timedelta(1), 1), (st + timedelta(2), 2), (st + timedelta(3), 3)]) | ||
|
|
||
| # Dummy y values | ||
| y = csp.curve(int, [(st + timedelta(1), -1), (st + timedelta(2), -1), (st + timedelta(3), -1)]) | ||
|
|
||
| # Add the time series | ||
| sum = add(x, y) | ||
|
|
||
| # Accumulate the result | ||
| acc = accum(sum) | ||
|
|
||
| csp.print("x", x) | ||
| csp.print("y", y) | ||
| csp.print("sum", sum) | ||
| csp.print("accum", acc) | ||
|
|
||
|
|
||
| def main(): | ||
| start = datetime(2020, 1, 1) | ||
| csp.run(my_graph, starttime=start) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| # Intermediate | ||
|
|
||
| - [Graph Loops (`csp.feedback`)](./e1_feedback.py) | ||
| - [Statistics Nodes](./e2_stats.py) | ||
| - [Statistics Nodes with Numpy](./e3_numpy_stats.py) | ||
| - [Expression Nodes with `exprtk`](./e4_exprtk.py) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Kafka Adapter | ||
|
|
||
| - [Kafka Example](./e1_kafka.py) |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Parquet Adapter | ||
|
|
||
| - [Parquet Writer](./e1_parquet_writer.py) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| # Slack Adapter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Websocket Adapter | ||
|
|
||
| - [Websocket Output](./e1_websocket_output.py) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # Writing Adapters | ||
|
|
||
| - [Generic Push Adapter](./e1_generic_push_adapter.py) | ||
| - [Pull Input Adapter](./e2_pullinput.py) | ||
| - [Pull Input Adapter with Adapter Manager](./e3_adaptermanager_pullinput.py) | ||
| - [Push Input Adapter](./e4_pushinput.py) | ||
| - [Push Input Adapter with Adapter Manager](./e5_adaptermanager_pushinput.py) | ||
| - [Output Adapter](./e6_outputadapter.py) | ||
| - [Complete Input/Output Adapter with Adapter Manager](./e7_adaptermanager_inputoutput.py) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.