Skip to content

Commit 991eef5

Browse files
committed
Merge branch 'release/v2.14.6'
2 parents d6f0d93 + 64c5a94 commit 991eef5

File tree

5 files changed

+17
-25
lines changed

5 files changed

+17
-25
lines changed

CHANGELOG.rst

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ Change Log
44
[upcoming release] - 2024-..-..
55
-------------------------------
66

7+
[2.14.6] - 2024-04-02
8+
-------------------------------
9+
- [FIXED] more futurewarnings and deprecation warnings
10+
711
[2.14.5] - 2024-03-28
812
-------------------------------
913
- [CHANGED] added possibility to provide custom weights to switches and transformers (before - always zero) when creating a graph

pandapower/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version__ = "2.14.0"
1+
__version__ = "2.14.6"
22
__format_version__ = "2.14.0"

pandapower/file_io.py

+8-23
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import numpy
1313
import pandas as pd
1414
from packaging.version import Version
15-
from packaging import version
1615
import sys
1716
try:
1817
import xlsxwriter
@@ -25,6 +24,7 @@
2524
except ImportError:
2625
openpyxl_INSTALLED = False
2726

27+
from pandapower._version import __version__ as pp_version
2828
from pandapower.auxiliary import soft_dependency_error, _preserve_dtypes
2929
from pandapower.auxiliary import pandapowerNet
3030
from pandapower.std_types import basic_std_types
@@ -101,7 +101,7 @@ def to_excel(net, filename, include_empty_tables=False, include_results=True):
101101
writer._save()
102102

103103

104-
def to_json(net, filename=None, encryption_key=None, store_index_names=False):
104+
def to_json(net, filename=None, encryption_key=None, store_index_names=None):
105105
"""
106106
Saves a pandapower Network in JSON format. The index columns of all pandas DataFrames will
107107
be saved in ascending order. net elements which name begins with "_" (internal elements)
@@ -116,38 +116,23 @@ def to_json(net, filename=None, encryption_key=None, store_index_names=False):
116116
**encrytion_key** (string, None) - If given, the pandapower network is stored as an
117117
encrypted json string
118118
119-
**store_index_names** (bool, False) - If True, an additional dict "index_names" is
120-
stored into the json string which includes the index names of the dataframes within the
121-
net.
122-
Since pandapower does usually not use net[elm].index.name, the default is False.
123-
124-
125119
EXAMPLE:
126120
127121
>>> pp.to_json(net, "example.json")
128122
129123
"""
130124
# --- store index names
131-
if store_index_names:
132-
# To ensure correct index names (see https://github.com/e2nIEE/pandapower/issues/1410),
133-
# these are additionally stored to the json file as a dict.
134-
if "index_names" in net.keys():
135-
raise ValueError("To store DataFrame index names, 'index_names' "
136-
"is used and thus should not be a key of net.")
137-
net["index_names"] = {
138-
key: net[key].index.name for key in net.keys() if isinstance(
139-
net[key], pd.DataFrame) and isinstance(net[key].index.name, str) and \
140-
net[key].index.name != ""
141-
}
125+
if store_index_names is not None:
126+
msg = "The input parameter 'store_index_names' of function 'to_json()' is deprecated."
127+
if Version(pp_version) < Version("2.15"):
128+
warn(msg)
129+
else:
130+
raise DeprecationWarning(msg)
142131

143132
json_string = json.dumps(net, cls=io_utils.PPJSONEncoder, indent=2)
144133
if encryption_key is not None:
145134
json_string = io_utils.encrypt_string(json_string, encryption_key)
146135

147-
if store_index_names:
148-
# remove the key "index_names" to not change net
149-
del net["index_names"]
150-
151136
if filename is None:
152137
return json_string
153138

pandapower/io_utils.py

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import json
99
import numbers
1010
import os
11+
import io
1112
import sys
1213
import types
1314
import weakref
@@ -514,6 +515,8 @@ def DataFrame(self):
514515
column_names = self.d.pop('column_names', None)
515516

516517
obj = self.obj
518+
if type(obj) == str and (not os.path.isabs(obj) or not obj.endswith('.json')):
519+
obj = io.StringIO(obj)
517520

518521
df = pd.read_json(obj, precise_float=True, convert_axes=False, **self.d)
519522

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
setup(
3636
name='pandapower',
37-
version='2.14.5',
37+
version='2.14.6',
3838
author='Leon Thurner, Alexander Scheidler',
3939
4040
description='An easy to use open source tool for power system modeling, analysis and optimization with a high degree of automation.',

0 commit comments

Comments
 (0)