Skip to content

Commit cce8efe

Browse files
sunt05claude
andcommitted
Refactor: Simplify test imports and improve documentation
- Replace convoluted importlib mechanics with standard import in test_soil_obs_conversion.py (reduces 14 lines to 3) - Clarify df_state column count comment to explain the 28 soil observation fields (4 fields × 7 surfaces) - Note that Water/Bldgs surfaces don't need soil obs but get columns anyway due to flat df_state structure 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent f2376c1 commit cce8efe

File tree

2 files changed

+2
-13
lines changed

2 files changed

+2
-13
lines changed

test/cmd/test_df_state_conversion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def test_convert_old_csv(self, old_csv_path):
9494
assert len(df_new) == len(df_old)
9595
assert (
9696
len(df_new.columns) == 1451
97-
) # New format has 1451 columns (1420 + 3 view factors + 28 soil obs fields)
97+
) # New format: 1420 old + 3 view factors + 28 soil obs (4 fields × 7 surfaces, though Water/Bldgs don't need soil obs)
9898

9999
# Check old columns removed
100100
col_names = {

test/core/test_soil_obs_conversion.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,7 @@
1-
import sys
2-
from pathlib import Path
3-
import importlib.util
4-
51
import pandas as pd
62
import pytest
73

8-
REPO_ROOT = Path(__file__).resolve().parents[2]
9-
MODULE_PATH = REPO_ROOT / "src" / "supy" / "util" / "_forcing.py"
10-
spec = importlib.util.spec_from_file_location("util._forcing", MODULE_PATH)
11-
soil_obs = importlib.util.module_from_spec(spec)
12-
assert spec.loader is not None
13-
sys.modules[spec.name] = soil_obs
14-
spec.loader.exec_module(soil_obs)
15-
convert_observed_soil_moisture = soil_obs.convert_observed_soil_moisture
4+
from supy.util._forcing import convert_observed_soil_moisture
165

176

187
def _make_state(

0 commit comments

Comments
 (0)