@@ -278,8 +278,18 @@ def __getitem__(self, i):
278278 )
279279
280280 def apply (self , sequence , result_type = None ):
281- '''blocktododoc
282- App
281+ '''
282+ Apply the perm to a sequence, choosing items from it.
283+
284+ This can also be used as `sequence * perm`. Example:
285+
286+ >>> perm = PermSpace(5)[10]
287+ >>> perm
288+ <Perm: (0, 2, 4, 1, 3)>
289+ >>> perm.apply('growl')
290+ 'golrw'
291+ >>> 'growl' * perm
292+ 'golrw'
283293
284294 Specify `result_type` to determine the type of the result returned. If
285295 `result_type=None`, will use `tuple`, except when `other` is a `str` or
@@ -314,6 +324,7 @@ def apply(self, sequence, result_type=None):
314324 # multiplication of objects of the same type.)
315325
316326 def __pow__ (self , exponent ):
327+ '''Raise the perm by the power of `exponent`.'''
317328 assert isinstance (exponent , numbers .Integral )
318329 if exponent <= - 1 :
319330 return self .inverse ** (- exponent )
@@ -326,6 +337,15 @@ def __pow__(self, exponent):
326337
327338 @caching .CachedProperty
328339 def degree (self ):
340+ '''
341+ The permutation's degree.
342+
343+ You can think of a permutation's degree like this: Imagine that you're
344+ starting with the identity permutation, and you want to make this
345+ permutation, by switching two items with each other over and over again
346+ until you get this permutation. The degree is the number of such
347+ switches you'll have to make.
348+ '''
329349 if self .is_partial :
330350 return NotImplemented
331351 else :
@@ -334,6 +354,13 @@ def degree(self):
334354
335355 @caching .CachedProperty
336356 def n_cycles (self ):
357+ '''
358+ The number of cycles in this permutation.
359+
360+ If item 1 points at item 7, and item 7 points at item 3, and item 3
361+ points at item 1 again, then that's one cycle. `n_cycles` is the total
362+ number of cycles in this permutation.
363+ '''
337364 if self .is_partial :
338365 return NotImplemented
339366 if self .is_rapplied :
@@ -357,6 +384,9 @@ def n_cycles(self):
357384
358385
359386 def get_neighbors (self , * , degrees = (1 ,), perm_space = None ):
387+ '''
388+
389+ '''
360390 from ..map_space import MapSpace
361391 if self .is_combination or self .is_recurrent or self .is_partial :
362392 raise NotImplementedError
0 commit comments