Point72 / csp

csp is a high performance reactive stream processing library, written in C++ and Python
https://github.com/Point72/csp/wiki
Apache License 2.0
191 stars 33 forks source link

Explain duplicate timestamps #291

Closed pavithraes closed 1 month ago

pavithraes commented 3 months ago

CSP has a many-to-1 mapping between timestamps and engine cycle. This allows for duplication of timestamps in the same engine cycle, for specific use cases. This needs to be documented, potentially in https://github.com/Point72/csp/wiki/Execution-Modes.

An example (shared by rob);

def g():
    u = csp.unroll(csp.const.using(T=[int])([1, 2, 3]))
    s = csp.sample(csp.const(True), u)
    csp.print('u', u)
    csp.print('s', s)
csp.run(g, starttime=datetime(2024, 1, 1))
> 2024-01-01 00:00:00 u:1
> 2024-01-01 00:00:00 s:1
> 2024-01-01 00:00:00 u:2
> 2024-01-01 00:00:00 u:3

csp.unroll is also used in the seismology example

AdamGlustein commented 2 months ago

https://github.com/Point72/csp/wiki/Execution-Modes#csppushmode

Seems like this is appropriately documented.

robambalu commented 2 months ago

The request here was to document the nuances / gotchas of having dup timestamps, ie in the example mentioned above the sample may not behave the way one would naively expect