Skip to content

SweepFormula: fix parser handling of signed exponents, non-finite operands and empty arrays - #2741

Closed
t-b with Copilot wants to merge 6 commits into
mainfrom
copilot/fix-sweepformula-parser-issues
Closed

SweepFormula: fix parser handling of signed exponents, non-finite operands and empty arrays#2741
t-b with Copilot wants to merge 6 commits into
mainfrom
copilot/fix-sweepformula-parser-issues

Conversation

Copilot AI commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Thanks for opening a PR in MIES ✨!

  • Code can only be merged if the continous integration tests pass
  • Please ensure that the branch is named correctly. See
    here for the detailed explanation.

Description

Three SweepFormula parser/executor defects:

  • 1e-3 gave Operand for - must be numeric (tokenizer split at the exponent sign).
  • 1 - NaN / 1 - inf gave Operand for - must be numeric (non-finite operands stored as strings).
  • [] (empty array) was rejected by the parser.

Changes

  • Scientific notation (MIES_SweepFormula_Parser.ipf): corrected the signed-number regex exponent order (E[+-]?[0-9]+) and added a pending-exponent regex so a +/- immediately following a number ending in e/E is collected into the number rather than parsed as an operator.
  • Non-finite operands (MIES_SweepFormula_Operations.ipf): text operands consisting solely of non-finite literals are converted to numeric inside the +, -, *, / operations. The recognized set (inf, -inf, NaN, -NaN, case-sensitive) mirrors the executor's SFE_ConvertNonFiniteElementsImpl so array and operation contexts stay consistent; standalone literals still return text waves.
  • Empty arrays (MIES_SweepFormula_Parser.ipf): explicit empty-array construction in the array action, producing [] at top level and when nested ([1,[]], [[]]). Relaxing the shared sign-evaluation assert this requires is offset by a guard that keeps invalid () reporting a clear error instead of yielding null.
  • Tests / docs: added cases in UTF_SweepFormula.ipf and documented signed exponents and non-finite operands in SweepFormula.rst.

Examples

1e-3        // 0.001
1 - NaN     // NaN
1 - inf     // -inf
[]          // empty numeric wave

Copilot AI assigned Copilot and t-b Jul 14, 2026
Copilot AI requested review from Copilot and removed request for Copilot July 14, 2026 13:15
Copilot AI linked an issue Jul 14, 2026 that may be closed by this pull request
3 tasks
Copilot AI requested review from Copilot and removed request for Copilot July 14, 2026 13:35
Copilot AI changed the title [WIP] Fix parser issues in SweepFormula SweepFormula: fix parser handling of signed exponents, non-finite operands and empty arrays Jul 14, 2026
Copilot finished work on behalf of t-b July 14, 2026 13:50
Copilot AI requested a review from t-b July 14, 2026 13:50
@t-b

t-b commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

@copilot Please fix the CI.

Copilot AI requested review from Copilot and removed request for Copilot July 14, 2026 14:16

Copilot AI commented Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Please fix the CI.

Fixed in 543e4a1. The compile failure was MIES_SweepFormula_Operations.ipf: error: Expected a wave reference.: the four +/-/*// impl functions redeclared their wave-reference parameters with a same-name function-call assignment (WAVE/Z data0 = SFO_ConvertNonFiniteText(data0)), which Igor parses as wave point-indexing. The converted operands are now stored in distinct locals (data0Num/data1Num).

Copilot finished work on behalf of t-b July 14, 2026 14:18
@t-b
t-b force-pushed the copilot/fix-sweepformula-parser-issues branch from 6ab3cf4 to ecd5fc0 Compare July 14, 2026 14:58
@t-b

t-b commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

@copilot Can you create a separate PR with the exponential changes?

Copilot AI commented Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

@t-b I've opened a new pull request, #2742, to work on those changes. Once the pull request is ready, I'll request review from you.

@t-b

t-b commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

@copilot Please create a new MR against main which has only the changes for the "empty array" fix.

Copilot AI commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

@t-b I've opened a new pull request, #2749, to work on those changes. Once the pull request is ready, I'll request review from you.

@t-b

t-b commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

THis will be done in separate PRs.

@t-b t-b closed this Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SweepFormula: Parser issues

2 participants