17
17
18
18
19
19
def _slice_to_str (key , repr_func = str ):
20
- """
20
+ r """
21
21
Converts a slice to a string
22
22
23
23
Examples
@@ -41,7 +41,7 @@ def _slice_to_str(key, repr_func=str):
41
41
42
42
43
43
def irange (start , stop , step = None ):
44
- """Create a range, with inclusive stop bound and automatic sign for step.
44
+ r """Create a range, with inclusive stop bound and automatic sign for step.
45
45
46
46
Parameters
47
47
----------
@@ -82,7 +82,7 @@ def irange(start, stop, step=None):
82
82
83
83
84
84
def generalized_range (start , stop , step = 1 ):
85
- """Create a range, with inclusive stop bound and automatic sign for step. Bounds can be strings.
85
+ r """Create a range, with inclusive stop bound and automatic sign for step. Bounds can be strings.
86
86
87
87
Parameters
88
88
----------
@@ -200,7 +200,7 @@ def generalized_range(start, stop, step=1):
200
200
201
201
202
202
def _range_str_to_range (s , stack_depth = 1 ):
203
- """
203
+ r """
204
204
Converts a range string to a range (of values).
205
205
The end point is included.
206
206
@@ -248,7 +248,7 @@ def _range_str_to_range(s, stack_depth=1):
248
248
249
249
250
250
def _range_to_slice (seq , length = None ):
251
- """
251
+ r """
252
252
Returns a slice if possible (including for sequences of 1 element) otherwise returns the input sequence itself
253
253
254
254
Parameters
@@ -332,7 +332,7 @@ def _seq_group_to_name(seq):
332
332
333
333
334
334
def _to_tick (v ):
335
- """
335
+ r """
336
336
Converts any value to a tick (ie makes it hashable, and acceptable as an ndarray element)
337
337
338
338
scalar -> not modified
@@ -375,7 +375,7 @@ def _to_tick(v):
375
375
376
376
# TODO: remove the conversion to list in doctests once Python 2 is dropped
377
377
def _to_ticks (s , parse_single_int = False ):
378
- """
378
+ r """
379
379
Makes a (list of) value(s) usable as the collection of labels for an Axis (ie hashable).
380
380
381
381
Strip strings, split them on ',' and translate "range strings" to list of values **including the end point** !
@@ -439,7 +439,7 @@ def _to_ticks(s, parse_single_int=False):
439
439
440
440
441
441
def _seq_str_to_seq (s , stack_depth = 1 , parse_single_int = False ):
442
- """
442
+ r """
443
443
Converts a sequence string to its sequence (or scalar)
444
444
445
445
Parameters
@@ -482,7 +482,7 @@ def to_seq(b, stack_depth=1):
482
482
483
483
484
484
def _to_key (v , stack_depth = 1 , parse_single_int = False ):
485
- """
485
+ r """
486
486
Converts a value to a key usable for indexing (slice object, list of values,...).
487
487
Strings are split on ',' and stripped. Colons (:) are interpreted as slices.
488
488
@@ -585,7 +585,7 @@ def _to_key(v, stack_depth=1, parse_single_int=False):
585
585
586
586
587
587
def _to_keys (value , stack_depth = 1 ):
588
- """
588
+ r """
589
589
Converts a (collection of) group(s) to a structure usable for indexing.
590
590
591
591
'label' or ['l1', 'l2'] or [['l1', 'l2'], ['l3']]
@@ -670,7 +670,7 @@ def _translate_group_key_hdf(key):
670
670
671
671
def union (* args ):
672
672
# TODO: add support for LGroup and lists
673
- """
673
+ r """
674
674
Returns the union of several "value strings" as a list.
675
675
676
676
Parameters
@@ -694,7 +694,7 @@ def union(*args):
694
694
695
695
696
696
class IGroupMaker (object ):
697
- """
697
+ r """
698
698
Generates a new instance of IGroup for a given axis and key.
699
699
700
700
Attributes
@@ -717,8 +717,7 @@ def __getitem__(self, key):
717
717
# We need a separate class for LGroup and cannot simply create a new Axis with a subset of values/ticks/labels:
718
718
# the subset of ticks/labels of the LGroup need to correspond to its *Axis* indices
719
719
class Group (object ):
720
- """Abstract Group.
721
- """
720
+ r"""Abstract Group. """
722
721
format_string = None
723
722
724
723
def __init__ (self , key , name = None , axis = None ):
@@ -777,7 +776,7 @@ def __str__(self):
777
776
778
777
# TODO: rename to "to_positional"
779
778
def translate (self , bound = None , stop = False ):
780
- """
779
+ r """
781
780
Translate key to a position if it is not already
782
781
783
782
Parameters
@@ -792,7 +791,7 @@ def translate(self, bound=None, stop=False):
792
791
raise NotImplementedError ()
793
792
794
793
def eval (self ):
795
- """
794
+ r """
796
795
Translate key to labels, if it is not already, expanding slices in the process.
797
796
798
797
Returns
@@ -802,7 +801,7 @@ def eval(self):
802
801
raise NotImplementedError ()
803
802
804
803
def to_label (self ):
805
- """
804
+ r """
806
805
Translate key to labels, if it is not already
807
806
808
807
Returns
@@ -812,7 +811,7 @@ def to_label(self):
812
811
raise NotImplementedError ()
813
812
814
813
def retarget_to (self , target_axis ):
815
- """Retarget group to another axis.
814
+ r """Retarget group to another axis.
816
815
817
816
It will be translated to an LGroup using its former axis, if necessary.
818
817
@@ -867,7 +866,7 @@ def __iter__(self):
867
866
return iter ([LGroup (v , axis = self .axis ) for v in self .eval ()])
868
867
869
868
def named (self , name ):
870
- """Returns group with a different name.
869
+ r """Returns group with a different name.
871
870
872
871
Parameters
873
872
----------
@@ -882,7 +881,7 @@ def named(self, name):
882
881
__rshift__ = named
883
882
884
883
def with_axis (self , axis ):
885
- """Returns group with a different axis.
884
+ r """Returns group with a different axis.
886
885
887
886
Parameters
888
887
----------
@@ -896,7 +895,7 @@ def with_axis(self, axis):
896
895
return self .__class__ (self .key , self .name , axis )
897
896
898
897
def by (self , length , step = None , template = None ):
899
- """Split group into several groups of specified length.
898
+ r """Split group into several groups of specified length.
900
899
901
900
Parameters
902
901
----------
@@ -954,7 +953,7 @@ def make_group(start, length, name_template):
954
953
# IGroup.i[] => IGroup
955
954
# LGroup.i[] => IGroup
956
955
def __getitem__ (self , key ):
957
- """
956
+ r """
958
957
959
958
Parameters
960
959
----------
@@ -1073,7 +1072,7 @@ def opmethod(self, other):
1073
1072
__eq__ = _binop ('eq' )
1074
1073
1075
1074
def equals (self , other ):
1076
- """
1075
+ r """
1077
1076
Checks if this group is equal to another group.
1078
1077
Two groups are equal if they have the same group and axis names and correspond to the same labels.
1079
1078
@@ -1136,7 +1135,7 @@ def equals(self, other):
1136
1135
return res if isinstance (res , bool ) else all (res )
1137
1136
1138
1137
def set (self ):
1139
- """Creates LSet from this group
1138
+ r """Creates LSet from this group
1140
1139
1141
1140
Returns
1142
1141
-------
@@ -1145,7 +1144,7 @@ def set(self):
1145
1144
return LSet (self .eval (), self .name , self .axis )
1146
1145
1147
1146
def union (self , other ):
1148
- """Returns (set) union of this label group and other.
1147
+ r """Returns (set) union of this label group and other.
1149
1148
1150
1149
Labels relative order will be kept intact, but only unique labels will be returned. Labels from this group will
1151
1150
be before labels from other.
@@ -1173,7 +1172,7 @@ def union(self, other):
1173
1172
return self .set ().union (other )
1174
1173
1175
1174
def intersection (self , other ):
1176
- """Returns (set) intersection of this label group and other.
1175
+ r """Returns (set) intersection of this label group and other.
1177
1176
1178
1177
In other words, this will return labels from this group which are also in other. Labels relative order will be
1179
1178
kept intact, but only unique labels will be returned.
@@ -1201,7 +1200,7 @@ def intersection(self, other):
1201
1200
return self .set ().intersection (other )
1202
1201
1203
1202
def difference (self , other ):
1204
- """Returns (set) difference of this label group and other.
1203
+ r """Returns (set) difference of this label group and other.
1205
1204
1206
1205
In other words, this will return labels from this group without those in other. Labels relative order will be
1207
1206
kept intact, but only unique labels will be returned.
@@ -1234,7 +1233,7 @@ def __contains__(self, item):
1234
1233
return item in self .eval ()
1235
1234
1236
1235
def startingwith (self , prefix ):
1237
- """
1236
+ r """
1238
1237
Returns a group with the labels starting with the specified string.
1239
1238
1240
1239
Parameters
@@ -1262,7 +1261,7 @@ def startingwith(self, prefix):
1262
1261
return LGroup ([v for v in self .eval () if v .startswith (prefix )], axis = self .axis )
1263
1262
1264
1263
def endingwith (self , suffix ):
1265
- """
1264
+ r """
1266
1265
Returns a group with the labels ending with the specified string.
1267
1266
1268
1267
Parameters
@@ -1290,7 +1289,7 @@ def endingwith(self, suffix):
1290
1289
return LGroup ([v for v in self .eval () if v .endswith (suffix )], axis = self .axis )
1291
1290
1292
1291
def matching (self , deprecated = None , pattern = None , regex = None ):
1293
- """
1292
+ r """
1294
1293
Returns a group with all the labels matching the specified pattern or regular expression.
1295
1294
1296
1295
Parameters
@@ -1359,7 +1358,7 @@ def matching(self, deprecated=None, pattern=None, regex=None):
1359
1358
return LGroup ([v for v in self .eval () if match (v )], axis = self .axis )
1360
1359
1361
1360
def containing (self , substring ):
1362
- """
1361
+ r """
1363
1362
Returns a group with all the labels containing the specified substring.
1364
1363
1365
1364
Parameters
@@ -1387,7 +1386,7 @@ def containing(self, substring):
1387
1386
return LGroup ([v for v in self .eval () if substring in v ], axis = self .axis )
1388
1387
1389
1388
def to_hdf (self , filepath , key = None , axis_key = None ):
1390
- """
1389
+ r """
1391
1390
Writes group to a HDF file.
1392
1391
1393
1392
A HDF file can contain multiple groups.
@@ -1526,7 +1525,7 @@ def remove_nested_groups(key):
1526
1525
1527
1526
1528
1527
class LGroup (Group ):
1529
- """Label group.
1528
+ r """Label group.
1530
1529
1531
1530
Represents a subset of labels of an axis.
1532
1531
@@ -1558,7 +1557,7 @@ def __init__(self, key, name=None, axis=None):
1558
1557
1559
1558
# XXX: return IGroup instead?
1560
1559
def translate (self , bound = None , stop = False ):
1561
- """
1560
+ r """
1562
1561
compute position(s) of group
1563
1562
"""
1564
1563
if bound is None :
@@ -1586,7 +1585,7 @@ def eval(self):
1586
1585
1587
1586
1588
1587
class LSet (LGroup ):
1589
- """Label set.
1588
+ r """Label set.
1590
1589
1591
1590
Represents a set of (unique) labels of an axis.
1592
1591
@@ -1657,7 +1656,7 @@ def opmethod(self, other):
1657
1656
1658
1657
1659
1658
class IGroup (Group ):
1660
- """Index Group.
1659
+ r """Index Group.
1661
1660
1662
1661
Represents a subset of indices of an axis.
1663
1662
@@ -1674,7 +1673,7 @@ class IGroup(Group):
1674
1673
format_string = "{axis}.i[{key}]"
1675
1674
1676
1675
def translate (self , bound = None , stop = False ):
1677
- """
1676
+ r """
1678
1677
compute position(s) of group
1679
1678
"""
1680
1679
if bound is not None :
0 commit comments