I just corrected an error where there was a comparison against a misspelled "Electricty". This is a great example of why one should avoid using hardcoded strings. The other reason is that it's easier to change a value if all uses flow through a single definition.
In energy.py, there are these definitions:
# TBD: Decide if these strings are the ones we want to use throughout. Some seem a bit random.
EN_NATURAL_GAS = 'Natural gas'
EN_UPG_PROC_GAS = 'Upgrader proc. gas'
EN_NGL = 'NGL'
EN_CRUDE_OIL = 'Crude oil'
EN_DIESEL = 'Diesel'
EN_RESID = 'Residual fuel'
EN_PETCOKE = 'Pet. coke'
EN_ELECTRICITY = 'Electricity'
So rather than testing for "Electricity", use EN_ELECTRICITY. Can't spell it wrong or the code won't run.
We should review the code more broadly to look for hardcoded strings that can be replaced with defined names, or if appropriate, enums
I just corrected an error where there was a comparison against a misspelled "Electricty". This is a great example of why one should avoid using hardcoded strings. The other reason is that it's easier to change a value if all uses flow through a single definition.
In energy.py, there are these definitions:
So rather than testing for "Electricity", use
EN_ELECTRICITY
. Can't spell it wrong or the code won't run.We should review the code more broadly to look for hardcoded strings that can be replaced with defined names, or if appropriate,
enum
s