@@ -80,20 +80,29 @@ where
80
80
impl < A > Array < A , Ix2 > {
81
81
/// Append a row to an array
82
82
///
83
+ /// The elements from `row` are cloned and added as a new row in the array.
84
+ ///
83
85
/// ***Errors*** with a shape error if the length of the row does not match the length of the
84
- /// rows in the array. <br>
86
+ /// rows in the array.
85
87
///
86
88
/// The memory layout of the `self` array matters for ensuring that the append is efficient.
87
89
/// Appending automatically changes memory layout of the array so that it is appended to
88
- /// along the "growing axis".
90
+ /// along the "growing axis". However, if the memory layout needs adjusting, the array must
91
+ /// reallocate and move memory.
92
+ ///
93
+ /// The operation leaves the existing data in place and is most efficent if one of these is
94
+ /// true:
89
95
///
90
- /// Ensure appending is efficient by, for example, appending to an empty array and then
91
- /// always appending along the same axis. For rows, ndarray's default layout is efficient for
92
- /// appending.
96
+ /// - The axis being appended to is the longest stride axis, i.e the array is in row major
97
+ /// ("C") layout.
98
+ /// - The array has 0 or 1 rows (It is converted to row major)
93
99
///
94
- /// Notice that an empty array (where it has an axis of length zero) is the simplest starting
95
- /// point. When repeatedly appending to a single axis, the amortized average complexity of each append is O(m), where *m* is the length of
96
- /// the row.
100
+ /// Ensure appending is efficient by, for example, appending to an empty array and then always
101
+ /// pushing/appending along the same axis. For pushing rows, ndarray's default layout (C order)
102
+ /// is efficient.
103
+ ///
104
+ /// When repeatedly appending to a single axis, the amortized average complexity of each
105
+ /// append is O(m), where *m* is the length of the row.
97
106
///
98
107
/// ```rust
99
108
/// use ndarray::{Array, ArrayView, array};
@@ -117,20 +126,29 @@ impl<A> Array<A, Ix2> {
117
126
118
127
/// Append a column to an array
119
128
///
129
+ /// The elements from `column` are cloned and added as a new row in the array.
130
+ ///
120
131
/// ***Errors*** with a shape error if the length of the column does not match the length of
121
- /// the columns in the array.<br>
132
+ /// the columns in the array.
122
133
///
123
134
/// The memory layout of the `self` array matters for ensuring that the append is efficient.
124
135
/// Appending automatically changes memory layout of the array so that it is appended to
125
- /// along the "growing axis".
136
+ /// along the "growing axis". However, if the memory layout needs adjusting, the array must
137
+ /// reallocate and move memory.
126
138
///
127
- /// Ensure appending is efficient by, for example, appending to an empty array and then
128
- /// always appending along the same axis. For columns, column major ("F") memory layout is
129
- /// efficient for appending.
139
+ /// The operation leaves the existing data in place and is most efficent if one of these is
140
+ /// true:
130
141
///
131
- /// Notice that an empty array (where it has an axis of length zero) is the simplest starting
132
- /// point. When repeatedly appending to a single axis, the amortized average complexity of each append is O(m), where *m* is the length of
133
- /// the row.
142
+ /// - The axis being appended to is the longest stride axis, i.e the array is in column major
143
+ /// ("F") layout.
144
+ /// - The array has 0 or 1 columns (It is converted to column major)
145
+ ///
146
+ /// Ensure appending is efficient by, for example, appending to an empty array and then always
147
+ /// pushing/appending along the same axis. For pushing columns, column major layout (F order)
148
+ /// is efficient.
149
+ ///
150
+ /// When repeatedly appending to a single axis, the amortized average complexity of each append
151
+ /// is O(m), where *m* is the length of the column.
134
152
///
135
153
/// ```rust
136
154
/// use ndarray::{Array, ArrayView, array};
@@ -339,28 +357,30 @@ impl<A, D> Array<A, D>
339
357
}
340
358
}
341
359
342
- /// Append an array to the array along an axis
343
- ///
344
- /// Where the item to push to the array has one dimension less than the `self` array. This
345
- /// method is equivalent to `self.append(axis, array.insert_axis(axis))`.
360
+ /// Append an array to the array along an axis.
346
361
///
347
- /// The axis-to-append-to `axis` must be the array's "growing axis" for this operation
348
- /// to succeed. The growing axis is the outermost or last-visited when elements are visited in
349
- /// memory order:
362
+ /// The elements of `array` are cloned and extend the axis `axis` in the present array;
363
+ /// `self` will grow in size by 1 along `axis`.
350
364
///
351
- /// `axis` must be the growing axis of the current array, an axis with length 0 or 1.
352
- ///
353
- /// - This is the 0th axis for standard layout arrays
354
- /// - This is the *n*-1 th axis for fortran layout arrays
355
- /// - If the array is empty (the axis or any other has length 0) or if `axis`
356
- /// has length 1, then the array can always be appended.
365
+ /// Append to the array, where the array being pushed to the array has one dimension less than
366
+ /// the `self` array. This method is equivalent to [append](ArrayBase::append) in this way:
367
+ /// `self.append(axis, array.insert_axis(axis))`.
357
368
///
358
369
/// ***Errors*** with a shape error if the shape of self does not match the array-to-append;
359
- /// all axes *except* the axis along which it being appended matter for this check.
370
+ /// all axes *except* the axis along which it being appended matter for this check:
371
+ /// the shape of `self` with `axis` removed must be the same as the shape of `array`.
360
372
///
361
373
/// The memory layout of the `self` array matters for ensuring that the append is efficient.
362
374
/// Appending automatically changes memory layout of the array so that it is appended to
363
- /// along the "growing axis".
375
+ /// along the "growing axis". However, if the memory layout needs adjusting, the array must
376
+ /// reallocate and move memory.
377
+ ///
378
+ /// The operation leaves the existing data in place and is most efficent if `axis` is a
379
+ /// "growing axis" for the array, i.e. one of these is true:
380
+ ///
381
+ /// - The axis is the longest stride axis, for example the 0th axis in a C-layout or the
382
+ /// *n-1*th axis in an F-layout array.
383
+ /// - The axis has length 0 or 1 (It is converted to the new growing axis)
364
384
///
365
385
/// Ensure appending is efficient by for example starting from an empty array and/or always
366
386
/// appending to an array along the same axis.
@@ -398,25 +418,27 @@ impl<A, D> Array<A, D>
398
418
}
399
419
400
420
401
- /// Append an array to the array along an axis
402
- ///
403
- /// The axis-to-append-to `axis` must be the array's "growing axis" for this operation
404
- /// to succeed. The growing axis is the outermost or last-visited when elements are visited in
405
- /// memory order:
421
+ /// Append an array to the array along an axis.
406
422
///
407
- /// `axis` must be the growing axis of the current array, an axis with length 0 or 1.
408
- ///
409
- /// - This is the 0th axis for standard layout arrays
410
- /// - This is the *n*-1 th axis for fortran layout arrays
411
- /// - If the array is empty (the axis or any other has length 0) or if `axis`
412
- /// has length 1, then the array can always be appended.
423
+ /// The elements of `array` are cloned and extend the axis `axis` in the present array;
424
+ /// `self` will grow in size by `array.len_of(axis)` along `axis`.
413
425
///
414
426
/// ***Errors*** with a shape error if the shape of self does not match the array-to-append;
415
- /// all axes *except* the axis along which it being appended matter for this check.
427
+ /// all axes *except* the axis along which it being appended matter for this check:
428
+ /// the shape of `self` with `axis` removed must be the same as the shape of `array` with
429
+ /// `axis` removed.
416
430
///
417
431
/// The memory layout of the `self` array matters for ensuring that the append is efficient.
418
432
/// Appending automatically changes memory layout of the array so that it is appended to
419
- /// along the "growing axis".
433
+ /// along the "growing axis". However, if the memory layout needs adjusting, the array must
434
+ /// reallocate and move memory.
435
+ ///
436
+ /// The operation leaves the existing data in place and is most efficent if `axis` is a
437
+ /// "growing axis" for the array, i.e. one of these is true:
438
+ ///
439
+ /// - The axis is the longest stride axis, for example the 0th axis in a C-layout or the
440
+ /// *n-1*th axis in an F-layout array.
441
+ /// - The axis has length 0 or 1 (It is converted to the new growing axis)
420
442
///
421
443
/// Ensure appending is efficient by for example starting from an empty array and/or always
422
444
/// appending to an array along the same axis.
0 commit comments