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

Small error in the documentation #125

Closed
poldpold opened this issue Mar 1, 2024 · 1 comment
Closed

Small error in the documentation #125

poldpold opened this issue Mar 1, 2024 · 1 comment
Labels
part: documentation Improvements/bugs/changes to documentation

Comments

@poldpold
Copy link

poldpold commented Mar 1, 2024

Describe the bug
In the introduction section of the documentation, under the heading Anatomy of a csp.node the code does not run. We get a python error instead.

To Reproduce
Go to https://github.com/Point72/csp/wiki/0.-Introduction, copy the example code, add from datetime import timedelta and run it:

from datetime import timedelta

@csp.node                                                                # 1
def demo_node(n: int, xs: ts[float], ys: ts[float]) -> ts[float]:        # 2
    with csp.alarms():                                                   # 3
        # Define an alarm time-series of type bool                       # 4
        alarm = csp.alarm(bool)                                          # 5 
                                                                         # 6
    with csp.state():                                                    # 7
        # Create a state variable bound to the node                      # 8
        s_sum = 0.0                                                      # 9
                                                                         # 10
    with csp.start():                                                    # 11
        # Code block that executes once on start of the engine           # 12
        # one can set timeseries properties here as well, such as        # 13
        # csp.set_buffering_policy(xs, tick_count=5)                     # 14
        # csp.set_buffering_policy(xs, tick_history=timedelta(minutes=1))# 15
        # csp.make_passive(xs)                                           # 16
        csp.schedule_alarm(alarm, timedelta(seconds=1), True)            # 17
                                                                         # 18
    with csp.stop():                                                     # 19
        # code block to execute when the engine is done                  # 20
                                                                         # 21
    if csp.ticked(xs, ys) and csp.valid(xs, ys):                         # 22
        s_sum += xs * ys                                                 # 23
                                                                         # 24
    if csp.ticked(alarm):                                                # 25
        csp.schedule_alarm(alarm, timedelta(seconds=1), True)            # 26
        return s_sum                                                     # 27

Expected behavior
Functional code. :) More seriously, adding pass on line 21 would solve the issue. At the same time one could add from datetime import timedelta to make the code more self-contained.

Error Message

Cell In[8], [line 24](vscode-notebook-cell:?execution_count=8&line=24)
    if csp.ticked(xs, ys) and csp.valid(xs, ys):                         # 22
    ^
IndentationError: expected an indented block after 'with' statement on line 21

Runtime Environment
0.1.0
3.11.7 | packaged by conda-forge | (main, Dec 23 2023, 14:43:09) [GCC 12.3.0]
linux

@poldpold poldpold added the type: bug Concrete, reproducible bugs label Mar 1, 2024
@ptomecek
Copy link
Collaborator

ptomecek commented Mar 1, 2024

Thanks for the report! I've updated the wiki manually.

@timkpaine timkpaine added part: documentation Improvements/bugs/changes to documentation and removed type: bug Concrete, reproducible bugs labels Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
part: documentation Improvements/bugs/changes to documentation
Projects
None yet
Development

No branches or pull requests

3 participants