Skip to content

Commit 2ac39bd

Browse files
committed
-
1 parent d8ecc76 commit 2ac39bd

File tree

4 files changed

+24
-17
lines changed

4 files changed

+24
-17
lines changed

misc/IDE files/Wing/python_toolbox_py3.wpr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ debug.launch-configs = (1,
1616
'pypath': ('default',
1717
''),
1818
'pyrunargs': ('project',
19-
u''),
20-
'runargs': u'',
21-
'rundir': ('default',
22-
u'')})})
19+
''),
20+
'runargs': u'--processes=3',
21+
'rundir': ('custom',
22+
u'${WING:PROJECT_HOME}')})})
2323
proj.directory-list = [{'dirloc': loc('../../..'),
2424
'excludes': [u'dist',
2525
u'source_py2',

source_py3/python_toolbox/combi/map_space.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,6 @@ def __iter__(self):
6161
__eq__ = lambda self, other: (isinstance(other, MapSpace) and
6262
self._reduced == other._reduced)
6363

64+
__bool__ = lambda self: bool(self.sequence)
6465

6566

source_py3/python_toolbox/nifty_collections/lazy_tuple.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,12 @@ def __ne__(self, other):
211211

212212

213213
def __bool__(self):
214-
self.exhaust(0)
215-
return bool(self.collected_data)
214+
try:
215+
next(iter(self))
216+
except StopIteration:
217+
return False
218+
else:
219+
return True
216220

217221

218222
def __lt__(self, other):

source_py3/test_python_toolbox/test_combi/test_exhaustive.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ def _check_variation_selection(variation_selection, perm_space_type,
187187
None),
188188
**kwargs
189189
)
190-
brute_perm_space_tuple = tuple(brute_perm_space)
191190

192191
assert perm_space.variation_selection == variation_selection
193192
assert perm_space.sequence_length == len(sequence)
@@ -198,12 +197,9 @@ def _check_variation_selection(variation_selection, perm_space_type,
198197
not variation_selection.is_partial
199198
)
200199

201-
assert perm_space.length == len(brute_perm_space_tuple)
202-
203200
if perm_space.length:
204201
assert perm_space.index(perm_space[-1]) == perm_space.length - 1
205202
assert perm_space.index(perm_space[0]) == 0
206-
assert tuple(perm_space[-1]) == brute_perm_space_tuple[-1]
207203

208204
if variation_selection.is_partial:
209205
assert 0 < perm_space.n_unused_elements == \
@@ -236,7 +232,7 @@ def _check_variation_selection(variation_selection, perm_space_type,
236232
# really not.
237233

238234
for i, (perm, brute_perm_tuple) in enumerate(
239-
itertools.islice(zip(perm_space, brute_perm_space_tuple), 30)):
235+
itertools.islice(zip(perm_space, brute_perm_space), 30)):
240236

241237
assert tuple(perm) == brute_perm_tuple
242238
assert perm in perm_space
@@ -452,22 +448,28 @@ def _iterate_tests():
452448
else:
453449
slice_options = (NO_ARGUMENT,)
454450

455-
for product in combi.ProductSpace(
451+
product_space_ = combi.ProductSpace(
456452
((variation_selection,), perm_space_type_options,
457453
iterable_or_length_and_sequence_options, domain_to_cut_options,
458454
n_elements_options, is_combination_options,
459455
purified_fixed_map_options, degrees_options, slice_options)
460-
):
461-
yield (_check_variation_selection,) + product
456+
)
457+
458+
for i in range(len(product_space_)):
459+
fucking_globals = dict(globals())
460+
fucking_globals.update(locals())
461+
yield eval(
462+
'lambda: _check_variation_selection(*product_space_[%s])' % i,
463+
fucking_globals, locals()
464+
)
462465

463466

464467
# We use this shit because Nose can't parallelize generator tests:
465468
lambdas = []
466-
for i, x in enumerate(_iterate_tests()):
467-
f = lambda: x[0](*x[1:])
469+
for i, f in enumerate(_iterate_tests()):
468470
f.name = 'f_%s' % i
469471
locals()[f.name] = f
470472
lambdas.append(f)
471-
for i, partition in enumerate(sequence_tools.partitions(lambdas, 1000)):
473+
for i, partition in enumerate(sequence_tools.partitions(lambdas, 10)):
472474
exec('def test_%s(): return (%s)' %
473475
(i, ', '.join('%s()'% f.name for f in partition)))

0 commit comments

Comments
 (0)