Skip to content

Commit 61b35ee

Browse files
committed
-
1 parent 11e7e13 commit 61b35ee

File tree

5 files changed

+11
-13
lines changed

5 files changed

+11
-13
lines changed

source_py2/python_toolbox/combi/perming/variations.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ class Variation(nifty_collections.CuteEnum):
2828
DEGREED = 'degreed'
2929
SLICED = 'sliced'
3030
TYPED = 'typed'
31-
Variation.values = (Variation.RAPPLIED, Variation.RECURRENT, Variation.PARTIAL,
32-
Variation.COMBINATION, Variation.DAPPLIED, Variation.FIXED,
33-
Variation.DEGREED, Variation.SLICED, Variation.TYPED)
31+
__order__ = ('RAPPLIED RECURRENT PARTIAL COMBINATION DAPPLIED FIXED '
32+
'DEGREED SLICED TYPED')
3433

3534

3635
class UnallowedVariationSelectionException(exceptions.CuteException):

source_py2/python_toolbox/nifty_collections/cute_enum.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515

1616
class EnumType(enum.EnumMeta):
1717
'''Metaclass for our kickass enum type.'''
18-
__getitem__ = lambda self, i: self.values[i]
18+
__getitem__ = lambda self, i: self._values_tuple[i]
1919
# This `__getitem__` is important, so we could feed enum types straight
2020
# into `ProductSpace`.
2121

22-
__iter__ = lambda self: iter(self.values)
22+
_values_tuple = caching.CachedProperty(tuple)
23+
2324

2425

2526
@functools.total_ordering
@@ -33,7 +34,7 @@ class _OrderableEnumMixin(object):
3334
doesn't override them.
3435
'''
3536
number = caching.CachedProperty(
36-
lambda self: type(self).values.index(self)
37+
lambda self: type(self)._values_tuple.index(self)
3738
)
3839
__lt__ = lambda self, other: isinstance(other, CuteEnum) and \
3940
(self.number < other.number)
@@ -43,10 +44,10 @@ class CuteEnum(_OrderableEnumMixin, enum.Enum):
4344
'''
4445
An improved version of Python's builtin `enum.Enum` type.
4546
46-
Note that on Python 2, you must include a line like this after every Enum
47+
Note that on Python 2, you must include a line like this in your enum
4748
definition:
4849
49-
Flavor.values = (CHOCOLATE, VANILLA, RASPBERRY, BANANA)
50+
__order__ = 'CHOCOLATE VANILLA RASPBERRY BANANA'
5051
5152
This defines the order of elements. (On Python 3 you don't have to do this
5253
because Python 3 can figure out the order by itself.)

source_py2/test_python_toolbox/test_combi/test_extensive.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def _check_variation_selection(variation_selection, perm_space_type,
155155
degrees, slice_, perm_type):
156156
assert isinstance(variation_selection,
157157
combi.perming.variations.VariationSelection)
158-
return #blocktodo remove
158+
# return #blocktodo remove
159159
print(variation_selection.number) #blocktodo remove
160160

161161
kwargs = {}

source_py2/test_python_toolbox/test_combi/test_perm_space.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ class Suit(nifty_collections.CuteEnum):
618618
diamond = 'diamond'
619619
heart = 'heart'
620620
spade = 'spade'
621-
Suit.values = (Suit.club, Suit.diamond, Suit.heart, Suit.spade)
621+
__order__ = 'club diamond heart spade'
622622

623623
@functools.total_ordering
624624
class Card():

source_py2/test_python_toolbox/test_nifty_collections/test_cute_enum/test.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ class Flavor(CuteEnum):
1212
VANILLA = 'vanilla'
1313
RASPBERRY = 'raspberry'
1414
BANANA = 'banana'
15-
16-
Flavor.values = (Flavor.CHOCOLATE, Flavor.VANILLA, Flavor.RASPBERRY,
17-
Flavor.BANANA)
15+
__order__ = 'CHOCOLATE VANILLA RASPBERRY BANANA'
1816

1917
assert tuple(Flavor) == (Flavor.CHOCOLATE, Flavor.VANILLA,
2018
Flavor.RASPBERRY, Flavor.BANANA)

0 commit comments

Comments
 (0)