Skip to content

Commit cb971c9

Browse files
committed
Supporting Python 2.6
1 parent cd4f181 commit cb971c9

File tree

8 files changed

+15
-12
lines changed

8 files changed

+15
-12
lines changed

source_py2/python_toolbox/combi/perming/perm_space.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ def _unsliced_length(self):
424424
return calculate_length_of_recurrent_perm_space(
425425
self.n_elements - len(self.fixed_map),
426426
nifty_collections.FrozenBagBag(
427-
collections.Counter(self.free_values).values()
427+
nifty_collections.Bag(self.free_values).values()
428428
)
429429
)
430430
else:

source_py2/python_toolbox/sequence_tools/misc.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ def are_equal_regardless_of_order(seq1, seq2):
3030
3131
Currently will fail for items that have problems with comparing.
3232
'''
33-
return collections.Counter(seq1) == collections.Counter(seq2)
33+
from python_toolbox import nifty_collections
34+
return nifty_collections.Bag(seq1) == nifty_collections.Bag(seq2)
3435

3536

3637
def flatten(iterable):
@@ -224,9 +225,10 @@ def get_recurrences(sequence):
224225
225226
The values of the dict are the numbers of repititions of each item.
226227
'''
228+
from python_toolbox import nifty_collections
227229
return dict(
228230
(item, n_recurrences) for item, n_recurrences in
229-
collections.Counter(sequence).most_common() if n_recurrences >= 2
231+
nifty_collections.Bag(sequence).most_common() if n_recurrences >= 2
230232
)
231233

232234

source_py2/test_python_toolbox/test_combi/test_perm_space.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33

44
import pickle
55
import itertools
6-
import functools
76
import math
87

8+
from python_toolbox.third_party import functools
9+
910
from python_toolbox import cute_testing
1011
from python_toolbox import math_tools
1112
from python_toolbox import cute_iter_tools

source_py2/test_python_toolbox/test_random_tools/test_shuffled.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ def test():
2222
assert my_range == list(range(50))
2323

2424
# Immutable sequences work too:
25-
assert set(random_tools.shuffled((1, 2, 3))) == {1, 2, 3}
25+
assert set(random_tools.shuffled((1, 2, 3))) == set((1, 2, 3))

source_py2/test_python_toolbox/test_sleek_reffing/test_cute_sleek_value_dict/tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
def test():
2020
'''Test the basic workings of `CuteSleekValueDict`.'''
2121
volatile_things = [A(), 1, 4.5, 'meow', u'woof', [1, 2], (1, 2), {1: 2},
22-
{1, 2, 3}]
22+
set((1, 2, 3))]
2323
unvolatile_things = [__builtins__, list, type, sum]
2424

2525
# Using len(csvd) as our key; just to guarantee we're not running over an
@@ -56,7 +56,7 @@ def test():
5656

5757
def test_one_by_one():
5858
volatile_things = [A(), 1, 4.5, 'meow', u'woof', [1, 2], (1, 2), {1: 2},
59-
{1, 2, 3}]
59+
set((1, 2, 3))]
6060
unvolatile_things = [__builtins__, list, type, sum]
6161

6262
# Using len(csvd) as our key; just to guarantee we're not running over an

source_py2/test_python_toolbox/test_sleek_reffing/test_sleek_call_args.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def test_unhashable():
3939
'''Test `SleekCallArgs` on unhashable arguments.'''
4040
sca_dict = {}
4141

42-
args = ([1, 2], {1: [1, 2]}, {'a', 1})
42+
args = ([1, 2], {1: [1, 2]}, set(('a', 1)))
4343
sca1 = SleekCallArgs(sca_dict, f, *args)
4444
hash(sca1)
4545
sca_dict[sca1] = 'meow'
@@ -52,7 +52,7 @@ def test_unhashable():
5252
'a': {1: 2},
5353
'b': [
5454
set(),
55-
{frozenset((3, 4))}
55+
set((frozenset((3, 4))))
5656
]
5757
}
5858
sca2 = SleekCallArgs(sca_dict, f, **kwargs)

source_py2/test_python_toolbox/test_sleek_reffing/test_sleek_ref.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def test_sleek_ref():
2121
'''Test the basic workings of `SleekRef`.'''
2222

2323
volatile_things = [A(), 1, 4.5, 'meow', u'woof', [1, 2], (1, 2), {1: 2},
24-
{1, 2, 3}, (None, 3, {None: 4})]
24+
set((1, 2, 3)), (None, 3, {None: 4})]
2525
unvolatile_things = [__builtins__, type, sum, None]
2626
# (Used to have `list` here too but Pypy 2.0b choked on it.)
2727

source_py2/test_python_toolbox/test_string_cataloging/test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ def test():
1313
assert string_cataloging.integer_to_string(y) == 'zwei'
1414
assert string_cataloging.integer_to_string(z) == 'drei'
1515

16-
assert {string_cataloging.string_to_integer('zwei') for i in xrange(10)} \
17-
== {y}
16+
assert set((string_cataloging.string_to_integer('zwei')
17+
for i in xrange(10))) == set((y,))

0 commit comments

Comments
 (0)