Skip to content

Commit

Permalink
Clean up imports
Browse files Browse the repository at this point in the history
  • Loading branch information
PMeira committed Jul 16, 2022
1 parent 4df844f commit 4bb762e
Show file tree
Hide file tree
Showing 47 changed files with 56 additions and 70 deletions.
2 changes: 1 addition & 1 deletion opendssdirect/ActiveClass.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._utils import codec, CheckForError, api_util, Base
from ._utils import api_util, Base


class IActiveClass(Base):
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/Basic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._utils import codec, api_util, Base
from ._utils import api_util, Base


class IBasic(Base):
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/Bus.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._utils import CheckForError, api_util, Base
from ._utils import api_util, Base


class IBus(Base):
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/CNData.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._utils import CheckForError, api_util, Iterable
from ._utils import api_util, Iterable


class ICNData(Iterable):
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/CapControls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._utils import codec, CheckForError, api_util, Iterable
from ._utils import api_util, Iterable


class ICapControls(Iterable):
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/Capacitors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._utils import CheckForError, api_util, Iterable
from ._utils import api_util, Iterable


class ICapacitors(Iterable):
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/Circuit.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._utils import codec, CheckForError, api_util, Base
from ._utils import api_util, Base


class ICircuit(Base):
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/CktElement.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._utils import ffi, codec, DSSException, api_util, Base
from ._utils import DSSException, api_util, Base


class ICktElement(Base):
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/CtrlQueue.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._utils import CheckForError, api_util, Base
from ._utils import api_util, Base


class ICtrlQueue(Base):
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/Element.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._utils import CheckForError, api_util, Base
from ._utils import api_util, Base


class IElement(Base):
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/Executive.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._utils import CheckForError, api_util, Base
from ._utils import api_util, Base


class IExecutive(Base):
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/Fuses.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._utils import codec, CheckForError, api_util, Iterable
from ._utils import api_util, Iterable


class IFuses(Iterable):
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/Generators.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._utils import codec, CheckForError, api_util, Iterable
from ._utils import api_util, Iterable


class IGenerators(Iterable):
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/Isource.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._utils import CheckForError, api_util, Iterable
from ._utils import api_util, Iterable


class IIsource(Iterable):
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/LineCodes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._utils import CheckForError, api_util, Iterable
from ._utils import api_util, Iterable


class ILineCodes(Iterable):
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/LineGeometries.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._utils import CheckForError, api_util, Iterable
from ._utils import api_util, Iterable


class ILineGeometries(Iterable):
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/LineSpacings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._utils import CheckForError, api_util, Iterable
from ._utils import api_util, Iterable


class ILineSpacings(Iterable):
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/Lines.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._utils import codec, CheckForError, api_util, Iterable
from ._utils import api_util, Iterable


class ILines(Iterable):
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/LoadShape.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._utils import codec, CheckForError, api_util, Iterable
from ._utils import api_util, Iterable


class ILoadShape(Iterable):
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/Loads.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._utils import codec, CheckForError, api_util, Iterable
from ._utils import api_util, Iterable


class ILoads(Iterable):
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/Meters.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._utils import codec, CheckForError, api_util, Iterable
from ._utils import api_util, Iterable


class IMeters(Iterable):
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/PDElements.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._utils import codec, CheckForError, api_util, Base
from ._utils import api_util, Base


class IPDElements(Base):
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/PVsystems.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._utils import codec, CheckForError, api_util, Iterable
from ._utils import api_util, Iterable


class IPVsystems(Iterable):
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/Parallel.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._utils import CheckForError, api_util, Base
from ._utils import api_util, Base


class IParallel(Base):
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/Parser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._utils import codec, CheckForError, api_util, Base
from ._utils import api_util, Base


class IParser(Base):
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/Progress.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._utils import codec, CheckForError, api_util, Base
from ._utils import api_util, Base


class IProgress(Base):
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/Reactors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._utils import codec, CheckForError, api_util, Iterable
from ._utils import api_util, Iterable


class IReactors(Iterable):
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/Reclosers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._utils import codec, CheckForError, api_util, Iterable
from ._utils import api_util, Iterable


class IReclosers(Iterable):
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/ReduceCkt.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._utils import codec, CheckForError, api_util, Base
from ._utils import api_util, Base


class IReduceCkt(Base):
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/RegControls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._utils import codec, CheckForError, api_util, Iterable
from ._utils import api_util, Iterable


class IRegControls(Iterable):
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/Relays.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._utils import codec, CheckForError, api_util, Iterable
from ._utils import api_util, Iterable


class IRelays(Iterable):
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/Sensors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._utils import codec, CheckForError, api_util, Iterable
from ._utils import api_util, Iterable


class ISensors(Iterable):
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/Settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._utils import codec, CheckForError, api_util, Base
from ._utils import api_util, Base


class ISettings(Base):
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/Solution.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._utils import codec, CheckForError, api_util, Base
from ._utils import api_util, Base


class ISolution(Base):
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/Storages.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._utils import CheckForError, api_util, Iterable
from ._utils import api_util, Iterable


class IStorages(Iterable):
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/SwtControls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._utils import codec, CheckForError, api_util, Iterable
from ._utils import api_util, Iterable


class ISwtControls(Iterable):
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/TSData.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._utils import CheckForError, api_util, Iterable
from ._utils import api_util, Iterable


class ITSData(Iterable):
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/Text.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._utils import codec, CheckForError, api_util, Base
from ._utils import api_util, Base


class IText(Base):
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/Topology.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._utils import codec, CheckForError, api_util, Base
from ._utils import api_util, Base


class ITopology(Base):
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/Transformers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._utils import codec, CheckForError, api_util, Iterable
from ._utils import api_util, Iterable


class ITransformers(Iterable):
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/Vsources.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._utils import CheckForError, api_util, Iterable
from ._utils import api_util, Iterable


class IVsources(Iterable):
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/WireData.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._utils import CheckForError, api_util, Iterable
from ._utils import api_util, Iterable


class IWireData(Iterable):
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/XYCurves.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._utils import CheckForError, api_util, Iterable
from ._utils import api_util, Iterable


class IXYCurves(Iterable):
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/YMatrix.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import numpy as np
from ._utils import ffi, CheckForError, api_util, Base
from ._utils import api_util, Base


class IYMatrix(Base):
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/ZIP.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._utils import ffi, api_util, codec, CheckForError, api_util, Base
from ._utils import api_util, Base


class IZIP(Base):
Expand Down
25 changes: 4 additions & 21 deletions opendssdirect/_utils.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,9 @@
# Import dss_python
import dss as dss_py
import numpy as np
import warnings
from .Iterable import Iterable, Base

# Bind to the FFI module instance. This should be refined in a future version,
# especially after DSS C-API 0.11 is fully released.
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_IR.CheckForError
# Bind to the FFI module instance and default/prime OpenDSS instance
lib = dss_py.api_util.lib
ffi = dss_py.api_util.ffi
api_util = dss_py.api_util
DSSException = dss_py._cffi_api_util.DSSException

# Currently, we prefer the functions that return lists (suffix 2)
# to keep higher compatibility with previous versions of OpenDSSDirect.py.

get_string = api_util.get_string
get_float64_array = api_util.get_float64_array2
get_int32_array = api_util.get_int32_array2
get_int8_array = api_util.get_int8_array2
get_string_array = api_util.get_string_array2
prepare_float64_array = api_util.prepare_float64_array
prepare_int32_array = api_util.prepare_int32_array
prepare_string_array = api_util.prepare_string_array
11 changes: 7 additions & 4 deletions opendssdirect/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import inspect
import warnings
from ._utils import get_string, dss_py
from . import _utils
from ._utils import dss_py
from .Iterable import Iterable

is_pandas_installed = True
Expand Down Expand Up @@ -41,13 +40,17 @@ def __iter__(self):

def run_command(text, dss=None):
"""Use Text interface of OpenDSS"""

warnings.warn('run_command is deprecated, see https://github.com/dss-extensions/OpenDSSDirect.py/issues/70')

if dss is None:
import opendssdirect as dss

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

return "\n".join(r).strip()

Expand Down

0 comments on commit 4bb762e

Please sign in to comment.