Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[modernize] Use proper Enums and remove get_all #89

Open
jmarrec opened this issue Jul 26, 2022 · 1 comment
Open

[modernize] Use proper Enums and remove get_all #89

jmarrec opened this issue Jul 26, 2022 · 1 comment

Comments

@jmarrec
Copy link
Contributor

jmarrec commented Jul 26, 2022

class ReportingFreq:
DETAILED = "Detailed"
TIME_STEP = "Timestep"
HOURLY = "Hourly"
DAILY = "Daily"
MONTHLY = "Monthly"
RUN_PERIOD = "RunPeriod"
ENVIRONMENT = "Environment"
ANNUAL = "Annual"
@staticmethod
def get_all():
return [
ReportingFreq.DETAILED, ReportingFreq.TIME_STEP, ReportingFreq.HOURLY,
ReportingFreq.DAILY, ReportingFreq.MONTHLY, ReportingFreq.RUN_PERIOD,
ReportingFreq.ENVIRONMENT, ReportingFreq.ANNUAL
]

Transition to use Enums, which makes get_all unecessary

from enum import Enum
class ReportingFreq(Enum):
    DETAILED = "Detailed"
    TIME_STEP = "Timestep"
    HOURLY = "Hourly"
    DAILY = "Daily"
    MONTHLY = "Monthly"
    RUN_PERIOD = "RunPeriod"
    ENVIRONMENT = "Environment"
    ANNUAL = "Annual"
    
In [2]: [x for x in ReportingFreq]
Out [2]: 
[<ReportingFreq.DETAILED: 'Detailed'>,
 <ReportingFreq.TIME_STEP: 'Timestep'>,
 <ReportingFreq.HOURLY: 'Hourly'>,
 <ReportingFreq.DAILY: 'Daily'>,
 <ReportingFreq.MONTHLY: 'Monthly'>,
 <ReportingFreq.RUN_PERIOD: 'RunPeriod'>,
 <ReportingFreq.ENVIRONMENT: 'Environment'>,
 <ReportingFreq.ANNUAL: 'Annual'>]

(each enum has a .name and a .value attribute too)

@Myoldmopar
Copy link
Member

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants