@@ -251,7 +251,7 @@ def concat(arrays, axis=0, dtype=None):
251
251
arrays : tuple of LArray
252
252
Arrays to concatenate.
253
253
axis : axis reference (int, str or Axis), optional
254
- Axis along which to concatenate. Defaults to the first axis.
254
+ Axis along which to concatenate. All arrays must have that axis. Defaults to the first axis.
255
255
dtype : dtype, optional
256
256
Result data type. Defaults to the "closest" type which can hold all arrays types without loss of information.
257
257
@@ -384,7 +384,7 @@ def __setitem__(self, key, value):
384
384
# TODO: rename to LArrayIndexPointsIndexer or something like that
385
385
class LArrayPositionalPointsIndexer (object ):
386
386
"""
387
- the closer to numpy indexing we get, but not 100% the same.
387
+ the closest to numpy indexing we get, but not 100% the same.
388
388
"""
389
389
def __init__ (self , array ):
390
390
self .array = array
@@ -5485,15 +5485,15 @@ def divnot0(self, other):
5485
5485
# XXX: rename/change to "add_axes" ?
5486
5486
# TODO: add a flag copy=True to force a new array.
5487
5487
def expand (self , target_axes = None , out = None , readonly = False ):
5488
- """Expands array to target_axes.
5488
+ r """Expands array to target_axes.
5489
5489
5490
5490
Target axes will be added to array if not present.
5491
5491
In most cases this function is not needed because LArray can do operations with arrays having different
5492
5492
(compatible) axes.
5493
5493
5494
5494
Parameters
5495
5495
----------
5496
- target_axes : list of Axis or AxisCollection, optional
5496
+ target_axes : string, list of Axis or AxisCollection, optional
5497
5497
Self can contain axes not present in `target_axes`.
5498
5498
The result axes will be: [self.axes not in target_axes] + target_axes
5499
5499
out : LArray, optional
@@ -5513,22 +5513,37 @@ def expand(self, target_axes=None, out=None, readonly=False):
5513
5513
>>> b = Axis('b=b1,b2')
5514
5514
>>> arr = ndtest([a, b])
5515
5515
>>> arr
5516
- a\\ b b1 b2
5516
+ a\b b1 b2
5517
5517
a1 0 1
5518
5518
a2 2 3
5519
+
5520
+ Adding one or several axes will append the new axes at the end
5521
+
5519
5522
>>> c = Axis('c=c1,c2')
5523
+ >>> arr.expand(c)
5524
+ a b\c c1 c2
5525
+ a1 b1 0 0
5526
+ a1 b2 1 1
5527
+ a2 b1 2 2
5528
+ a2 b2 3 3
5529
+
5530
+ If you want to new axes to be inserted in a particular order, you have to give that order
5531
+
5520
5532
>>> arr.expand([a, c, b])
5521
- a c\\ b b1 b2
5533
+ a c\b b1 b2
5534
+ a1 c1 0 1
5535
+ a1 c2 0 1
5536
+ a2 c1 2 3
5537
+ a2 c2 2 3
5538
+
5539
+ But it is enough to list only the added axes and the axes after them:
5540
+
5541
+ >>> arr.expand([c, b])
5542
+ a c\b b1 b2
5522
5543
a1 c1 0 1
5523
5544
a1 c2 0 1
5524
5545
a2 c1 2 3
5525
5546
a2 c2 2 3
5526
- >>> arr.expand([b, c])
5527
- a b\\ c c1 c2
5528
- a1 b1 0 0
5529
- a1 b2 1 1
5530
- a2 b1 2 2
5531
- a2 b2 3 3
5532
5547
"""
5533
5548
if sum ([target_axes is not None , out is not None ]) != 1 :
5534
5549
raise ValueError ("exactly one of either `target_axes` or `out` must be defined (not both)" )
@@ -6767,8 +6782,8 @@ def shift(self, axis, n=1):
6767
6782
----------
6768
6783
axis : int, str or Axis
6769
6784
Axis for which we want to perform the shift.
6770
- n : int
6771
- Number of cells to shift.
6785
+ n : int, optional
6786
+ Number of cells to shift. Defaults to 1.
6772
6787
6773
6788
Returns
6774
6789
-------
@@ -8275,7 +8290,7 @@ def stack(elements=None, axis=None, title=None, meta=None, **kwargs):
8275
8290
Returns
8276
8291
-------
8277
8292
LArray
8278
- A single array combining arrays.
8293
+ A single array combining arrays. The new (stacked) axes will be the last axes of the new array.
8279
8294
8280
8295
Examples
8281
8296
--------
0 commit comments