-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Describe the bug
Before v1.4.7 we could do the following
from power_grid_model_ds import Grid
from power_grid_model_ds.arrays import NodeArray
grid = Grid.empty()
nodes = NodeArray.empty(2)
grid.attach_ids(nodes)
grid.append(nodes)
But after the merge of #92 this raises an error:
ValueError: Cannot append: minimum id 1 is not greater than the current id counter 2
Cause
The attach_ids already updates the internal counter, this is sensible on the one hand since this allows you to do something like:
grid = Grid.empty()
nodes = NodeArray.empty(1)
lines = LineArray.empty(1)
grid.attach_ids(nodes)
grid.attach_ids(lines)
where the node will have id 1 and the line will have id 2.
However it blocks the example given above.
Solution
The change in 1.4.7 was a breaking change for our code, since we used the flow as described.
Personally I view the described flow that now breaks as a valid one. We use it so that we know what the id will be of a certain index of the array that we add to the grid. This seems like a useful thing to have.
The solutions I see for now:
- If you want the flow described, you need to set
check_max_idstoFalse(our current fix). - We do no longer update the internal counter within
attach_ids. This breaks the flow in the Cause section. - The append returns a list of
idsthat match their index. Removing the need forattach_ids
Metadata
Metadata
Assignees
Labels
Type
Projects
Status