JuliaAlgebra / MultivariatePolynomials.jl

Multivariate polynomials interface
https://juliaalgebra.github.io/MultivariatePolynomials.jl/stable/
Other
135 stars 27 forks source link

Fix showing conjugate variables #288

Closed projekter closed 11 months ago

projekter commented 11 months ago

name_base_indices might return a Symbol instead of a String, in which case we cannot iterate over it; so make sure that we always have a String.

blegat commented 11 months ago

Can you add a test ?

projekter commented 11 months ago

Maybe? I found this issue when implementing my own primitive realization of MP, which is supposed to do an extremely limited set of arithmetic operations in a very fast and non-allocating way, so I ended up using a Symbol for name_base_indices. However, I did a quick scan of GitHub and it seems that the only package (not on Yggdrasil) that uses this particular return type is YAPP, which is version-bound to MP 0.4 (and I have no idea what its purpose is). So there's not really a way to test it without an implementation using it... Of course, this is kind of a problem of MP anyway, as it can't do much without using a implementation, so I could add a test that just checks the output of name_base_indices, but it wouldn't have caught this issue had it been present before.

blegat commented 11 months ago

You can just do

struct SymbolVar <: MP.AbstractVariable end
MP.name_base_indices(::SymbolVar) = (:x, (1,2))

in the tests