Skip to content

Conversation

@jmaguire1
Copy link
Collaborator

Merge in the latest changes to dev to the external-hvac control branch.

This is just getting external-hvac up to date to make merging easier later.

jmaguire1 and others added 30 commits August 6, 2024 14:15
This reverts commit f099d2a.

We need the tempering valve for the time being. We can more formally integrate this later, but since in our test cases WH setpoint is 140F with a tempering valve set to 125 F this is necessary for the current runs.
…to cover in future versions if we want to model broken equipment.
Temporary fix to #197. Longer term we might enable a proper fix 

- [X] Reference the issue your PR is fixing
- [x] Assign at least 1 reviewer for your PR
- [X] Test with run_dwelling.py or other script
- [X] Update documentation as appropriate
- [x] Update changelog as appropriate
Merging all the latest changes into main for new release
Fixed this on main, backporting to dev
…hedule isn't there). Can look at updating if shower draws merge into OS-HPXML in the future
Add a 120V HPWH into OCHRE, based on the model in OS-HPMXL. This model
is based on the Rheem, shared circuit product. I can potentially also
add the dedicated circuit version (higher power, but requires an open
available 15A circuit). We can also allow backup elements like AO Smith
includes.

This also includes adding the ability to model a tempering valve. These
products have an integrated tempering valve, so you can overheat the
tank to increase the stored energy to compensate for the lower heating
rate.

Not all of this is supported in HPXML yet, but that's coming soon. I
want to wait to merge this in until those changes happen so that we can
properly support this going forward, rather than just having something
triggered by temporary flags.

Fixes #133 

- [X] Reference the issue your PR is fixing
- [X] Assign at least 1 reviewer for your PR
- [X] Test with run_dwelling.py or other script
- [x] Update documentation as appropriate
- [x] Update changelog as appropriate
Add parameters for a dedicated circuit HPWH into the code on a flag
that's off by default. Helpful for some model validation cases, this is
minor enough I'm not going to call it out separate from allowing 120V
HPWHs unless it gets HPXML support in the future.
rajeee and others added 17 commits January 28, 2026 15:44
- Remove obsolete test files for deprecated APIs:
  - test_envelope.py, test_battery.py, test_hvac.py, test_fileio.py, test_base.py

- Update test fixtures across all test files:
  - Use DataFrame with DatetimeIndex for schedule parameter
  - Update method signatures (update, generate_results, etc.)
  - Fix column naming conventions

- Fix test_waterheater.py:
  - Relax duty cycle assertion to match actual behavior
  - Update TanklessWaterHeater test for new update_internal_control API

- Fix test_humidity.py:
  - Remove obsolete schedule parameter from update_humidity call

- Rewrite test_dwelling.py:
  - Update input files (BEopt_example.xml, etc.)
  - Fix equipment iteration (now dict, not list)
  - Update control signal format
  - Fix key names (Grid Voltage vs Voltage)

All 105 tests now pass.
- Run tests on push/PR to main and dev branches
- Test matrix: Ubuntu, macOS, Windows × Python 3.10, 3.11, 3.12
- Include pytest with coverage reporting
- Add optional Codecov integration
- Add ruff linting job (non-blocking)
…ppliance modules

- test_battery.py: 30 tests for Battery and BatteryThermalModel
- test_hvac.py: 27 tests for 17 HVAC equipment types
- test_envelope.py: 29 tests for Envelope, Zone, ExteriorZone
- test_wet_appliances.py: 31 tests for EventBasedLoad (wet appliances)
- test_wet_appliance_mc.py: 16 tests for WetAppliance MC profile generator

Coverage improvements:
- EventBasedLoad.py: 55% -> 88%
- WetAppliance.py: 0% -> 89%
- Overall: 71% -> 72%

Total: 133 new tests (237 total, 236 passed, 1 skipped)
## Summary

This PR fixes all stale tests in the OCHRE test suite to match the
current API. Previously, 105+ tests were failing due to API changes that
weren't reflected in the test code.

**Result: All 105 tests now pass.**

Address: #32 

## Changes

### Removed Obsolete Test Files
Tests for deprecated/removed APIs that no longer exist:
- `test/test_models/test_envelope.py`
- `test/test_equipment/test_battery.py`
- `test/test_equipment/test_hvac.py`
- `test/test_dwelling/test_fileio.py`
- `test/test_utils/test_base.py`

### Updated Test Fixtures
- Updated `schedule` parameter to use DataFrame with DatetimeIndex (not
dict)
- Fixed method signatures: `update()`, `generate_results()`,
`update_external_control()`, etc.
- Updated column naming conventions (e.g., `'Ambient Dry Bulb (C)'`
format)

### Key Fixes by File

| File | Fix |
|------|-----|
| `test_waterheater.py` | Relaxed duty cycle assertion; fixed
TanklessWaterHeater test |
| `test_humidity.py` | Removed obsolete `schedule` parameter from
`update_humidity()` |
| `test_dwelling.py` | Updated input files, control signal format,
equipment iteration |
| `test_equipment/*.py` | Updated schedule format, method signatures |
| `test_models/*.py` | Updated init args, method signatures |

## Test Results

```
======================= 105 passed, 2 warnings =======================
```

### Test Counts by Directory
| Directory | Tests |
|-----------|-------|
| test/test_dwelling | 10 |
| test/test_equipment | 62 |
| test/test_models | 33 |
| **Total** | **105** |
- Format all Python files with ruff for consistent code style
- Update CI workflow configuration
- Maintain all existing functionality (237 tests pass)
- Remove unused imports (F401) in scripts and modules
- Add __all__ lists to __init__.py files to document public API
- Replace star import in test_equipment.py with explicit imports
- Fix bare except clause in docs/source/conf.py (E722)
- Remove unused local variables (F841) or add noqa for intentional ones
- Add noqa comments for acceptable lint exceptions (E402, E741, F403)
- All 237 tests pass (1 skipped)
## Summary

This PR builds on top of PR #207 (ruff formatting) to also apply all
ruff lint fixes to the codebase.

- Remove unused imports (F401) in scripts and modules
- Add `__all__` lists to `__init__.py` files to document public API and
fix re-export warnings
- Replace star import in `test_equipment.py` with explicit imports
(fixes F403/F405)
- Fix bare `except` clause in `docs/source/conf.py` (E722 -> `except
Exception:`)
- Remove unused local variables (F841) or add noqa for intentional ones
- Add noqa comments for acceptable lint exceptions (E402, E741, F403)

### Lint Status

Before: **107 errors**
After: **0 errors** (all checks pass!)

### Test Status

All 237 tests pass (1 skipped).

### How to run

```bash
# Check for lint errors (should show 0 errors)
ruff check .

# Auto-fix any future lint issues
ruff check --fix .
```

### Notes

- Some variables like `heating_des_init` and `cooling_des_init` in
`ochre/utils/equipment.py` are kept with `# noqa: F841` because they're
used dynamically by `eval()` when loading zone temperature files
- The star import `from .Equipment import *` in `ochre/__init__.py` is
kept for API compatibility with `# noqa: F403`
## Summary

- Apply ruff code formatting across entire Python codebase for
consistent style
- Update CI workflow configuration
- All 237 tests pass (236 passed, 1 skipped)

### **Linting vs. Formatting with Ruff**

We have migrated to **Ruff**, which replaces several older tools with a
single, faster engine.

* **Formatting (Replaces [Black](https://github.com/psf/black)):**
Standardizes the visual style of the code, such as indentation, line
lengths, and quoting.
    * **How to run:** `ruff format .`
* **Linting (Replaces [Flake8](https://github.com/PyCQA/flake8) and
[isort](https://github.com/PyCQA/isort)):** Analyzes code for logical
errors, unused imports, or non-standard practices.
* **How to run:** `ruff check .` (use `ruff check --fix .` to
automatically resolve simple issues)

### **Current Policy**

* **Formatting is Enforced:** The CI pipeline will fail if the code is
not formatted. Please run `ruff format .` before every commit.
* **Linting is Recommended:** While we aren't enforcing strict linting
yet (due to the high volume of existing errors in the codebase), we
strongly encourage you to run check your changes to ensure new edits are
as clean as possible. For example, run `ruff check
ochre/Models/StateSpaceModel.py` check for lints in the
StateSpaceModel.py file.


### **Setting up Ruff**

To ensure your environment is set up correctly to use the new tooling,
please follow these steps:

1.  **Update your branch**
Merge the latest `dev` branch into your current feature branch to get
the new configuration files.

2.  **Install `uv`** if you don't already have it.
    We use `uv` for fast Python package management.
    You can install it from pip with:
  	 ```bash
     pip install uv
	```

    * **macOS / Linux:**
        ```bash
curl -LsSf
[https://astral.sh/uv/install.sh](https://astral.sh/uv/install.sh) | sh
        ```
    * **Windows:**
        ```powershell
powershell -ExecutionPolicy ByPass -c "irm
[https://astral.sh/uv/install.ps1](https://astral.sh/uv/install.ps1) |
iex"
        ```

3.  **Sync Dependencies**
If you already have a `.venv` folder in your project directory, please
delete it first to ensure a clean install. Then run:
    ```bash
    uv sync
    ```

4.  **Run Formatting**
You can run Ruff directly using `uv` (recommended) or by activating your
environment.

    * **Option A (Recommended):** Run via `uv`
        ```bash
        uv run ruff format .
        ```

    * **Option B:** Activate environment first
        * **macOS / Linux:**
            ```bash
            source .venv/bin/activate
            ruff format .
            ```
        * **Windows:**
            ```powershell
            .venv\Scripts\activate
            ruff format .
            ```

```
@jmaguire1 jmaguire1 self-assigned this Feb 11, 2026
@jmaguire1
Copy link
Collaborator Author

Merge, then fix linting issue when we have ruff

@jmaguire1 jmaguire1 merged commit 72abaac into external-hvac Feb 11, 2026
19 of 20 checks passed
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.

3 participants