Point72 / Point72/csp

Node parser fails to recognize renamed `ts` inputs

Open
#261 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: bug
Dominant language
Python
Stars
441
Forks
90
Avg merge
1d 12m
Merged PRs (30d)
5

Description

Describe the bug

Baskets in csp are not iterable, but should be.

To Reproduce

This code will raise an error:

import csp
from csp import ts

@csp.node
def n(values: [ts[int]]):
    for val in values:
        if csp.ticked(val):
            pass
 
>> CspParseError: unrecognized input 'val'

This code will not:

import csp
from csp import ts

@csp.node
def n(values: [ts[int]]):
    for i in range(len(values)):
        if csp.ticked(values[i]):
            pass

Similarly for dictbaskets:

import csp
from csp import ts

@csp.node
def n(values: {str: ts[int]}):
    for key, val in values.items():
        if csp.ticked(val):
            pass

>> CspParseError: unrecognized input 'val'
import csp
from csp import ts

@csp.node
def n(values: {str: ts[int]}):
    for key, val in values.items():
        if csp.ticked(values[key]):
            pass

Expected behavior

Both of the snippets given above (for list/dictbaskets) should be equivalent.

Error Message

Runtime Environment

0.0.4
3.8.12 (default, Apr 7 2022, 17:33:24)
[GCC 11.2.0]
linux

Additional context

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the listbasket and dictbasket examples with Python 3.8.12, then trace the csp.node parser and the CspParseError path for loop variables and renamed ts inputs. Done means both iteration forms are accepted equivalently and regression coverage confirms the reported snippets no longer raise the parse error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
stream-processing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.