File tree Expand file tree Collapse file tree 2 files changed +38
-2
lines changed
source_py2/python_toolbox
source_py3/python_toolbox Expand file tree Collapse file tree 2 files changed +38
-2
lines changed Original file line number Diff line number Diff line change 1111
1212
1313@nifty_collections .LazyTuple .factory
14- def get_all_contained_counters (counter ):
14+ def get_all_contained_counters (counter , use_lazy_tuple = True ):
15+ '''
16+ Get all counters that are subsets of `counter`.
17+
18+ This means all counters that have amounts identical or smaller than
19+ `counter` for each of its keys.
20+
21+ If `use_lazy_tuple=True` (default), value is returned as a `LazyTuple`, so
22+ it may be used both by lazily iterating on it *and* as a tuple. Otherwise
23+ an iterator is returned.
24+ '''
25+ iterator = _get_all_contained_counters (counter )
26+ if use_lazy_tuple :
27+ return nifty_collections .LazyTuple (iterator )
28+ else :
29+ return iterator
30+
31+
32+ def _get_all_contained_counters (counter , use_lazy_tuple = True ):
1533 assert isinstance (counter , collections .Counter )
1634 counter_type = type (counter )
1735 keys , amounts = zip (
Original file line number Diff line number Diff line change 1111
1212
1313@nifty_collections .LazyTuple .factory
14- def get_all_contained_counters (counter ):
14+ def get_all_contained_counters (counter , use_lazy_tuple = True ):
15+ '''
16+ Get all counters that are subsets of `counter`.
17+
18+ This means all counters that have amounts identical or smaller than
19+ `counter` for each of its keys.
20+
21+ If `use_lazy_tuple=True` (default), value is returned as a `LazyTuple`, so
22+ it may be used both by lazily iterating on it *and* as a tuple. Otherwise
23+ an iterator is returned.
24+ '''
25+ iterator = _get_all_contained_counters (counter )
26+ if use_lazy_tuple :
27+ return nifty_collections .LazyTuple (iterator )
28+ else :
29+ return iterator
30+
31+
32+ def _get_all_contained_counters (counter , use_lazy_tuple = True ):
1533 assert isinstance (counter , collections .Counter )
1634 counter_type = type (counter )
1735 keys , amounts = zip (
You can’t perform that action at this time.
0 commit comments