Skip to content

Commit 4cb49e1

Browse files
committed
Add docstrings
1 parent d22face commit 4cb49e1

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/varnamedtuple.jl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,19 @@ const PARTIAL_ARRAY_DIM_GROWTH_FACTOR = 4
7676
"""A convenience for defining method argument type bounds."""
7777
const INDEX_TYPES = Union{Integer,UnitRange,Colon}
7878

79+
"""
80+
ArrayLikeBlock{T,I}
81+
82+
A wrapper for non-array blocks stored in `PartialArray`s.
83+
84+
When setting a value in a `PartialArray` over a range of indices, if the value being set
85+
is not itself an `AbstractArray`, but has a well-defined size, we wrap it in an
86+
`ArrayLikeBlock`, which records both the value and the indices it was set with.
87+
88+
When getting values from a `PartialArray`, if any of the requested indices correspond to
89+
an `ArrayLikeBlock`, we check that the requested indices match the ones used to set the
90+
value. If they do, we return the underlying block, otherwise we throw an error.
91+
"""
7992
struct ArrayLikeBlock{T,I}
8093
block::T
8194
inds::I
@@ -136,6 +149,14 @@ Like `Base.Array`s, `PartialArray`s have a well-defined, compile-time-known elem
136149
`ElType` and number of dimensions `numdims`. Indices into a `PartialArray` must have exactly
137150
`numdims` elements.
138151
152+
One can set values in a `PartialArray` either element-by-element, or with ranges like
153+
`arr[1:3,2] = [5,10,15]`. When setting values over a range of indices, the value being set
154+
must either be an `AbstractArray` or otherwise something for which `size(value)` is defined,
155+
and the size mathces the range. If the value is an `AbstractArray`, the elements are copied
156+
individually, but if it is not, the value is stored as a block, that takes up the whole
157+
range, e.g. `[1:3,2]`, but is only a single object. Getting such a block-value must be done
158+
with the exact same range of indices, otherwise an error is thrown.
159+
139160
If the element type of a `PartialArray` is not concrete, any call to `setindex!!` will check
140161
if, after the new value has been set, the element type can be made more concrete. If so,
141162
a new `PartialArray` with a more concrete element type is returned. Thus the element type

0 commit comments

Comments
 (0)