-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Usability of non-standard index ranges in variables of polynomial rings #1492
Comments
Indeed, using a plain
If you want variables showing as
They are mainly for interactive usage and then typically should be created with
Ways to circumvent this that I see are …
|
Probably this is a non-issue because anybody can use Anyway, I guess it would be more helpful if people who want to index variables by non-negative (or non-consecutive) numbers, would state what they want or need. |
Fine, I added a warning. So your example now yields julia> R, x = polynomial_ring(ZZ, :x => (-3:4));
┌ Warning: Indexing with -3:4 can lead to confusion, since the entry at index 1 gets printed as being at index -3.
│ Consider using `"x#" => axes` syntax or communicating your use case to the Oscar community.
└ @ AbstractAlgebra ~/.julia/dev/AbstractAlgebra/src/misc/VarNames.jl:121 Does this “fix” your issue? |
Fine by me. I don't have the rights to properly link the issue in the pull request. |
On Fri, Nov 03, 2023 at 05:57:52AM -0700, Markus Kurtz wrote:
Fine, I added a warning. So your example now yields
```julia
julia> R, x = polynomial_ring(ZZ, :x => (-3:4));
┌ Warning: Indexing with -3:4 can lead to confusion, since the entry at index 1 gets printed as being at index -3.
│ Consider using `"x#" => axes` syntax or communicating your use case to the Oscar community.
└ @ AbstractAlgebra ~/.julia/dev/AbstractAlgebra/src/misc/VarNames.jl:121
```
Does this “fix” your issue?
No, can we please, at least outside the direct repl not print any
warnings? It is either an error - or quiet by default.
… --
Reply to this email directly or view it on GitHub:
#1492 (comment)
You are receiving this because you are subscribed to this thread.
Message ID: ***@***.***>
|
Agree with Claus. Either it is an error or quiet. |
For now, we went back to the old behavior. Throwing errors, would mean to have no proper way to display If we change printing later, using |
This came up in the discussion of #1360 ; requires either #1360 or Oscar:
So
x[5]
givesx[1]
, but if I typex[1]
I getx[-3]
...@fingolfin explained in #1360 (comment) what would be necessary to make indexing by
-3
etc. work. To me personally, this sounds like 'too much magic' and would require constant effort to make new functions fit in the pattern (see point 3 and 4 on the list).I think the main problem is that the variables print like something one should be able to type in the REPL, but when one does one gets unexpected results. So maybe we should print the variables differently? Like
x(-3)
?x_{-3}
? I feel like we should at least comment on this odd behaviour in the documentation somewhere.In general, I am wondering what the use of index ranges other than
1:n
is. I would think they are mainly so that I can type in the variable names as in some paper without needing to think. But as soon as I have to access anything, I have to think again. So is it just to make the output look nice? Note that the@polynomial_ring
macro introduced in #1360 cannot circumvent this because it cannot produce variable names with illegal characters (like-
).The text was updated successfully, but these errors were encountered: