Fix rate text descriptions to use tariff range#3484
Fix rate text descriptions to use tariff range#3484springfall2008 merged 2 commits intospringfall2008:mainfrom
Conversation
Remove charge threshold override in band_rate_text so rate descriptions reflect the actual tariff structure. On multi-tier tariffs like Cosy Octopus, 14p slots now show as "cheap" instead of "expensive". Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
| text = "expensive" | ||
| else: | ||
| text = "very expensive" | ||
| rate_frac = (rate - self.rate_min) / (self.rate_max - self.rate_min) |
There was a problem hiding this comment.
This could give a divide by zero error on a fixed rate tariff?
There was a problem hiding this comment.
Yes, will add a check for that and resolve the test error (thought I had run them before submitting, sorry)
The export branch of band_rate_text referenced a removed local variable (export_cost_threshold), causing a NameError. Switched export to use the same rate_frac approach as import with 4 bands (very low/low/good/very good). Added tests covering flat rate, Cosy Octopus, Flux import/export, and edge cases (free, negative, zero). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Thanks for the review. The divide-by-zero was already guarded (the Export now uses the same |
Summary
Test plan
🤖 Generated with Claude Code