Skip to content

Commit

Permalink
Interpolate keyword args into multiple docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
emstoudenmire committed Aug 4, 2023
1 parent 2d48586 commit a13b205
Showing 1 changed file with 17 additions and 32 deletions.
49 changes: 17 additions & 32 deletions src/itensor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1406,17 +1406,23 @@ for find in (:commonind, :noncommonind, :uniqueind, :unionind)
end
end

function index_filter_kwargs_docstring()
return """
Optional keyword arguments:
* tags::String - a tag name or comma separated list of tag names that the returned indices must all have
* plev::Int - common prime level that the returned indices must all have
* inds - Index or collection of indices. Returned indices must come from this set of indices.
"""
end

# intersect
@doc """
commoninds(A, B; kwargs...)
Return a Vector with indices that are common between the indices of `A` and `B`
(the set intersection, similar to `Base.intersect`).
Optional keyword arguments:
* tags::String - a tag name or comma separated list of tag names that the returned indices must all have
* plev::Int - common prime level that the returned indices must all have
* inds - Index or collection of indices. Returned indices must come from this set of indices.
$(index_filter_kwargs_docstring())
""" commoninds

# firstintersect
Expand All @@ -1427,10 +1433,7 @@ Return the first `Index` common between the indices of `A` and `B`.
See also [`commoninds`](@ref).
Optional keyword arguments:
* tags::String - a tag name or comma separated list of tag names that the returned indices must all have
* plev::Int - common prime level that the returned indices must all have
* inds - Index or collection of indices. Returned indices must come from this set of indices.
$(index_filter_kwargs_docstring())
""" commonind

# symdiff
Expand All @@ -1440,10 +1443,7 @@ Optional keyword arguments:
Return a Vector with indices that are not common between the indices of `A` and
`B` (the symmetric set difference, similar to `Base.symdiff`).
Optional keyword arguments:
* tags::String - a tag name or comma separated list of tag names that the returned indices must all have
* plev::Int - common prime level that the returned indices must all have
* inds - Index or collection of indices. Returned indices must come from this set of indices.
$(index_filter_kwargs_docstring())
""" noncommoninds

# firstsymdiff
Expand All @@ -1454,10 +1454,7 @@ Return the first `Index` not common between the indices of `A` and `B`.
See also [`noncommoninds`](@ref).
Optional keyword arguments:
* tags::String - a tag name or comma separated list of tag names that the returned indices must all have
* plev::Int - common prime level that the returned indices must all have
* inds - Index or collection of indices. Returned indices must come from this set of indices.
$(index_filter_kwargs_docstring())
""" noncommonind

# setdiff
Expand All @@ -1467,10 +1464,7 @@ Optional keyword arguments:
Return Vector with indices that are unique to the set of indices of `A` and not
in `B` (the set difference, similar to `Base.setdiff`).
Optional keyword arguments:
* tags::String - a tag name or comma separated list of tag names that the returned indices must all have
* plev::Int - common prime level that the returned indices must all have
* inds - Index or collection of indices. Returned indices must come from this set of indices.
$(index_filter_kwargs_docstring())
""" uniqueinds

# firstsetdiff
Expand All @@ -1481,10 +1475,7 @@ Return the first `Index` unique to the set of indices of `A` and not in `B`.
See also [`uniqueinds`](@ref).
Optional keyword arguments:
* tags::String - a tag name or comma separated list of tag names that the returned indices must all have
* plev::Int - common prime level that the returned indices must all have
* inds - Index or collection of indices. Returned indices must come from this set of indices.
$(index_filter_kwargs_docstring())
""" uniqueind

# union
Expand All @@ -1494,10 +1485,7 @@ Optional keyword arguments:
Return a Vector with indices that are the union of the indices of `A` and `B`
(the set union, similar to `Base.union`).
Optional keyword arguments:
* tags::String - a tag name or comma separated list of tag names that the returned indices must all have
* plev::Int - common prime level that the returned indices must all have
* inds - Index or collection of indices. Returned indices must come from this set of indices.
$(index_filter_kwargs_docstring())
""" unioninds

# firstunion
Expand All @@ -1508,10 +1496,7 @@ Return the first `Index` in the union of the indices of `A` and `B`.
See also [`unioninds`](@ref).
Optional keyword arguments:
* tags::String - a tag name or comma separated list of tag names that the returned indices must all have
* plev::Int - common prime level that the returned indices must all have
* inds - Index or collection of indices. Returned indices must come from this set of indices.
$(index_filter_kwargs_docstring())
""" unionind

firstind(A...; kwargs...) = getfirst(map_itensor2inds(A)...; kwargs...)
Expand Down

0 comments on commit a13b205

Please sign in to comment.