66
77import numpy as np
88import pytest
9- from power_grid_model import initialize_array
10- from power_grid_model .validation import validate_batch_data
9+
10+ from power_grid_model import CalculationType , LoadGenType , initialize_array
11+ from power_grid_model .validation import validate_batch_data , validate_input_data
1112from power_grid_model .validation .errors import MultiComponentNotUniqueError , NotBooleanError
1213
1314
@@ -28,15 +29,34 @@ def input_data() -> Dict[str, np.ndarray]:
2829 line ["c1" ] = 3.0
2930 line ["tan1" ] = 4.0
3031 line ["i_n" ] = 5.0
31- return {"node" : node , "line" : line }
32+
33+ asym_load = initialize_array ("input" , "asym_load" , 2 )
34+ asym_load ["id" ] = [9 , 10 ]
35+ asym_load ["node" ] = [1 , 2 ]
36+ asym_load ["status" ] = [1 , 1 ]
37+ asym_load ["type" ] = [LoadGenType .const_power , LoadGenType .const_power ]
38+ asym_load ["p_specified" ] = [[11e6 , 12e6 , 13e6 ], [21e6 , 22e6 , 23e6 ]]
39+ asym_load ["q_specified" ] = [[11e5 , 12e5 , 13e5 ], [21e5 , 22e5 , 23e5 ]]
40+
41+ return {"node" : node , "line" : line , "asym_load" : asym_load }
3242
3343
3444@pytest .fixture
3545def batch_data () -> Dict [str , np .ndarray ]:
3646 line = initialize_array ("update" , "line" , (3 , 2 ))
3747 line ["id" ] = [[5 , 6 ], [6 , 7 ], [7 , 5 ]]
3848 line ["from_status" ] = [[1 , 1 ], [1 , 1 ], [1 , 1 ]]
39- return {"line" : line }
49+
50+ # Add batch for asym_load, which has 2-D array for p_specified
51+ asym_load = initialize_array ("update" , "asym_load" , (3 , 2 ))
52+ asym_load ["id" ] = [[9 , 10 ], [9 , 10 ], [9 , 10 ]]
53+
54+ return {"line" : line , "asym_load" : asym_load }
55+
56+
57+ def test_validate_batch_data (input_data , batch_data ):
58+ errors = validate_batch_data (input_data , batch_data )
59+ assert not errors
4060
4161
4262def test_validate_batch_data_input_error (input_data , batch_data ):
0 commit comments