Skip to content

Commit fc5f277

Browse files
committed
fix #477 : use raw docstrings (to avoid having to escape \)
1 parent 4a9c954 commit fc5f277

18 files changed

+515
-515
lines changed

larray/core/array.py

Lines changed: 334 additions & 334 deletions
Large diffs are not rendered by default.

larray/core/axis.py

Lines changed: 63 additions & 63 deletions
Large diffs are not rendered by default.

larray/core/group.py

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818

1919
def _slice_to_str(key, repr_func=str):
20-
"""
20+
r"""
2121
Converts a slice to a string
2222
2323
Examples
@@ -40,7 +40,7 @@ def _slice_to_str(key, repr_func=str):
4040

4141

4242
def irange(start, stop, step=None):
43-
"""Create a range, with inclusive stop bound and automatic sign for step.
43+
r"""Create a range, with inclusive stop bound and automatic sign for step.
4444
4545
Parameters
4646
----------
@@ -81,7 +81,7 @@ def irange(start, stop, step=None):
8181

8282

8383
def generalized_range(start, stop, step=1):
84-
"""Create a range, with inclusive stop bound and automatic sign for step. Bounds can be strings.
84+
r"""Create a range, with inclusive stop bound and automatic sign for step. Bounds can be strings.
8585
8686
Parameters
8787
----------
@@ -199,7 +199,7 @@ def generalized_range(start, stop, step=1):
199199

200200

201201
def _range_str_to_range(s, stack_depth=1):
202-
"""
202+
r"""
203203
Converts a range string to a range (of values).
204204
The end point is included.
205205
@@ -247,7 +247,7 @@ def _range_str_to_range(s, stack_depth=1):
247247

248248

249249
def _range_to_slice(seq, length=None):
250-
"""
250+
r"""
251251
Returns a slice if possible (including for sequences of 1 element) otherwise returns the input sequence itself
252252
253253
Parameters
@@ -331,7 +331,7 @@ def _seq_group_to_name(seq):
331331

332332

333333
def _to_tick(v):
334-
"""
334+
r"""
335335
Converts any value to a tick (ie makes it hashable, and acceptable as an ndarray element)
336336
337337
scalar -> not modified
@@ -374,7 +374,7 @@ def _to_tick(v):
374374

375375
# TODO: remove the conversion to list in doctests once Python 2 is dropped
376376
def _to_ticks(s, parse_single_int=False):
377-
"""
377+
r"""
378378
Makes a (list of) value(s) usable as the collection of labels for an Axis (ie hashable).
379379
380380
Strip strings, split them on ',' and translate "range strings" to list of values **including the end point** !
@@ -438,7 +438,7 @@ def _to_ticks(s, parse_single_int=False):
438438

439439

440440
def _seq_str_to_seq(s, stack_depth=1, parse_single_int=False):
441-
"""
441+
r"""
442442
Converts a sequence string to its sequence (or scalar)
443443
444444
Parameters
@@ -481,7 +481,7 @@ def to_seq(b, stack_depth=1):
481481

482482

483483
def _to_key(v, stack_depth=1, parse_single_int=False):
484-
"""
484+
r"""
485485
Converts a value to a key usable for indexing (slice object, list of values,...).
486486
Strings are split on ',' and stripped. Colons (:) are interpreted as slices.
487487
@@ -584,7 +584,7 @@ def _to_key(v, stack_depth=1, parse_single_int=False):
584584

585585

586586
def _to_keys(value, stack_depth=1):
587-
"""
587+
r"""
588588
Converts a (collection of) group(s) to a structure usable for indexing.
589589
590590
'label' or ['l1', 'l2'] or [['l1', 'l2'], ['l3']]
@@ -670,7 +670,7 @@ def _translate_group_key_hdf(key):
670670
# TODO: kill this function
671671
def union(*args):
672672
# TODO: add support for LGroup and lists
673-
"""
673+
r"""
674674
Returns the union of several "value strings" as a list.
675675
676676
Parameters
@@ -694,7 +694,7 @@ def union(*args):
694694

695695

696696
class IGroupMaker(object):
697-
"""
697+
r"""
698698
Generates a new instance of IGroup for a given axis and key.
699699
700700
Attributes
@@ -786,7 +786,7 @@ def __str__(self):
786786

787787
# TODO: rename to "to_positional"
788788
def translate(self, bound=None, stop=False):
789-
"""
789+
r"""
790790
Translate key to a position if it is not already
791791
792792
Parameters
@@ -801,7 +801,7 @@ def translate(self, bound=None, stop=False):
801801
raise NotImplementedError()
802802

803803
def eval(self):
804-
"""
804+
r"""
805805
Translate key to labels, if it is not already, expanding slices in the process.
806806
807807
Returns
@@ -811,7 +811,7 @@ def eval(self):
811811
raise NotImplementedError()
812812

813813
def to_label(self):
814-
"""
814+
r"""
815815
Translate key to labels, if it is not already
816816
817817
Returns
@@ -821,7 +821,7 @@ def to_label(self):
821821
raise NotImplementedError()
822822

823823
def retarget_to(self, target_axis):
824-
"""Retarget group to another axis.
824+
r"""Retarget group to another axis.
825825
826826
It will be translated to an LGroup using its former axis, if necessary.
827827
@@ -877,7 +877,7 @@ def __iter__(self):
877877
return iter([LGroup(v, axis=axis) for v in self.eval()])
878878

879879
def named(self, name):
880-
"""Returns group with a different name.
880+
r"""Returns group with a different name.
881881
882882
Parameters
883883
----------
@@ -892,7 +892,7 @@ def named(self, name):
892892
__rshift__ = named
893893

894894
def with_axis(self, axis):
895-
"""Returns group with a different axis.
895+
r"""Returns group with a different axis.
896896
897897
Parameters
898898
----------
@@ -906,7 +906,7 @@ def with_axis(self, axis):
906906
return self.__class__(self.key, self.name, axis)
907907

908908
def by(self, length, step=None, template=None):
909-
"""Split group into several groups of specified length.
909+
r"""Split group into several groups of specified length.
910910
911911
Parameters
912912
----------
@@ -964,7 +964,7 @@ def make_group(start, length, name_template):
964964
# IGroup.i[] => IGroup
965965
# LGroup.i[] => IGroup
966966
def __getitem__(self, key):
967-
"""
967+
r"""
968968
969969
Parameters
970970
----------
@@ -1083,7 +1083,7 @@ def opmethod(self, other):
10831083
__eq__ = _binop('eq')
10841084

10851085
def equals(self, other):
1086-
"""
1086+
r"""
10871087
Checks if this group is equal to another group.
10881088
Two groups are equal if they have the same group and axis names and correspond to the same labels.
10891089
@@ -1146,7 +1146,7 @@ def equals(self, other):
11461146
return res if isinstance(res, bool) else all(res)
11471147

11481148
def set(self):
1149-
"""Creates LSet from this group
1149+
r"""Creates LSet from this group
11501150
11511151
Returns
11521152
-------
@@ -1155,7 +1155,7 @@ def set(self):
11551155
return LSet(self.eval(), self.name, self.axis)
11561156

11571157
def union(self, other):
1158-
"""Returns (set) union of this label group and other.
1158+
r"""Returns (set) union of this label group and other.
11591159
11601160
Labels relative order will be kept intact, but only unique labels will be returned. Labels from this group will
11611161
be before labels from other.
@@ -1183,7 +1183,7 @@ def union(self, other):
11831183
return self.set().union(other)
11841184

11851185
def intersection(self, other):
1186-
"""Returns (set) intersection of this label group and other.
1186+
r"""Returns (set) intersection of this label group and other.
11871187
11881188
In other words, this will return labels from this group which are also in other. Labels relative order will be
11891189
kept intact, but only unique labels will be returned.
@@ -1211,7 +1211,7 @@ def intersection(self, other):
12111211
return self.set().intersection(other)
12121212

12131213
def difference(self, other):
1214-
"""Returns (set) difference of this label group and other.
1214+
r"""Returns (set) difference of this label group and other.
12151215
12161216
In other words, this will return labels from this group without those in other. Labels relative order will be
12171217
kept intact, but only unique labels will be returned.
@@ -1244,7 +1244,7 @@ def __contains__(self, item):
12441244
return item in self.eval()
12451245

12461246
def startingwith(self, prefix):
1247-
"""
1247+
r"""
12481248
Returns a group with the labels starting with the specified string.
12491249
12501250
Parameters
@@ -1272,7 +1272,7 @@ def startingwith(self, prefix):
12721272
return LGroup([v for v in self.eval() if v.startswith(prefix)], axis=self.axis)
12731273

12741274
def endingwith(self, suffix):
1275-
"""
1275+
r"""
12761276
Returns a group with the labels ending with the specified string.
12771277
12781278
Parameters
@@ -1300,7 +1300,7 @@ def endingwith(self, suffix):
13001300
return LGroup([v for v in self.eval() if v.endswith(suffix)], axis=self.axis)
13011301

13021302
def matching(self, deprecated=None, pattern=None, regex=None):
1303-
"""
1303+
r"""
13041304
Returns a group with all the labels matching the specified pattern or regular expression.
13051305
13061306
Parameters
@@ -1369,7 +1369,7 @@ def matching(self, deprecated=None, pattern=None, regex=None):
13691369
return LGroup([v for v in self.eval() if match(v)], axis=self.axis)
13701370

13711371
def containing(self, substring):
1372-
"""
1372+
r"""
13731373
Returns a group with all the labels containing the specified substring.
13741374
13751375
Parameters
@@ -1397,7 +1397,7 @@ def containing(self, substring):
13971397
return LGroup([v for v in self.eval() if substring in v], axis=self.axis)
13981398

13991399
def to_hdf(self, filepath, key=None, axis_key=None):
1400-
"""
1400+
r"""
14011401
Writes group to a HDF file.
14021402
14031403
A HDF file can contain multiple groups.
@@ -1542,7 +1542,7 @@ def remove_nested_groups(key):
15421542

15431543

15441544
class LGroup(Group):
1545-
"""Label group.
1545+
r"""Label group.
15461546
15471547
Represents a subset of labels of an axis.
15481548
@@ -1575,7 +1575,7 @@ def __init__(self, key, name=None, axis=None):
15751575

15761576
# XXX: return IGroup instead?
15771577
def translate(self, bound=None, stop=False):
1578-
"""
1578+
r"""
15791579
compute position(s) of group
15801580
"""
15811581
if bound is None:
@@ -1603,7 +1603,7 @@ def eval(self):
16031603

16041604

16051605
class LSet(LGroup):
1606-
"""Label set.
1606+
r"""Label set.
16071607
16081608
Represents a set of (unique) labels of an axis.
16091609
@@ -1675,7 +1675,7 @@ def opmethod(self, other):
16751675

16761676

16771677
class IGroup(Group):
1678-
"""Index Group.
1678+
r"""Index Group.
16791679
16801680
Represents a subset of indices of an axis.
16811681
@@ -1693,7 +1693,7 @@ class IGroup(Group):
16931693
format_string = "{axis}.i[{key}]"
16941694

16951695
def translate(self, bound=None, stop=False):
1696-
"""
1696+
r"""
16971697
compute position(s) of group
16981698
"""
16991699
if bound is not None:

larray/core/metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def __repr__(self):
109109

110110

111111
class Metadata(AttributeDict):
112-
"""
112+
r"""
113113
An ordered dictionary allowing key-values accessibly using attribute notation (AttributeDict.attribute)
114114
instead of key notation (Dict["key"]).
115115

0 commit comments

Comments
 (0)