Skip to content

Commit

Permalink
Merge branch 'release/v2.14.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
vogt31337 committed Apr 2, 2024
2 parents d6f0d93 + 64c5a94 commit 991eef5
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 25 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Change Log
[upcoming release] - 2024-..-..
-------------------------------

[2.14.6] - 2024-04-02
-------------------------------
- [FIXED] more futurewarnings and deprecation warnings

[2.14.5] - 2024-03-28
-------------------------------
- [CHANGED] added possibility to provide custom weights to switches and transformers (before - always zero) when creating a graph
Expand Down
2 changes: 1 addition & 1 deletion pandapower/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = "2.14.0"
__version__ = "2.14.6"
__format_version__ = "2.14.0"
31 changes: 8 additions & 23 deletions pandapower/file_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import numpy
import pandas as pd
from packaging.version import Version
from packaging import version
import sys
try:
import xlsxwriter
Expand All @@ -25,6 +24,7 @@
except ImportError:
openpyxl_INSTALLED = False

from pandapower._version import __version__ as pp_version
from pandapower.auxiliary import soft_dependency_error, _preserve_dtypes
from pandapower.auxiliary import pandapowerNet
from pandapower.std_types import basic_std_types
Expand Down Expand Up @@ -101,7 +101,7 @@ def to_excel(net, filename, include_empty_tables=False, include_results=True):
writer._save()


def to_json(net, filename=None, encryption_key=None, store_index_names=False):
def to_json(net, filename=None, encryption_key=None, store_index_names=None):
"""
Saves a pandapower Network in JSON format. The index columns of all pandas DataFrames will
be saved in ascending order. net elements which name begins with "_" (internal elements)
Expand All @@ -116,38 +116,23 @@ def to_json(net, filename=None, encryption_key=None, store_index_names=False):
**encrytion_key** (string, None) - If given, the pandapower network is stored as an
encrypted json string
**store_index_names** (bool, False) - If True, an additional dict "index_names" is
stored into the json string which includes the index names of the dataframes within the
net.
Since pandapower does usually not use net[elm].index.name, the default is False.
EXAMPLE:
>>> pp.to_json(net, "example.json")
"""
# --- store index names
if store_index_names:
# To ensure correct index names (see https://github.com/e2nIEE/pandapower/issues/1410),
# these are additionally stored to the json file as a dict.
if "index_names" in net.keys():
raise ValueError("To store DataFrame index names, 'index_names' "
"is used and thus should not be a key of net.")
net["index_names"] = {
key: net[key].index.name for key in net.keys() if isinstance(
net[key], pd.DataFrame) and isinstance(net[key].index.name, str) and \
net[key].index.name != ""
}
if store_index_names is not None:
msg = "The input parameter 'store_index_names' of function 'to_json()' is deprecated."
if Version(pp_version) < Version("2.15"):
warn(msg)
else:
raise DeprecationWarning(msg)

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

if store_index_names:
# remove the key "index_names" to not change net
del net["index_names"]

if filename is None:
return json_string

Expand Down
3 changes: 3 additions & 0 deletions pandapower/io_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import json
import numbers
import os
import io
import sys
import types
import weakref
Expand Down Expand Up @@ -514,6 +515,8 @@ def DataFrame(self):
column_names = self.d.pop('column_names', None)

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

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

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

setup(
name='pandapower',
version='2.14.5',
version='2.14.6',
author='Leon Thurner, Alexander Scheidler',
author_email='[email protected], [email protected]',
description='An easy to use open source tool for power system modeling, analysis and optimization with a high degree of automation.',
Expand Down

0 comments on commit 991eef5

Please sign in to comment.