Skip to content

Commit afd1b6b

Browse files
committed
-
1 parent 0491e8f commit afd1b6b

File tree

3 files changed

+32
-5
lines changed

3 files changed

+32
-5
lines changed

source_py3/python_toolbox/combi/perming/_variation_removing_mixin.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ def _get_just_fixed(self):
156156

157157
_nominal_perm_space_of_perms = caching.CachedProperty(
158158
lambda self: self.unsliced.undegreed.unfixed,
159-
doc='''blocktododoc'''
160159
)
161160

162161

source_py3/python_toolbox/math_tools/sequences.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,16 @@
1212
_n_highest_cache_completed = -1
1313
def stirling(n, k, skip_calculation=False):
1414
'''
15-
blocktododoc specify first kind
15+
Calculate Stirling number of the second kind of `n` and `k`.
16+
17+
More information about these numbers:
18+
https://en.wikipedia.org/wiki/Stirling_numbers_of_the_second_kind
19+
20+
Example:
21+
22+
>>> stirling(3, 2)
23+
-3
24+
1625
'''
1726
global _n_highest_cache_completed
1827
if k not in range(n + 1):
@@ -54,5 +63,17 @@ def stirling(n, k, skip_calculation=False):
5463

5564

5665
def abs_stirling(n, k):
66+
'''
67+
Calculate Stirling number of the first kind of `n` and `k`.
68+
69+
More information about these numbers:
70+
https://en.wikipedia.org/wiki/Stirling_numbers_of_the_first_kind
71+
72+
Example:
73+
74+
>>> abs_stirling(3, 2)
75+
3
76+
77+
'''
5778
return abs(stirling(n, k))
5879

source_py3/python_toolbox/nifty_collections/frozen_tally_and_frozen_ordered_tally.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,16 @@ def __and__(self, other):
198198

199199
__bool__ = lambda self: any(True for element in self.elements())
200200

201-
n_elements = property( # blocktodo: want to make this cached but import loop
202-
lambda self: sum(self.values())
203-
)
201+
202+
_n_elements = None
203+
@property
204+
def n_elements(self):
205+
# Implemented as a poor man's `CachedProperty` because we can't use the
206+
# real `CachedProperty` due to circular import.
207+
if self._n_elements is None:
208+
self._n_elements = sum(self.values())
209+
return self._n_elements
210+
204211

205212
# We define all the comparison methods manually instead of using
206213
# `total_ordering` because `total_ordering` assumes that >= means (> and

0 commit comments

Comments
 (0)