I have a function that is called view
but does not provide a view on an array.
Unfortunately, the help on this function starts with the documentation of the build-in view
and only adds my docstring later. Since the general view
docstring is not relevant, I would like to disable it.
Example below (showing the full docstring, I only need the documentation below the separator line). Is there a way to disable re-using?
julia> import Damask
help?> Damask.view
view(A, inds...)
Like getindex, but returns a lightweight array that lazily references (or is effectively a
view into) the parent array A at the given index or indices inds instead of eagerly
extracting elements or constructing a copied subset. Calling getindex or setindex! on the
returned value (often a SubArray) computes the indices to access or modify the parent
array on the fly. The behavior is undefined if the shape of the parent array is changed
after view is called because there is no bound check for the parent array; e.g., it may
cause a segmentation fault.
Some immutable parent arrays (like ranges) may choose to simply recompute a new array in
some circumstances instead of returning a SubArray if doing so is efficient and provides
compatible semantics.
โ Julia 1.6
โ
โ In Julia 1.6 or later, view can be called on an AbstractString, returning a
โ SubString.
Examples
โกโกโกโกโกโกโกโกโกโก
julia> A = [1 2; 3 4]
2ร2 Matrix{Int64}:
1 2
3 4
julia> b = view(A, :, 1)
2-element view(::Matrix{Int64}, :, 1) with eltype Int64:
1
3
julia> fill!(b, 0)
2-element view(::Matrix{Int64}, :, 1) with eltype Int64:
0
0
julia> A # Note A has changed even though we modified b
2ร2 Matrix{Int64}:
0 2
0 4
julia> view(2:5, 2:3) # returns a range as type is immutable
3:4
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
view(obj::Result; <keyword arguments>)
Return a copy of obj with the selected view. True or "*" as keyword value selects all.
False or String[] as keyword value deselects all.
Arguments
โกโกโกโกโกโกโกโกโกโกโก
โข obj::HDF_Obj : HDF5_obj to create a view of
โข increments::Union{Int,Vector{Int},String,Vector{String},Bool,Nothing}=nothing :
Number(s) of increments to select. Negative Integers allowed eg. -1 for last
increment, -2 for second last. Defaults to all.
โข times::Union{<:AbstractFloat,Vector{<:AbstractFloat},String,Vector{String},Bool,Nothing}=nothing,
: Simulation time(s) of increments to select. Defaults to all. Mutually
exclusive to increments.
โข phases::Union{String,Vector{String},Bool,Nothing}=nothing, : Name(s) of phases
to select. Defaults to all.
โข homogenizations::Union{String,Vector{String},Bool,Nothing}=nothing,: Name(s) of
homogenizations to select. Defaults to all.
โข fields::Union{String,Vector{String},Bool,Nothing}=nothing, : Name(s) of fields
to select. Defaults to all.
โข protected::Union{Bool,Nothing}=nothing : Protection status of existing data.
Examples
โกโกโกโกโกโกโกโกโกโก
Create a view on the last increment
julia> using Damask
julia> res = read_HDF5("my_file.hdf5")
julia> v = view(res,increments = -1)