Skip to content

Commit f151e00

Browse files
committed
Rename device -> component in the binding docs and tests
Pure terminology: the per-category formulas' non-meter source is a component, matching component-graph's vocabulary (the flag is prefer_meters_in_component_formulas). Rename _DEVICE_PRIMARY and the "device" wording in the type stub and preference tests to "component"; no behavior change. Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
1 parent 538bd94 commit f151e00

2 files changed

Lines changed: 17 additions & 17 deletions

File tree

python/frequenz/microgrid_component_graph/__init__.pyi

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,25 +50,25 @@ class ComponentGraphConfig:
5050
predecessor meters. When `false`, consumer formula is generated by
5151
excluding production and battery components from the grid measurements.
5252
prefer_meters_in_component_formulas: Default policy for the per-category
53-
formulas. When `False` (the default), the device measurement is the
53+
formulas. When `False` (the default), the component measurement is the
5454
primary source and the meter measurement is the fallback for
5555
`battery_formula`, `chp_formula`, `pv_formula`, `wind_turbine_formula`,
5656
`ev_charger_formula`, and `steam_boiler_formula`. When `True`, the
57-
meter is primary and the device is the fallback. Has no effect on
57+
meter is primary and the component is the fallback. Has no effect on
5858
`grid_formula`, `consumer_formula`, `producer_formula`, or any of the
5959
coalesce formulas.
60-
formula_overrides: Per-formula overrides for the meter/device preference;
60+
formula_overrides: Per-formula overrides for the meter/component preference;
6161
see `FormulaOverrides`. Each entry, when set, takes precedence over
6262
`prefer_meters_in_component_formulas` for that formula.
6363
"""
6464

6565
class FormulaOverrides:
66-
"""Per-formula overrides for the meter/device preference.
66+
"""Per-formula overrides for the meter/component preference.
6767
6868
Each parameter is `None` by default, meaning the corresponding formula
6969
follows the global `prefer_meters_in_component_formulas` setting on
7070
`ComponentGraphConfig`. Setting `True` forces the meter as primary
71-
for that formula; `False` forces the device.
71+
for that formula; `False` forces the component.
7272
"""
7373

7474
def __init__(

tests/test_formula_preferences.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33

44
"""Behavioral tests for `ComponentGraphConfig` formula preferences.
55
6-
These tests build a small, controllable graph (Grid -> Meter -> Device)
6+
These tests build a small, controllable graph (Grid -> Meter -> Component)
77
for each per-category formula method and assert the actual formula
8-
output for the four meter/device-preference combinations:
8+
output for the four meter/component-preference combinations:
99
10-
* default config -> device primary
10+
* default config -> component primary
1111
* global True -> meter primary
1212
* per-formula override = True -> meter primary (override wins)
13-
* per-formula override = False -> device primary (override wins)
13+
* per-formula override = False -> component primary (override wins)
1414
1515
The drift test in `test_stub_drift.py` only checks signatures; this
1616
file catches actual mis-wiring -- a swapped override, an inverted
@@ -46,9 +46,9 @@
4646
_MGRID = MicrogridId(1)
4747

4848
# In every per-category topology built below, component #2 is the meter
49-
# and #3 is the device that appears in the formula.
49+
# and #3 is the component that appears in the formula.
5050
_METER_PRIMARY = "COALESCE(#2, #3, 0.0)"
51-
_DEVICE_PRIMARY = "COALESCE(#3, #2, 0.0)"
51+
_COMPONENT_PRIMARY = "COALESCE(#3, #2, 0.0)"
5252

5353
# Each per-category graph builder takes an optional `config` and returns a
5454
# graph rooted at the same Grid -> Meter pair, so the assertion strings
@@ -104,7 +104,7 @@ def _battery_graph(
104104
config: ComponentGraphConfig | None = None,
105105
) -> ComponentGraph[Any, Any, Any]:
106106
# Grid -> Meter -> BatteryInverter -> Battery; the formula references
107-
# the inverter (#3) as the device, the battery (#4) doesn't appear.
107+
# the inverter (#3) as the component, the battery (#4) doesn't appear.
108108
return ComponentGraph(
109109
components={
110110
_grid(),
@@ -190,14 +190,14 @@ def _steam_boiler_graph(
190190

191191

192192
@pytest.mark.parametrize("build_graph,method,override_field", _CATEGORIES)
193-
def test_default_config_prefers_device(
193+
def test_default_config_prefers_component(
194194
build_graph: GraphBuilder,
195195
method: str,
196196
override_field: str, # pylint: disable=unused-argument
197197
) -> None:
198-
"""Default config selects the device as the primary source."""
198+
"""Default config selects the component as the primary source."""
199199
formula = getattr(build_graph(None), method)(None)
200-
assert formula == _DEVICE_PRIMARY
200+
assert formula == _COMPONENT_PRIMARY
201201

202202

203203
@pytest.mark.parametrize("build_graph,method,override_field", _CATEGORIES)
@@ -229,13 +229,13 @@ def test_override_true_wins_over_global_false(
229229
def test_override_false_wins_over_global_true(
230230
build_graph: GraphBuilder, method: str, override_field: str
231231
) -> None:
232-
"""A `False` per-formula override flips to device despite a `True` global."""
232+
"""A `False` per-formula override flips to component despite a `True` global."""
233233
config = ComponentGraphConfig(
234234
prefer_meters_in_component_formulas=True,
235235
formula_overrides=FormulaOverrides(**{override_field: False}),
236236
)
237237
formula = getattr(build_graph(config), method)(None)
238-
assert formula == _DEVICE_PRIMARY
238+
assert formula == _COMPONENT_PRIMARY
239239

240240

241241
def _empty_graph() -> ComponentGraph[Any, Any, Any]:

0 commit comments

Comments
 (0)