Skip to content

Commit 2c22cbf

Browse files
committed
-
1 parent 0b059dd commit 2c22cbf

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

source_py3/python_toolbox/collection_tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def get_all_contained_counters(counter, use_lazy_tuple=True):
2929
return iterator
3030

3131

32-
def _get_all_contained_counters(counter, use_lazy_tuple=True):
32+
def _get_all_contained_counters(counter):
3333
assert isinstance(
3434
counter,
3535
(

source_py3/python_toolbox/copy_tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ def deepcopy_as_simple_object(thing, memo=None):
1919
memo[id(thing)] = new_thing
2020
for (name, subthing) in vars(thing).items():
2121
new_thing.__dict__[name] = copy.deepcopy(subthing, memo)
22-
return(new_thing)
22+
return new_thing
2323

2424

source_py3/python_toolbox/cute_iter_tools.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ def _iterate_overlapping_subsequences(iterable, length, wrap_around):
8787
yield tuple(deque)
8888

8989

90-
def shorten(iterable, n, lazy_tuple=False):
90+
def shorten(iterable, length, lazy_tuple=False):
9191
'''
92-
Shorten an iterable to length `n`.
92+
Shorten an iterable to `length`.
9393
9494
Iterate over the given iterable, but stop after `n` iterations (Or when the
9595
iterable stops iteration by itself.)
@@ -98,7 +98,7 @@ def shorten(iterable, n, lazy_tuple=False):
9898
9999
If `lazy_tuple=True`, returns a `LazyTuple` rather than an iterator.
100100
'''
101-
iterator = _shorten(iterable=iterable, n=n)
101+
iterator = _shorten(iterable=iterable, length=length)
102102

103103
if lazy_tuple:
104104
from python_toolbox import nifty_collections
@@ -107,20 +107,20 @@ def shorten(iterable, n, lazy_tuple=False):
107107
return iterator
108108

109109

110-
def _shorten(iterable, n):
110+
def _shorten(iterable, length):
111111

112-
if n == infinity:
112+
if length == infinity:
113113
yield from iterable
114114
raise StopIteration
115115

116-
assert isinstance(n, int)
116+
assert isinstance(length, int)
117117

118-
if n == 0:
118+
if length == 0:
119119
raise StopIteration
120120

121121
for i, thing in enumerate(iterable):
122122
yield thing
123-
if i + 1 == n: # Checking `i + 1` to avoid pulling an extra item.
123+
if i + 1 == length: # Checking `i + 1` to avoid pulling an extra item.
124124
raise StopIteration
125125

126126

@@ -152,7 +152,7 @@ def _enumerate(iterable, reverse_index):
152152
try:
153153
length = sequence_tools.get_length(iterable)
154154
except AttributeError:
155-
iterable = revenifty_collections.LazyTuple(iterable)
155+
iterable = nifty_collections.LazyTuple(iterable)
156156
length = len(iterable)
157157
return zip(range(length - 1, -1, -1), iterable)
158158

@@ -177,7 +177,7 @@ def get_length(iterable):
177177
If given an iterator, it will be exhausted.
178178
'''
179179
i = 0
180-
for thing in iterable:
180+
for _ in iterable:
181181
i += 1
182182
return i
183183

@@ -211,17 +211,17 @@ def _iter_with(iterable, context_manager):
211211
yield next_item
212212

213213

214-
def get_items(iterable, n, container_type=tuple):
214+
def get_items(iterable, n_items, container_type=tuple):
215215
'''
216-
Get the next `n` items from the iterable as a `tuple`.
216+
Get the next `n_items` items from the iterable as a `tuple`.
217217
218218
If there are less than `n` items, no exception will be raised. Whatever
219219
items are there will be returned.
220220
221221
If you pass in a different kind of container than `tuple` as
222222
`container_type`, it'll be used to wrap the results.
223223
'''
224-
return container_type(shorten(iterable, n))
224+
return container_type(shorten(iterable, n_items))
225225

226226

227227
def double_filter(filter_function, iterable, lazy_tuple=False):
@@ -235,7 +235,8 @@ def double_filter(filter_function, iterable, lazy_tuple=False):
235235
Note that this function is not thread-safe. (You may not consume the two
236236
iterators on two separate threads.)
237237
238-
If `lazy_tuple=True`, returns two `LazyTuple` objects rather than two iterator.
238+
If `lazy_tuple=True`, returns two `LazyTuple` objects rather than two
239+
iterator.
239240
'''
240241
iterator = iter(iterable)
241242

@@ -396,7 +397,7 @@ def get_single_if_any(iterable,
396397

397398

398399
def are_equal(*sequences):
399-
from python_toolbox import sys_tools
400+
'''blocktododoc'''
400401
from python_toolbox import logic_tools
401402
sequence_types = set(map(type, sequences))
402403

@@ -422,6 +423,7 @@ def are_equal(*sequences):
422423

423424

424425
def is_sorted(iterable, key=None):
426+
'''blocktododoc'''
425427
from python_toolbox import misc_tools
426428
if key is None:
427429
key = misc_tools.identity_function
@@ -490,6 +492,7 @@ def iterate_popitem(item_poppable, lazy_tuple=False):
490492

491493

492494
def zip_non_equal(iterables, lazy_tuple=False):
495+
'''blocktododoc'''
493496
from python_toolbox import logic_tools
494497
iterator = (items for items in zip(*iterables)
495498
if not logic_tools.all_equal(items))

0 commit comments

Comments
 (0)