Skip to content

Add test for run_dwelling.py script and fix HPWH initialization bug#208

Open
rajeee wants to merge 2 commits intoruff_lintfrom
add-run-dwelling-test
Open

Add test for run_dwelling.py script and fix HPWH initialization bug#208
rajeee wants to merge 2 commits intoruff_lintfrom
add-run-dwelling-test

Conversation

@rajeee
Copy link
Collaborator

@rajeee rajeee commented Feb 3, 2026

Summary

  • Add --no-show CLI flag to bin/run_dwelling.py for automated testing support
  • Always save plots to disk (in addition to optional interactive display)
  • Add TestRunDwellingScript integration test that runs the script as a subprocess
  • Fix bug in WaterHeater.py where self.hp_cop was used before being defined

Details

New Test

The PR template requires "Test with run_dwelling.py or other script". This adds an automated test that validates bin/run_dwelling.py works end-to-end by running it as a subprocess with --no-show flag.

Bug Fix

Fixed an AttributeError in HeatPumpWaterHeater.__init__ where self.hp_cop was referenced before assignment. This bug was triggered when:

  1. Water heater type is "heat pump water heater"
  2. UniformEnergyFactor != 4.9 (so HPWH Capacity (W) is not set)

The fix changes self.hp_cop to self.cop_nominal on line 438, which is equivalent since self.hp_cop is later set to self.cop_nominal anyway.

Testing

All 11 dwelling tests pass including the new TestRunDwellingScript::test_run_dwelling_script.

@rajeee rajeee force-pushed the add-run-dwelling-test branch 2 times, most recently from c60ff6a to 232bfef Compare February 3, 2026 17:58
@rajeee rajeee changed the base branch from dev to ruff_lint February 3, 2026 17:58
- Add --no-show flag to bin/run_dwelling.py to support automated testing
- Always save plots to disk (in addition to optional display)
- Add TestRunDwellingScript class that runs the script as a subprocess
- Fix bug in WaterHeater.py where self.hp_cop was used before being defined
  (affects HPWH with UniformEnergyFactor != 4.9)
@rajeee rajeee force-pushed the add-run-dwelling-test branch from 232bfef to 51215e9 Compare February 3, 2026 18:14
else:
hp_power_nominal = kwargs.get("HPWH Power (W)", 500) # in W
self.hp_capacity_nominal = hp_power_nominal * self.hp_cop # in W
self.hp_capacity_nominal = hp_power_nominal * self.cop_nominal # in W
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seemed like a bug and fixed it.

@rajeee rajeee requested a review from jmaguire1 February 3, 2026 18:44
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

Successfully merging this pull request may close these issues.

1 participant