Skip to content

Commit

Permalink
Merge pull request #41 from NREL/dss_python_0.10
Browse files Browse the repository at this point in the history
Migrate to DSS Python 0.10
  • Loading branch information
kdheepak authored Nov 19, 2018
2 parents 299e42e + 5e7685a commit 5af1e77
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 14 deletions.
13 changes: 10 additions & 3 deletions opendssdirect/Basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,16 @@ def Version():
return get_string(lib.DSS_Get_Version())


def AllowForms(value=None):
# warnings.warn('AllowForms is not implemented.')
return 1
def AllowForms(*args):
"""Gets/sets whether text output is allowed"""

# Getter
if len(args) == 0:
return lib.DSS_Get_AllowForms() != 0

# Setter
Value, = args
lib.DSS_Set_AllowForms(Value)


def ShowPanel():
Expand Down
10 changes: 5 additions & 5 deletions opendssdirect/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
# Import dss_python, exposing only OpenDSS v7 while v8 is still considered
# experimental (at least with Free Pascal)
import dss as dss_py
from dss._cffi_api_util import CffiApiUtil, codec
from dss.v7.dss_capi import CheckForError
import numpy as np
import warnings

# Bind to the FFI module instance
lib = dss_py._dss_capi_v7.lib
ffi = dss_py._dss_capi_v7.ffi
api_util = CffiApiUtil(ffi, lib)
lib = dss_py.v7.api_util.lib
ffi = dss_py.v7.api_util.ffi
api_util = dss_py.v7.api_util
codec = api_util.codec
CheckForError = dss_py.v7.DSS.CheckForError

# Currently, we prefer the functions that return lists (suffix 2)
# to keep higher compatibility with previous versions of OpenDSSDirect.py.
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# -*- coding: utf-8 -*-
__version__ = "0.3.4"
__version__ = "0.3.5"
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def run(self):
author_email="dheepak.krishnamurthy@nrel.gov",
license="BSD-compatible",
packages=find_packages(),
install_requires=["future", "six", "dss_python>=0.9.8"],
install_requires=["future", "six", "dss_python>=0.10.0"],
extras_require={
"extras": ["pandas", "matplotlib", "networkx"],
"dev": [
Expand Down Expand Up @@ -78,6 +78,7 @@ def run(self):
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
],
cmdclass={"develop": PostDevelopCommand},
)
21 changes: 17 additions & 4 deletions tests/test_opendssdirect.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,19 @@ def test_configuration():

import opendssdirect as dss

assert dss.Basic.AllowForms() == 1, "Allow forms should be disabled"
# Test toggling the console output using AllowForms.
# Note COM's AllowForms can only be disabled and it ignores
# the user's command to reallow forms if they were previously
# disabled.
assert dss.Basic.AllowForms() == False, "Allow forms should be disabled by default"

dss.Basic.AllowForms(True)
assert dss.Basic.AllowForms() == True

dss.Basic.AllowForms(False)
assert dss.Basic.AllowForms() == False



def test_13Node(dss):

Expand Down Expand Up @@ -227,7 +238,7 @@ def test_13Node(dss):

def test_13Node_Basic(dss):

assert dss.Basic.AllowForms() == 1
assert dss.Basic.AllowForms() == False
assert dss.Basic.Classes() == [
u"Solution",
u"LineCode",
Expand Down Expand Up @@ -268,6 +279,8 @@ def test_13Node_Basic(dss):
u"UPFCControl",
u"ESPVLControl",
u"IndMach012",
u"GICsource",
u"AutoTrans",
u"InvControl",
u"ExpControl",
u"GICLine",
Expand All @@ -277,10 +290,10 @@ def test_13Node_Basic(dss):
u"EnergyMeter",
u"Sensor",
]
assert dss.Basic.NumClasses() == 47
assert dss.Basic.NumClasses() == 49
assert dss.Basic.ShowPanel() == 0
assert dss.Basic.ClearAll() is None
assert os.path.abspath(dss.Basic.DataPath()) == os.path.abspath(".")
assert os.path.abspath(dss.Basic.DataPath()) == os.path.abspath("." + os.sep)
# assert dss.Basic.DefaultEditor() == u'open -t'
assert dss.Basic.NewCircuit("Circuit") == u"New Circuit"
assert dss.Basic.NumCircuits() == 1
Expand Down

0 comments on commit 5af1e77

Please sign in to comment.