Add evaluate_expression entrypoint#25
Merged
Merged
Conversation
Evaluates a native-syntax VCell infix expression against a JSON {name: value}
symbol table, returning a 64-bit float (or a structured error).
Java (vcell-native):
- ModelUtils.evaluateExpression(String, Map<String,Double>): parse -> bind to a
SimpleSymbolTable built from the supplied names -> evaluateVector. Any symbol
the expression references must be supplied; extras are ignored.
- Entrypoints.evaluateExpression @centrypoint: parses the symbol-table JSON,
evaluates, and returns a JSON document
{"success":true,"value":<double>} or
{"success":false,"error_type":<exceptionClass>,"message":<text>}.
Non-finite results are surfaced as an error (JSON can't encode Inf/NaN).
- MainRecorder exercises the path so native-image records its config.
Python (libvcell):
- native_utils registers evaluateExpression (hasattr-guarded for older libs).
- native_calls.evaluate_expression returns the structured EvalReturnValue
(success/value/error_type/message).
- model_utils.evaluate_expression returns float or raises VCellExpressionError
(carrying error_type + message); both exported from __init__.
Tests:
- Java: 7 ModelEntrypointsTest cases (value, constant, extra-symbols, unbound,
parse error, divide-by-zero, domain error) - all pass on the JVM.
- Python: raise/return tests, skipped until the native lib is rebuilt.
Docs: new docs/design.md (architecture, FFI conventions, entry-point catalog,
evaluate_expression, how-to-add-an-entrypoint); referenced in mkdocs nav and
the module API reference. Also ignore stray uv.lock (project uses Poetry).
The Python end-to-end path requires rebuilding the native shared library
(scripts/local_build_native.sh) to expose the new C entry point.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Release that adds the evaluate_expression entrypoint. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
evaluate_expression: evaluate a native-syntax VCell infix expression against a{symbol: value}table and get a 64-bit float back — or a structured error.Design
EvalReturnValue(success, value, error_type, message)mirrors the existingReturnValue. The native entry point always returns a JSON document; Python parses it intoEvalReturnValue.native_calls.evaluate_expressionreturns the rawEvalReturnValue(branch on.success); the publicmodel_utils.evaluate_expressionreturns thefloator raisesVCellExpressionError(carrying.error_type+.message).Expression: parse →bindExpression(new SimpleSymbolTable(names))→evaluateVector(values).SimpleSymbolTablegives the lightweight dummy binding — no VCell model / MathDescription needed. Any symbol the expression references must be supplied; extras are ignored.Changes
Java (
vcell-native/):ModelUtils.evaluateExpression,Entrypoints.evaluateExpression@CEntryPoint(JSON in/out),MainRecorderexercise, 7 JVM tests.Python (
libvcell/):native_utils(hasattr-guarded registration),native_calls(EvalReturnValue+ call),model_utils(evaluate_expression+VCellExpressionError), exported from__init__; Python tests.Docs: new
docs/design.md(architecture, FFI conventions, entry-point catalog,evaluate_expression, how-to-add-an-entrypoint) + mkdocs nav + API reference. Also ignore strayuv.lock(project uses Poetry).Verification
ExpressionBindingException, parse error, divide-by-zero →DivideByZeroException, domain →FunctionDomainException).evaluate_expressiontests run against the rebuilt dylib, incl.pytest.raises(VCellExpressionError)with expectederror_type).make checkgreen (ruff, prettier incl. docs, mypy strict, deptry).🤖 Generated with Claude Code