Skip to content
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

inconsistent eachindex: first on a variable array causes a BoundsError when the indexing base is not one #943

Open
nsajko opened this issue Aug 3, 2023 · 1 comment

Comments

@nsajko
Copy link
Contributor

nsajko commented Aug 3, 2023

Minimal reproducer:

using Symbolics
@variables x[0:2]
first(x)  # errors

Seems to be caused by this inconsistency:

julia> using Symbolics

julia> @variables x[0:2]
1-element Vector{Symbolics.Arr{Num, 1}}:
 x[1:3]

julia> ci = eachindex(x)
CartesianIndices((0:2,))

julia> li = eachindex(IndexLinear(), x)
1:3

julia> first(ci)
CartesianIndex(0,)

julia> first(li)
1

Note that Base.first is currently implemented as first(a::AbstractArray) = a[first(eachindex(a))].

@shashi
Copy link
Member

shashi commented Aug 3, 2023

Ahh I thought that @variables x[0:2] should error. Indexes not starting from 1 are not really supported

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants