Skip to content

Commit abef5c8

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

File tree

18 files changed

+537
-538
lines changed

18 files changed

+537
-538
lines changed

larray/core/array.py

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

larray/core/axis.py

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

larray/core/group.py

Lines changed: 36 additions & 37 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
@@ -41,7 +41,7 @@ def _slice_to_str(key, repr_func=str):
4141

4242

4343
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.
4545
4646
Parameters
4747
----------
@@ -82,7 +82,7 @@ def irange(start, stop, step=None):
8282

8383

8484
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.
8686
8787
Parameters
8888
----------
@@ -200,7 +200,7 @@ def generalized_range(start, stop, step=1):
200200

201201

202202
def _range_str_to_range(s, stack_depth=1):
203-
"""
203+
r"""
204204
Converts a range string to a range (of values).
205205
The end point is included.
206206
@@ -248,7 +248,7 @@ def _range_str_to_range(s, stack_depth=1):
248248

249249

250250
def _range_to_slice(seq, length=None):
251-
"""
251+
r"""
252252
Returns a slice if possible (including for sequences of 1 element) otherwise returns the input sequence itself
253253
254254
Parameters
@@ -332,7 +332,7 @@ def _seq_group_to_name(seq):
332332

333333

334334
def _to_tick(v):
335-
"""
335+
r"""
336336
Converts any value to a tick (ie makes it hashable, and acceptable as an ndarray element)
337337
338338
scalar -> not modified
@@ -375,7 +375,7 @@ def _to_tick(v):
375375

376376
# TODO: remove the conversion to list in doctests once Python 2 is dropped
377377
def _to_ticks(s, parse_single_int=False):
378-
"""
378+
r"""
379379
Makes a (list of) value(s) usable as the collection of labels for an Axis (ie hashable).
380380
381381
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):
439439

440440

441441
def _seq_str_to_seq(s, stack_depth=1, parse_single_int=False):
442-
"""
442+
r"""
443443
Converts a sequence string to its sequence (or scalar)
444444
445445
Parameters
@@ -482,7 +482,7 @@ def to_seq(b, stack_depth=1):
482482

483483

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

586586

587587
def _to_keys(value, stack_depth=1):
588-
"""
588+
r"""
589589
Converts a (collection of) group(s) to a structure usable for indexing.
590590
591591
'label' or ['l1', 'l2'] or [['l1', 'l2'], ['l3']]
@@ -670,7 +670,7 @@ def _translate_group_key_hdf(key):
670670

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
@@ -717,8 +717,7 @@ def __getitem__(self, key):
717717
# We need a separate class for LGroup and cannot simply create a new Axis with a subset of values/ticks/labels:
718718
# the subset of ticks/labels of the LGroup need to correspond to its *Axis* indices
719719
class Group(object):
720-
"""Abstract Group.
721-
"""
720+
r"""Abstract Group. """
722721
format_string = None
723722

724723
def __init__(self, key, name=None, axis=None):
@@ -777,7 +776,7 @@ def __str__(self):
777776

778777
# TODO: rename to "to_positional"
779778
def translate(self, bound=None, stop=False):
780-
"""
779+
r"""
781780
Translate key to a position if it is not already
782781
783782
Parameters
@@ -792,7 +791,7 @@ def translate(self, bound=None, stop=False):
792791
raise NotImplementedError()
793792

794793
def eval(self):
795-
"""
794+
r"""
796795
Translate key to labels, if it is not already, expanding slices in the process.
797796
798797
Returns
@@ -802,7 +801,7 @@ def eval(self):
802801
raise NotImplementedError()
803802

804803
def to_label(self):
805-
"""
804+
r"""
806805
Translate key to labels, if it is not already
807806
808807
Returns
@@ -812,7 +811,7 @@ def to_label(self):
812811
raise NotImplementedError()
813812

814813
def retarget_to(self, target_axis):
815-
"""Retarget group to another axis.
814+
r"""Retarget group to another axis.
816815
817816
It will be translated to an LGroup using its former axis, if necessary.
818817
@@ -867,7 +866,7 @@ def __iter__(self):
867866
return iter([LGroup(v, axis=self.axis) for v in self.eval()])
868867

869868
def named(self, name):
870-
"""Returns group with a different name.
869+
r"""Returns group with a different name.
871870
872871
Parameters
873872
----------
@@ -882,7 +881,7 @@ def named(self, name):
882881
__rshift__ = named
883882

884883
def with_axis(self, axis):
885-
"""Returns group with a different axis.
884+
r"""Returns group with a different axis.
886885
887886
Parameters
888887
----------
@@ -896,7 +895,7 @@ def with_axis(self, axis):
896895
return self.__class__(self.key, self.name, axis)
897896

898897
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.
900899
901900
Parameters
902901
----------
@@ -954,7 +953,7 @@ def make_group(start, length, name_template):
954953
# IGroup.i[] => IGroup
955954
# LGroup.i[] => IGroup
956955
def __getitem__(self, key):
957-
"""
956+
r"""
958957
959958
Parameters
960959
----------
@@ -1073,7 +1072,7 @@ def opmethod(self, other):
10731072
__eq__ = _binop('eq')
10741073

10751074
def equals(self, other):
1076-
"""
1075+
r"""
10771076
Checks if this group is equal to another group.
10781077
Two groups are equal if they have the same group and axis names and correspond to the same labels.
10791078
@@ -1136,7 +1135,7 @@ def equals(self, other):
11361135
return res if isinstance(res, bool) else all(res)
11371136

11381137
def set(self):
1139-
"""Creates LSet from this group
1138+
r"""Creates LSet from this group
11401139
11411140
Returns
11421141
-------
@@ -1145,7 +1144,7 @@ def set(self):
11451144
return LSet(self.eval(), self.name, self.axis)
11461145

11471146
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.
11491148
11501149
Labels relative order will be kept intact, but only unique labels will be returned. Labels from this group will
11511150
be before labels from other.
@@ -1173,7 +1172,7 @@ def union(self, other):
11731172
return self.set().union(other)
11741173

11751174
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.
11771176
11781177
In other words, this will return labels from this group which are also in other. Labels relative order will be
11791178
kept intact, but only unique labels will be returned.
@@ -1201,7 +1200,7 @@ def intersection(self, other):
12011200
return self.set().intersection(other)
12021201

12031202
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.
12051204
12061205
In other words, this will return labels from this group without those in other. Labels relative order will be
12071206
kept intact, but only unique labels will be returned.
@@ -1234,7 +1233,7 @@ def __contains__(self, item):
12341233
return item in self.eval()
12351234

12361235
def startingwith(self, prefix):
1237-
"""
1236+
r"""
12381237
Returns a group with the labels starting with the specified string.
12391238
12401239
Parameters
@@ -1262,7 +1261,7 @@ def startingwith(self, prefix):
12621261
return LGroup([v for v in self.eval() if v.startswith(prefix)], axis=self.axis)
12631262

12641263
def endingwith(self, suffix):
1265-
"""
1264+
r"""
12661265
Returns a group with the labels ending with the specified string.
12671266
12681267
Parameters
@@ -1290,7 +1289,7 @@ def endingwith(self, suffix):
12901289
return LGroup([v for v in self.eval() if v.endswith(suffix)], axis=self.axis)
12911290

12921291
def matching(self, deprecated=None, pattern=None, regex=None):
1293-
"""
1292+
r"""
12941293
Returns a group with all the labels matching the specified pattern or regular expression.
12951294
12961295
Parameters
@@ -1359,7 +1358,7 @@ def matching(self, deprecated=None, pattern=None, regex=None):
13591358
return LGroup([v for v in self.eval() if match(v)], axis=self.axis)
13601359

13611360
def containing(self, substring):
1362-
"""
1361+
r"""
13631362
Returns a group with all the labels containing the specified substring.
13641363
13651364
Parameters
@@ -1387,7 +1386,7 @@ def containing(self, substring):
13871386
return LGroup([v for v in self.eval() if substring in v], axis=self.axis)
13881387

13891388
def to_hdf(self, filepath, key=None, axis_key=None):
1390-
"""
1389+
r"""
13911390
Writes group to a HDF file.
13921391
13931392
A HDF file can contain multiple groups.
@@ -1526,7 +1525,7 @@ def remove_nested_groups(key):
15261525

15271526

15281527
class LGroup(Group):
1529-
"""Label group.
1528+
r"""Label group.
15301529
15311530
Represents a subset of labels of an axis.
15321531
@@ -1558,7 +1557,7 @@ def __init__(self, key, name=None, axis=None):
15581557

15591558
# XXX: return IGroup instead?
15601559
def translate(self, bound=None, stop=False):
1561-
"""
1560+
r"""
15621561
compute position(s) of group
15631562
"""
15641563
if bound is None:
@@ -1586,7 +1585,7 @@ def eval(self):
15861585

15871586

15881587
class LSet(LGroup):
1589-
"""Label set.
1588+
r"""Label set.
15901589
15911590
Represents a set of (unique) labels of an axis.
15921591
@@ -1657,7 +1656,7 @@ def opmethod(self, other):
16571656

16581657

16591658
class IGroup(Group):
1660-
"""Index Group.
1659+
r"""Index Group.
16611660
16621661
Represents a subset of indices of an axis.
16631662
@@ -1674,7 +1673,7 @@ class IGroup(Group):
16741673
format_string = "{axis}.i[{key}]"
16751674

16761675
def translate(self, bound=None, stop=False):
1677-
"""
1676+
r"""
16781677
compute position(s) of group
16791678
"""
16801679
if bound is not None:

larray/core/metadata.py

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

111111

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

0 commit comments

Comments
 (0)