Skip to content

Commit 1871897

Browse files
authored
fix: temporary ignore raised 1.0 deprecations (PyPSA#1334)
1 parent 862ec8b commit 1871897

3 files changed

Lines changed: 36 additions & 34 deletions

File tree

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ include = ["pypsa"]
9898

9999
[tool.pytest.ini_options]
100100
filterwarnings = [
101-
"error::DeprecationWarning", # Raise all DeprecationWarnings as errors
101+
# Activate again with final 1.0 release
102+
# "error::DeprecationWarning", # Raise all DeprecationWarnings as errors
102103
# "error::FutureWarning", # Raise all FutureWarnings as errors # TODO Add again
103104
# "error:RuntimeWarning",
104105
# "error:UserWarning",

test/test_graph.py

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
Tests for the graph module
66
"""
77

8-
import warnings
9-
108
import pandas as pd
119
import scipy.sparse as sp
1210

@@ -174,34 +172,35 @@ def test_adjacency_matrix_deprecation_warning():
174172
n.add("Line", "line1", bus0="bus1", bus1="bus2")
175173

176174
# Check that calling without return_dataframe parameter raises FutureWarning
177-
with warnings.catch_warnings(record=True) as w:
178-
warnings.simplefilter("always")
179-
adj = n.adjacency_matrix()
175+
# TODO: Activate when warnings are raised again
176+
# with warnings.catch_warnings(record=True) as w:
177+
# warnings.simplefilter("always")
178+
# adj = n.adjacency_matrix()
180179

181-
# Check that a warning was raised
182-
assert len(w) == 1
183-
assert issubclass(w[0].category, FutureWarning)
184-
assert "adjacency_matrix will return a pandas DataFrame by default" in str(
185-
w[0].message
186-
)
180+
# # Check that a warning was raised
181+
# assert len(w) == 1
182+
# assert issubclass(w[0].category, FutureWarning)
183+
# assert "adjacency_matrix will return a pandas DataFrame by default" in str(
184+
# w[0].message
185+
# )
187186

188-
# Check that it still returns sparse matrix
189-
assert isinstance(adj, sp.coo_matrix)
187+
# # Check that it still returns sparse matrix
188+
# assert isinstance(adj, sp.coo_matrix)
190189

191190
# Check that calling with explicit return_dataframe=False doesn't raise warning
192-
with warnings.catch_warnings(record=True) as w:
193-
warnings.simplefilter("always")
194-
adj = n.adjacency_matrix(return_dataframe=False)
191+
# with warnings.catch_warnings(record=True) as w:
192+
# warnings.simplefilter("always")
193+
# adj = n.adjacency_matrix(return_dataframe=False)
195194

196-
# Check that no warning was raised
197-
assert len(w) == 0
198-
assert isinstance(adj, sp.coo_matrix)
195+
# # Check that no warning was raised
196+
# assert len(w) == 0
197+
# assert isinstance(adj, sp.coo_matrix)
199198

200199
# Check that calling with explicit return_dataframe=True doesn't raise warning
201-
with warnings.catch_warnings(record=True) as w:
202-
warnings.simplefilter("always")
203-
adj = n.adjacency_matrix(return_dataframe=True)
200+
# with warnings.catch_warnings(record=True) as w:
201+
# warnings.simplefilter("always")
202+
# adj = n.adjacency_matrix(return_dataframe=True)
204203

205-
# Check that no warning was raised
206-
assert len(w) == 0
207-
assert isinstance(adj, pd.DataFrame)
204+
# # Check that no warning was raised
205+
# assert len(w) == 0
206+
# assert isinstance(adj, pd.DataFrame)

test/test_network.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -582,15 +582,16 @@ def test_api_components_legacy(new_components_api):
582582
assert n.generators is n.components.generators.static
583583
assert n.c.generators.dynamic is n.components.generators.dynamic
584584
else:
585+
# TODO: Activate when warnings are raised again
585586
assert n.buses is n.components.buses
586-
with pytest.raises(DeprecationWarning):
587-
assert n.buses_t is n.components.buses.dynamic
587+
# with pytest.raises(DeprecationWarning):
588+
# assert n.buses_t is n.components.buses.dynamic
588589
assert n.lines is n.components.lines
589-
with pytest.raises(DeprecationWarning):
590-
assert n.lines_t is n.components.lines.dynamic
590+
# with pytest.raises(DeprecationWarning):
591+
# assert n.lines_t is n.components.lines.dynamic
591592
assert n.generators is n.components.generators
592-
with pytest.raises(DeprecationWarning):
593-
assert n.generators_t is n.components.generators.dynamic
593+
# with pytest.raises(DeprecationWarning):
594+
# assert n.generators_t is n.components.generators.dynamic
594595

595596

596597
@pytest.mark.parametrize("new_components_api", [True, False])
@@ -614,5 +615,6 @@ def test_api_new_components_api(component_name, new_components_api):
614615
assert n.dynamic(component_name) is n.c[component_name].dynamic
615616
with pytest.raises(AttributeError):
616617
setattr(n, component_name, "test")
617-
with pytest.raises(DeprecationWarning):
618-
setattr(n, f"{component_name}_t", "test")
618+
# TODO: Activate when warnings are raised again
619+
# with pytest.raises(DeprecationWarning):
620+
# setattr(n, f"{component_name}_t", "test")

0 commit comments

Comments
 (0)