|
3 | 3 | # SPDX-License-Identifier: MPL-2.0 |
4 | 4 |
|
5 | 5 | import json |
| 6 | +import warnings |
6 | 7 | from functools import lru_cache |
7 | 8 | from pathlib import Path |
8 | 9 | from typing import List, Tuple |
9 | 10 |
|
| 11 | +import numpy as np |
10 | 12 | import pandas as pd |
11 | 13 | import pytest |
12 | 14 | from power_grid_model import ComponentType, DatasetType |
@@ -118,14 +120,17 @@ def test_extra_info__serializable(extra_info): |
118 | 120 | json.dumps(actual, cls=JsonEncoder) # expect no exception |
119 | 121 |
|
120 | 122 |
|
121 | | -@pytest.mark.filterwarnings("error:.*invalid value encountered in divide.*:RuntimeWarning") |
122 | 123 | def test_pgm_input_lines__cnf_zero(): |
123 | | - pp_network = pp_net_3ph_minimal_trafo() |
124 | | - pp_converter = PandaPowerConverter() |
125 | | - pp_network.line.c_nf_per_km = 0 |
126 | | - data, _ = pp_converter.load_input_data(pp_network) |
127 | | - assert data[ComponentType.line]["tan1"] == 0 |
128 | | - pp_network.line.c_nf_per_km = 0.001 |
129 | | - pp_network.line.c0_nf_per_km = 0 |
130 | | - data, _ = pp_converter.load_input_data(pp_network) |
131 | | - assert data[ComponentType.line]["tan0"] == 0 |
| 124 | + with warnings.catch_warnings(): |
| 125 | + warnings.simplefilter("error") |
| 126 | + |
| 127 | + pp_network = pp_net_3ph_minimal_trafo() |
| 128 | + pp_converter = PandaPowerConverter() |
| 129 | + pp_network.line.c_nf_per_km = 0 |
| 130 | + data, _ = pp_converter.load_input_data(pp_network) |
| 131 | + np.testing.assert_array_equal(data[ComponentType.line]["tan1"], 0) |
| 132 | + |
| 133 | + pp_network.line.c_nf_per_km = 0.001 |
| 134 | + pp_network.line.c0_nf_per_km = 0 |
| 135 | + data, _ = pp_converter.load_input_data(pp_network) |
| 136 | + np.testing.assert_array_equal(data[ComponentType.line]["tan0"], 0) |
0 commit comments