Skip to content

Report element count in generator-too-short error - #1348

Open
JohnCobbler wants to merge 1 commit into
JuliaArrays:masterfrom
JohnCobbler:fix/1207-generator-error-count
Open

Report element count in generator-too-short error#1348
JohnCobbler wants to merge 1 commit into
JuliaArrays:masterfrom
JohnCobbler:fix/1207-generator-error-count

Conversation

@JohnCobbler

Copy link
Copy Markdown

The too-short generator error printed the failing CartesianIndex
coordinate via shape_string(i), not the number of values actually
produced. For SVector{5}(i for i in 1:5 if i != 2) that showed
"stopped at 5" even though only 4 elements were yielded.

Report the produced count as LinearIndices(inds)[i] - 1 instead, and
drop the unused shape_string(::CartesianIndex) method.

Fixes #1207

The error printed the failing CartesianIndex coordinate instead of the
number of elements produced, so a one-short generator of length 5
reported "stopped at 5" even though only 4 values were produced.

Report LinearIndices(inds)[i]-1 as the count. Remove unused
shape_string(::CartesianIndex). Tests use occursin for Julia 1.6
compat.
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

Successfully merging this pull request may close these issues.

Bad error message: "Expected exactly 5 elements, but generator stopped at 5"

1 participant