Skip to content

Commit

Permalink
Warn about incorrect behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
moble committed Dec 2, 2024
1 parent 1732ba4 commit bc57218
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/iterators.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
const iterator_warning = """Inconsistent behavior relative to documentation.
This iterator mistakenly returns the transpose of the result implied by the documentation.
To avoid breaking code that relies on this behavior, this is a final release in this major
version of the package. On the other hand, to avoid silent bugs, this version is being
released with this warning. The next major version of the package will likely provide the
expected behavior, though with inefficient performance; and the major version after that
will likely provide the expected behavior with efficient performance.
"""


"""
D_iterator(D, ℓₘₐₓ, [ℓₘᵢₙ])
Construct an Iterator that returns sub-matrices of `D`, each of which consists
of elements ``(ℓ,-ℓ,-ℓ)`` through ``(ℓ,ℓ,ℓ)``, for ``ℓ`` from `ℓₘᵢₙ` through
`ℓₘₐₓ`. By default, `ℓₘᵢₙ` is 0.
!!! danger "Incorrect behavior"
This iterator mistakenly returns the transpose of the result implied by the
documentation. To avoid breaking code that relies on this behavior, this is a final
release in this major version of the package. On the other hand, to avoid silent bugs,
this version is being released with this warning. The next major version of the package
will likely provide the expected behavior, though with inefficient performance; and the
major version after that will likely provide the expected behavior with efficient
performance.
Note that the returned objects are *views* into the original `D` data — meaning
that you may alter their values.
Expand All @@ -31,6 +51,7 @@ struct D_iterator{VT<:Vector}
ℓₘᵢₙ::Int
function D_iterator{VT}(D, ℓₘₐₓ, ℓₘᵢₙ=0) where VT
#@assert ℓₘₐₓ ≥ ℓₘᵢₙ ≥ 0
@warn iterator_warning
new{VT}(D, ℓₘₐₓ, ℓₘᵢₙ)
end
end
Expand Down Expand Up @@ -66,6 +87,15 @@ Construct an Iterator that returns sub-matrices of `d`, each of which consists
of elements ``(ℓ,-ℓ,-ℓ)`` through ``(ℓ,ℓ,ℓ)``, for ``ℓ`` from `ℓₘᵢₙ` through
`ℓₘₐₓ`. By default, `ℓₘᵢₙ` is 0.
!!! danger "Incorrect behavior"
This iterator mistakenly returns the transpose of the result implied by the
documentation. To avoid breaking code that relies on this behavior, this is a final
release in this major version of the package. On the other hand, to avoid silent bugs,
this version is being released with this warning. The next major version of the package
will likely provide the expected behavior, though with inefficient performance; and the
major version after that will likely provide the expected behavior with efficient
performance.
Note that the returned objects are *views* into the original `d` data — meaning
that you may alter their values.
Expand All @@ -92,6 +122,7 @@ struct d_iterator{VT<:Vector}
ℓₘᵢₙ::Int
function d_iterator{VT}(d, ℓₘₐₓ, ℓₘᵢₙ=0) where VT
#@assert ℓₘₐₓ ≥ ℓₘᵢₙ ≥ 0
@warn iterator_warning
new{VT}(d, ℓₘₐₓ, ℓₘᵢₙ)
end
end
Expand Down

0 comments on commit bc57218

Please sign in to comment.