PowerGridModel/power-grid-model

[BUG] Validation fails for a configuration without three winding transformers

Closed this issue · 5 comments

Describe the bug

I get an KeyError: <ComponentType.three_winding_transformer: 'three_winding_transformer'> when validating a configuration that does not have any three_winding_transformers.

To Reproduce

del input_data["three_winding_transformer"]
assert_valid_input_data(input_data)

Expected behavior

I think it should be possible to validate an input_data object without three_winding_transformer?

Additional context

Can be solved by changing:

for ref_component, ref_field in tap_side_fields:
indices = get_indexer(data[ref_component]["id"], data[component][regulated_object_field], default_value=-1)
found = indices != -1
ref_comp_values = data[ref_component][ref_field][indices[found]]
invalid[found] = np.logical_or(invalid[found], values[found] == ref_comp_values)

into:

for ref_component, ref_field in tap_side_fields:
    if data.get("ref_component", False):
      indices = get_indexer(data[ref_component]["id"], data[component][regulated_object_field], default_value=-1)
      found = indices != -1
      ref_comp_values = data[ref_component][ref_field][indices[found]]
      invalid[found] = np.logical_or(invalid[found], values[found] == ref_comp_values)

Hi @wfjvdham ,

Thank you for reporting.

I will investigate and will get back to you as soon as I have an update.

Hi @wfjvdham ,

After a very quick investigation, I verified that this indeed a bug and your proposal is the right way to go to fix the issue (with some minor adjustments). Thank you for your clear and elaborate input. The fix is proposed in #670 .

We will merge this ASAP.

Cool! Thanks for the quick response

FYI @wfjvdham , the fix in #670 has been merged, but it may take up til an hour from now until CI finishes and v1.9.4 containing the fix is released.

  • If you are using PyPI, the release will be available using pip install or equivalent immediately after the release.
  • If you are using conda-forge, then it may take up to 18 hours before it becomes available if everything goes correctly.

Closely related follow-up found in #671 . A fix will be available in a couple hours (most likely v1.9.5)