Skip to content

Basket Nodes API

github-actions[bot] edited this page Jul 13, 2026 · 2 revisions

The csp.basketlib library contains useful functions for working with list and dict baskets. These functions are found in the csp.basketlib module and can be called using csp.basketlib.<func>.

Table of Contents

sync_list

sync_list(x: List[ts["T"]], threshold: timedelta, output_incomplete: bool = True, trigger: ts["K"] = None) → csp.OutputBasket(
    List[ts["T"]], shape_of="x"
)

Synchronizes a list basket of time series within some threshold.

If trigger is specified, then it will control when we begin the synchronization intervals. If it is not specified, any element of x will trigger the start of a synchronization interval. Once an interval is triggered, we wait up to threshold time for all elements of the basket x to tick. Once all elements of the list basket tick at least once or the threshold elapses and output_incomplete=True, we return a list basket with the most recent value of each time series (between the interval's first tick and now) and reset the synchronization interval.

Args:

  • x: a list basket of time series to synchronize.
  • threshold: the time to wait for all elements of the basket to tick before propagating the values.
  • output_incomplete: if True, return an incomplete output basket if the threshold elapses before all values tick. Else, do not output in this situation.
  • trigger: an optional time-series which will trigger a synchronization period. If trigger is used, the first tick of x will not trigger a synchronization period.

sync_dict

sync_dict(x: Dict["K", ts["T"]], threshold: timedelta, output_incomplete: bool = True, trigger: ts["K"] = None) → csp.OutputBasket(
    Dict["K", ts["T"]], shape_of="x"
)

Synchronizes a dict basket of time series within some threshold. For the specific synchronization behavior, see the docs for sync_list above.

Args:

  • x: a dict basket of time series to synchronize.
  • threshold: the time to wait for all elements of the basket to tick before propagating the values.
  • output_incomplete: if True, return an incomplete output basket if the threshold elapses before all values tick. Else, do not output in this situation.
  • trigger: an optional time-series which will trigger a synchronization period. If trigger is used, the first tick of x will not trigger a synchronization period.

sync

sync(x, threshold: timedelta, output_incomplete: bool = True, trigger: ts["K"] = None)

Helper function which calls sync_list if x is a list basket and sync_dict if x is a dict basket. If x is not a valid basket, it will raise an exception.

sample_list

sample_list(trigger: ts["Y"], x: List[ts["T"]]) → csp.OutputBasket(List[ts["T"]], shape_of="x")

Samples a list basket of time series on a common trigger.

Args:

  • trigger: when trigger ticks, sample the most recent value of each element in x.
  • x: the list basket of time series to sample.

sample_dict

sample_dict(trigger: ts["Y"], x: Dict["K", ts["T"]]) → csp.OutputBasket(Dict["K", ts["T"]], shape_of="x")

Samples a dict basket of time series on a common trigger.

Args:

  • trigger: when trigger ticks, sample the most recent value of each element in x.
  • x: the dict basket of time series to sample.

sample_basket

sample_basket(trigger, x)

Helper function which calls sample_list if x is a list basket and sample_dict if x is a dict basket. If x is not a valid basket, it will raise an exception.

Clone this wiki locally