Skip to content

Commit

Permalink
re: private legacy name map within enums - not fancy but this works.
Browse files Browse the repository at this point in the history
  • Loading branch information
bnb32 committed May 29, 2024
1 parent fa71fd6 commit 123162c
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions reV/utilities/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@
class FieldEnum(str, Enum):
"""Base Field enum with some mapping methods."""

_OLD_NAMES = OldSupplyCurveField

@classmethod
def map_to(cls, other):
"""Return a rename map from this enum to another."""
Expand All @@ -57,9 +55,9 @@ def map_from(cls, other):

@classmethod
def map_from_legacy(cls):
"""Return a rename map from a dictionary of name / member pairs (e.g.
'sc_gid': 'SC_GID') to this enum."""
return {name: cls[mem] for name, mem in cls._OLD_NAMES.items()}
"""Return a dictionary -> this enum map using the dictionary of legacy
names"""
return cls.map_from(OldSupplyCurveField)

def __str__(self):
return self.value
Expand Down

0 comments on commit 123162c

Please sign in to comment.