Skip to content

Commit

Permalink
Merge pull request #96 from dss-extensions/kd/use-codec
Browse files Browse the repository at this point in the history
Use `codec` in `run_command`
  • Loading branch information
PMeira committed Mar 10, 2021
2 parents 9af3e5c + e75bbbd commit bb20ea7
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions opendssdirect/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import warnings

from ._utils import get_string, dss_py
from . import _utils

is_pandas_installed = True

Expand All @@ -23,12 +24,12 @@ def __init__(self, module, function):

def __iter__(self):
import opendssdirect as dss

try:
idx = self.module.First()
except:
return # no circuit?

if dss.Error.ExtendedErrors() and idx == 0:
return # nothing to iterate

Expand All @@ -47,7 +48,7 @@ def run_command(text, dss=None):

r = []
for l in text.splitlines():
dss.dss_lib.Text_Set_Command(l.encode("ascii"))
dss.dss_lib.Text_Set_Command(l.encode(_utils.codec))
r.append(get_string(dss.dss_lib.Text_Get_Result()))

return "\n".join(r).strip()
Expand Down Expand Up @@ -245,9 +246,9 @@ def monitor_to_dataframe(dss=None):
if dss.Solution.Mode() in (dss_py.enums.SolveModes.Harmonic, 17):
# Note: Mode 17 is HarmonicT but it was not exposed in the enum
# ported from COM as of 2021-01-03
columns = ['frequency', 'harmonic']
columns = ['frequency', 'harmonic']
else:
columns = ['hour', 'second']
columns = ['hour', 'second']

columns.extend(col.strip() for col in dss.Monitors.Header())
data = dss.Monitors.AsMatrix()
Expand Down

0 comments on commit bb20ea7

Please sign in to comment.