You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fix empty-band-list crash in get_rate_fixed_charge_at_dt when all bands are filtered by BOOLEAN applicability #49
get_rate_fixed_charge_at_dt in fixedcharge.py raises a misleading RateConversionError ("Fixed price rate bands units should be COST_PER_UNIT") when rate_filter_bands returns an empty list. An empty list is a valid outcome when all bands in a FIXED_PRICE rate carry applicabilityValue=true and the scenario resolves the corresponding BOOLEAN property to False — meaning the charge simply does not apply to this customer.
The root cause is this check:
bands = ru.rate_filter_bands(rate, scenario, library)
band_rate_units = {band["rate_unit"] for band in bands} # empty set when bands=[]
if "COST_PER_UNIT" not in band_rate_units: # always True for empty set → raises
raise RateConversionError(rate, "Fixed price rate bands units should be COST_PER_UNIT")
Why
This crashes URDB conversion for any utility that models opt-in charges as FIXED_PRICE rates with BOOLEAN applicability guards. BGE has two such rates ("Competitive Billing", "Smart Meter Opt-Out Charge"). A standard residential customer on utility service with no opt-out genuinely does not pay these charges — the correct contribution is $0, not an exception.
How
In get_rate_fixed_charge_at_dt, add an early return of 0.0 when rate_filter_bands returns an empty list:
def get_rate_fixed_charge_at_dt(scenario, library, rate, dt):
bands = rate_filter_bands(rate, scenario, library)
if not bands:
return 0.0
...existing logic...
Deliverables
PR adding the early-return guard in get_rate_fixed_charge_at_dt
Unit test: construct a synthetic FIXED_PRICE rate with a single band carrying applicabilityValue=true and a scenario where the BOOLEAN property is False; assert the function returns 0.0 rather than raising
Activity
linear commentedon Jul 6, 2026
TF-29