-
-
Notifications
You must be signed in to change notification settings - Fork 19
added handling of parens in datastream values #17
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
Conversation
|
Thanks! I've verified this works great for Python tuples ( btw, some Micropython/CircuitPython code you can use to quickly try this out is: import time, math
while True:
t = time.monotonic() % 2*math.pi
vals = t, math.sin(t), math.cos(t)
print(vals) # prints python tuple ()
#print(list(vals)) # prints python list []
time.sleep(0.05) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds support for handling parentheses in datastream values by stripping leading and trailing parentheses from both series names and data values during parsing.
- Modifies the
handleIncomingLinefunction to remove leading(and trailing)characters - Updates both series name parsing (lines starting with #) and data value parsing
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| // Parse for chart (existing logic) | ||
| if (line.trim().startsWith('#')) { | ||
| const names = line.replace(/^\s*#+\s*/, '').split(/[\s,\t]+/).filter(Boolean) | ||
| const names = line.replace(/^\(/, '').replace(/\)$/, '').replace(/^\s*#+\s*/, '').split(/[\s,\t]+/).filter(Boolean) |
Copilot
AI
Oct 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parentheses removal logic should be applied after the hash symbol removal, not before. The current order may incorrectly handle cases where parentheses are part of the hash prefix (e.g., '#(data)'). Consider reordering: line.replace(/^\s*#+\s*/, '').replace(/^\(/, '').replace(/\)$/, '')
| const names = line.replace(/^\(/, '').replace(/\)$/, '').replace(/^\s*#+\s*/, '').split(/[\s,\t]+/).filter(Boolean) | |
| const names = line.replace(/^\s*#+\s*/, '').replace(/^\(/, '').replace(/\)$/, '').split(/[\s,\t]+/).filter(Boolean) |
| // Parse for chart (existing logic) | ||
| if (line.trim().startsWith('#')) { | ||
| const names = line.replace(/^\s*#+\s*/, '').split(/[\s,\t]+/).filter(Boolean) | ||
| const names = line.replace(/^\(/, '').replace(/\)$/, '').replace(/^\s*#+\s*/, '').split(/[\s,\t]+/).filter(Boolean) |
Copilot
AI
Oct 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parentheses removal logic is duplicated. Consider extracting this into a helper function to improve maintainability and ensure consistent behavior across both parsing paths.
| return | ||
| } | ||
| const parts = line.trim().split(/[\s,\t]+/).filter(Boolean) | ||
| const parts = line.trim().replace(/^\(/, '').replace(/\)$/, '').split(/[\s,\t]+/).filter(Boolean) |
Copilot
AI
Oct 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parentheses removal logic is duplicated. Consider extracting this into a helper function to improve maintainability and ensure consistent behavior across both parsing paths.
Summary
This commit should add the feature requested in #12.
When parsing the values in 'handleIncomingLine' it replaces starting and ending parens.
Motivation & Context
Closes #12
Changes
How to Test
@todbot
Checklist
npm run lintand fixed any issuesnpm run typecheck(TypeScript) with no errorsnpm testand tests passnpm run test:coverageif code paths changed significantlyAdditional Notes