matfun(exp, x, A) returns a matrix of bare 'exp' symbols with wrong off-diagonals instead of a value or an error

Open Beginner friendly
#277 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
75/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
python, rust
Domain
backend

Research direction

Start with the matfun implementation and its existing tests, especially how bare symbols and applied expressions are represented. Compare the exp and exp(x) paths to find where the symbol is accepted without evaluation. Done means one behavior is implemented consistently: the function is applied to the eigenvalues, or a clear error requires an applied expression, with a regression test for the bare-symbol case.

Written by the indexing model from the issue text.

Description

area/linear-algebra good first issue help wanted kind/wrong-result severity/4-minor

matfun with a bare function symbol returns a matrix of that symbol instead of a value or an error.

import rssn
s = rssn.Session()

s.compute("matfun(exp, x, list(list(1,0),list(0,2)))").text
# 'list(list(exp, 0), list(0, exp))'      <- bare symbols, and the off-diagonals are wrong

s.compute("matfun(exp(x), x, list(list(1,0),list(0,2)))").text
# 'list(list(E, 0), list(0, exp(2)))'     <- correct

For A = diag(1,2), matfun(f, x, A) applies f to the eigenvalues, so the answer is diag(exp(1), exp(2)) = diag(E, exp(2)) — which is exactly what the second call returns.

The first call passes exp as a bare function symbol. It returns diag(exp, exp): the symbol itself in each diagonal slot, and zero off-diagonals regardless of the matrix, so for a non-diagonal A the off-diagonals would be wrong as well. .reduced is True and .error is None, so this is presented as a computed result.

The two calls differ only in whether the function is written exp or exp(x), and the docstring does not say which form is expected, so a caller can easily hit the wrong one and get a plausible-looking matrix of symbols back.

Expected: either treat a bare symbol as the function and apply it properly (diag(exp(1), exp(2))), or reject the argument with an error explaining that an applied expression like exp(x) is required.

rssn 0.3.0, Python binding, Windows x86_64.

Dominant language
Rust
Stars
36
Forks
3
Avg merge
18h 51m
Merged PRs (30d)
18

Getting set up

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.

More from Apich-Organization/rssn

All issues in Apich-Organization/rssn

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.