Skip to content

Commit babfdce

Browse files
sevmagclaude
andcommitted
Raise on missing string/sensor labels in ExamplePrometheusGridDefinition
Mirror the IC86 grid's validation: initialize the string and sensor-number indices to None and raise a ValueError if either label is absent from the pixel feature names, instead of leaving the attributes unset. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 04e2dd3 commit babfdce

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/graphnet/models/data_representation/images/mappings/grid_definition.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,8 @@ def _set_indices(
419419
) -> None:
420420
"""Set the indices for the features."""
421421
self._cnn_features_idx = []
422+
self._sensor_number_idx = None
423+
self._string_idx = None
422424
for feature in feature_names:
423425
if feature == sensor_number_label:
424426
self._sensor_number_idx = feature_names.index(feature)
@@ -427,6 +429,16 @@ def _set_indices(
427429
else:
428430
self._cnn_features_idx.append(feature_names.index(feature))
429431

432+
if self._sensor_number_idx is None:
433+
raise ValueError(
434+
f"Sensor number label not found in feature names: "
435+
f"{sensor_number_label}"
436+
)
437+
if self._string_idx is None:
438+
raise ValueError(
439+
f"String label not found in feature names: {string_label}"
440+
)
441+
430442
def forward(self, data: Data, data_feature_names: List[str]) -> Data:
431443
"""Scatter pixel rows into the example 3D image tensor."""
432444
# Initialize output arrays

0 commit comments

Comments
 (0)