Skip to content

feat: expr builder#5252

Open
seanpearsonuk wants to merge 35 commits into
mainfrom
feat/expr-builder
Open

feat: expr builder#5252
seanpearsonuk wants to merge 35 commits into
mainfrom
feat/expr-builder

Conversation

@seanpearsonuk

@seanpearsonuk seanpearsonuk commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Pull request overview

This PR introduces a new Fluent expression builder subsystem (AST + registry + parser + discovery + builder facade) and integrates it with the solver settings API so expression objects can be assigned directly to setup.named_expressions[...].definition. It also adds a comprehensive set of unit/grammar/discovery/integration tests plus a minimal Fluent smoke test.

Changes:

  • Added ansys.fluent.core.expressions package providing an AST, function registry, builder facade, discovery layer, and a recursive-descent parser with round-tripping.
  • Extended Textual.set_state() to accept “expression objects” (duck-typed via __fluent_expr__) at whitelisted settings paths.
  • Added tests covering parsing, registry coverage, discovery via settings/field-info fakes, flobject integration, and a live Fluent smoke test.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new Fluent expression builder subsystem (AST + registry + parser + discovery + builder facade) and integrates it with the solver settings API so expression objects can be assigned directly to setup.named_expressions[...].definition. It also adds a comprehensive set of unit/grammar/discovery/integration tests plus a minimal Fluent smoke test.

Changes:

  • Added ansys.fluent.core.expressions package providing an AST, function registry, builder facade, discovery layer, and a recursive-descent parser with round-tripping.
  • Extended Textual.set_state() to accept “expression objects” (duck-typed via __fluent_expr__) at whitelisted settings paths.
  • Added tests covering parsing, registry coverage, discovery via settings/field-info fakes, flobject integration, and a live Fluent smoke test.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tests/expressions/test_parser.py Parser unit tests and canonical round-trip coverage.
tests/expressions/test_grammar.py Grammar coverage tests for reductions/math/vector/conditional APIs.
tests/expressions/test_fluent_smoke.py Live Fluent smoke test validating end-to-end builder→settings→evaluation.
tests/expressions/test_flobject_expression_integration.py Offline tests for Textual.set_state expression-object acceptance/rejection by path.
tests/expressions/test_field_info_discovery.py Tests for discovery behavior using field-info shaped fakes.
tests/expressions/test_expression_builder.py Core builder/AST/registry behavior tests (rendering, operators, errors).
tests/expressions/test_discovery.py Tests for settings-tree-driven discovery and slot accessors.
src/ansys/fluent/core/solver/flobject.py Adds whitelisted-path expression-object support to Textual.set_state().
src/ansys/fluent/core/expressions/errors.py Introduces ExpressionBuildError.
src/ansys/fluent/core/expressions/builder.py Implements ExpressionBuilder facade and group/signature invokers.
src/ansys/fluent/core/expressions/_slots.py Adds per-parameter slot discovery helpers (locations/scalars).
src/ansys/fluent/core/expressions/_registry.py Declares the function registry, signature/param binding, and Weight enum.
src/ansys/fluent/core/expressions/_parser.py Implements tokenizer + recursive-descent parser + reverse maps for kind inference.
src/ansys/fluent/core/expressions/_discovery.py Implements best-effort discovery against settings and/or field-info.
src/ansys/fluent/core/expressions/_ast.py Adds the typed immutable AST and operator overloading.
src/ansys/fluent/core/expressions/init.py Public package exports for builder/parser/types.
doc/changelog.d/5252.added.md Changelog entry for the new expression builder feature.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ansys/fluent/core/expressions/_parser.py Outdated
Comment thread src/ansys/fluent/core/expressions/_ast.py
Comment thread src/ansys/fluent/core/expressions/_slots.py
Comment thread src/ansys/fluent/core/expressions/builder.py
Comment thread src/ansys/fluent/core/solver/flobject.py
Comment thread doc/changelog.d/5252.added.md
seanpearsonuk and others added 2 commits July 10, 2026 19:47
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
seanpearsonuk and others added 2 commits July 10, 2026 19:48
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@seanpearsonuk
seanpearsonuk marked this pull request as ready for review July 21, 2026 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants