ProtectedArrays
Documentation for ProtectedArrays.
julia> using ProtectedArrays
julia> a = zeros(2, 5)
2×5 Matrix{Float64}:
0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0
julia> pa = protect(a)
2×5 ProtectedMatrix(::Matrix{Float64}) with eltype Float64:
0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0
julia> pa[1] = 1.
ERROR: `ProtectedArray` does not allow modifying elements with `setindex!`,
use `unprotect` if you really know what you're doing.
[...]
julia> pa[1, 1] = 1.
ERROR: `ProtectedArray` does not allow modifying elements with `setindex!`,
use `unprotect` if you really know what you're doing.
[...]
julia> pa[:, 1] .= 1.
ERROR: `ProtectedArray` does not allow modifying elements with `setindex!`,
use `unprotect` if you really know what you're doing.
[...]
julia> fill!(pa, 1.)
ERROR: `ProtectedArray` does not allow modifying elements with `setindex!`,
use `unprotect` if you really know what you're doing.
[...]
julia> a # unmodified
2×5 Matrix{Float64}:
0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0API
ProtectedArrays.ProtectedArrayProtectedArrays.ProtectedMatrixProtectedArrays.ProtectedVectorBase.similarProtectedArrays.protectProtectedArrays.unprotect
ProtectedArrays.ProtectedArray — TypeProtectedArray(array)Wrapper around an array which disables setindex! to prevent modifications.
ProtectedArrays.ProtectedMatrix — TypeProtectedMatrix(matrix)Type alias and convenience constructor for two-dimensional ProtectedArrays.
ProtectedArrays.ProtectedVector — TypeProtectedVector(vector)Type alias and convenience constructor for one-dimensional ProtectedArrays.
Base.similar — Methodsimilar(pa::ProtectedArray, eltype=eltype(pa), dims=size(pa))Create an uninitialized mutable array based on the underlying array parent(pa) wrapped by ProtectedArray.
ProtectedArrays.protect — Functionprotect(array::AbstractArray)Wrap an array into a ProtectedArray to prevent modifications.
See also unprotect.
ProtectedArrays.unprotect — Functionunprotect(::ProtectedArray)Unwrap a ProtectedArray into the underlying array.
This is a synonym of parent.
See also protect.