Skip to content

Commit a30f40e

Browse files
committed
Upgrade to DSS Python 0.10.7:
- Update tests - Drop Python 2.7, add Python 3.9 -- due to this, updated version to 0.6.0 - Pin dss_python==0.10.7
1 parent 7123a67 commit a30f40e

File tree

9 files changed

+99
-59
lines changed

9 files changed

+99
-59
lines changed

.appveyor.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ build: false
55

66
environment:
77
matrix:
8+
- PYTHON_VERSION: 3.9
9+
TARGET_ARCH: "x64"
10+
MINICONDA: C:\Miniconda3-x64
811
- PYTHON_VERSION: 3.8
912
TARGET_ARCH: "x64"
1013
MINICONDA: C:\Miniconda3-x64
@@ -17,9 +20,9 @@ environment:
1720
- PYTHON_VERSION: 3.5
1821
TARGET_ARCH: "x64"
1922
MINICONDA: C:\Miniconda3-x64
20-
- PYTHON_VERSION: 2.7
21-
TARGET_ARCH: "x64"
22-
MINICONDA: C:\Miniconda-x64
23+
- PYTHON_VERSION: 3.9
24+
TARGET_ARCH: "x86"
25+
MINICONDA: C:\Miniconda3
2326
- PYTHON_VERSION: 3.8
2427
TARGET_ARCH: "x86"
2528
MINICONDA: C:\Miniconda3
@@ -32,9 +35,6 @@ environment:
3235
- PYTHON_VERSION: 3.5
3336
TARGET_ARCH: "x86"
3437
MINICONDA: C:\Miniconda3
35-
- PYTHON_VERSION: 2.7
36-
TARGET_ARCH: "x86"
37-
MINICONDA: C:\Miniconda
3838

3939
install:
4040
- "set PATH=%MINICONDA%;%MINICONDA%\\Scripts;%PATH%"
@@ -43,8 +43,6 @@ install:
4343
- conda info -a
4444
- "conda create -q -n test-environment python=%PYTHON_VERSION% pandas matplotlib pytest"
4545
- activate test-environment
46-
- pip install cffi
47-
- pip install --pre dss-python
4846
- pip install -e .[extras]
4947

5048
test_script:

.travis.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ matrix:
44
allow_failures:
55
- os: osx
66
include:
7+
- os: linux
8+
env: TRAVIS_PYTHON_VERSION="3.9"
79
- os: linux
810
env: TRAVIS_PYTHON_VERSION="3.8"
911
- os: linux
@@ -12,8 +14,8 @@ matrix:
1214
env: TRAVIS_PYTHON_VERSION="3.6"
1315
- os: linux
1416
env: TRAVIS_PYTHON_VERSION="3.5"
15-
- os: linux
16-
env: TRAVIS_PYTHON_VERSION="2.7"
17+
- os: osx
18+
env: TRAVIS_PYTHON_VERSION="3.9"
1719
- os: osx
1820
env: TRAVIS_PYTHON_VERSION="3.8"
1921
- os: osx
@@ -22,8 +24,6 @@ matrix:
2224
env: TRAVIS_PYTHON_VERSION="3.6"
2325
- os: osx
2426
env: TRAVIS_PYTHON_VERSION="3.5"
25-
- os: osx
26-
env: TRAVIS_PYTHON_VERSION="2.7"
2727
install:
2828
# Install conda
2929
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
@@ -41,8 +41,6 @@ install:
4141
- source activate test-env
4242
- pip install pytest-cov
4343
- pip install codecov
44-
- pip install cffi
45-
- pip install --pre dss-python
4644
- pip install -e '.[extras]'
4745
script:
4846
- make

opendssdirect/Bus.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,16 @@ def LineList():
190190
return CheckForError(get_string_array(lib.Bus_Get_LineList))
191191

192192

193+
def AllPCEatBus():
194+
"""Returns an array with the names of all PCE connected to the active bus"""
195+
return CheckForError(get_string_array(lib.Bus_Get_AllPCEatBus))
196+
197+
198+
def AllPDEatBus():
199+
"""Returns an array with the names of all PDE connected to the active bus"""
200+
return CheckForError(get_string_array(lib.Bus_Get_AllPDEatBus))
201+
202+
193203
_columns = [
194204
"Coorddefined",
195205
"CplxSeqVoltages",
@@ -223,6 +233,8 @@ def LineList():
223233
"Y",
224234
]
225235
__all__ = [
236+
"AllPCEatBus",
237+
"AllPDEatBus",
226238
"GetUniqueNodeNumber",
227239
"ZscRefresh",
228240
"Coorddefined",

opendssdirect/CktElement.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,11 @@ def SeqVoltages():
278278
return get_float64_array(lib.CktElement_Get_SeqVoltages)
279279

280280

281+
def TotalPowers():
282+
"""Returns the total powers (complex) at ALL terminals of the active circuit element."""
283+
return get_float64_array(lib.CktElement_Get_TotalPowers)
284+
285+
281286
def Voltages():
282287
"""(read-only) Complex array of voltages at terminals"""
283288
return get_float64_array(lib.CktElement_Get_Voltages)
@@ -333,6 +338,7 @@ def IsIsolated():
333338
"SeqCurrents",
334339
"SeqPowers",
335340
"SeqVoltages",
341+
"TotalPowers",
336342
"Voltages",
337343
"VoltagesMagAng",
338344
"YPrim",
@@ -341,6 +347,7 @@ def IsIsolated():
341347
"AllVariableValues",
342348
"AllVariableNames",
343349
]
350+
344351
__all__ = [
345352
"Close",
346353
"Controller",
@@ -382,6 +389,7 @@ def IsIsolated():
382389
"SeqCurrents",
383390
"SeqPowers",
384391
"SeqVoltages",
392+
"TotalPowers",
385393
"Voltages",
386394
"VoltagesMagAng",
387395
"YPrim",

opendssdirect/Meters.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,10 @@ def Totals():
271271
"""(read-only) Totals of all registers of all meters"""
272272
return get_float64_array(lib.Meters_Get_Totals)
273273

274+
def ZonePCE():
275+
"""Returns the list of all PCE within the area covered by the energy meter"""
276+
return CheckForError(get_string_array(lib.Meters_Get_ZonePCE))
277+
274278

275279
def Idx(*args):
276280
"""
@@ -361,5 +365,6 @@ def Idx(*args):
361365
"SumBranchFltRates",
362366
"TotalCustomers",
363367
"Totals",
368+
"ZonePCE",
364369
"Idx",
365370
]

opendssdirect/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# -*- coding: utf-8 -*-
2-
__version__ = "0.5.0"
2+
__version__ = "0.6.0"

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def run(self):
4646
author_email="[email protected]",
4747
license="BSD-compatible",
4848
packages=find_packages(),
49-
install_requires=["future", "six", "dss_python>=0.10.6,<0.11"],
49+
install_requires=["future", "six", "dss_python==0.10.7"],
5050
extras_require={
5151
"extras": ["pandas", "matplotlib", "networkx"],
5252
"dev": [
@@ -76,11 +76,11 @@ def run(self):
7676
"License :: Other/Proprietary License",
7777
# Specify the Python versions you support here. In particular, ensure
7878
# that you indicate whether you support Python 2, Python 3 or both.
79-
"Programming Language :: Python :: 2.7",
8079
"Programming Language :: Python :: 3.5",
8180
"Programming Language :: Python :: 3.6",
8281
"Programming Language :: Python :: 3.7",
8382
"Programming Language :: Python :: 3.8",
83+
"Programming Language :: Python :: 3.9",
8484
],
8585
cmdclass={"develop": PostDevelopCommand},
8686
)

tests/test_opendssdirect.py

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,13 @@ def test_13Node_Bus(dss):
430430

431431
# TODO: this should not be sorted, we should define the order of the results
432432
assert sorted(dss.YMatrix.getV()[2:]) == sorted(dss.Circuit.AllBusVolts())
433+
434+
assert dss.Bus.AllPDEatBus() == ["Transformer.sub"]
435+
assert dss.Bus.AllPCEatBus() == ["Vsource.source"]
436+
437+
dss.Circuit.SetActiveBus("684")
438+
assert dss.Bus.AllPDEatBus() == ['Line.671684', 'Line.684611', 'Line.684652']
439+
assert dss.Bus.AllPCEatBus() == []
433440

434441

435442
def test_13Node_Circuit(dss):
@@ -1159,6 +1166,7 @@ def test_13Node_CktElement(dss):
11591166
u"B0",
11601167
u"Seasons",
11611168
u"Ratings",
1169+
u"LineType",
11621170
u"normamps",
11631171
u"emergamps",
11641172
u"faultrate",
@@ -1263,11 +1271,16 @@ def test_13Node_CktElement(dss):
12631271
)
12641272
assert dss.CktElement.Name() == u"Line.671692"
12651273
assert dss.CktElement.NodeOrder() == [1, 2, 3, 1, 2, 3]
1274+
np.testing.assert_almost_equal(
1275+
dss.CktElement.TotalPowers(),
1276+
[1013.9070515856262, 19.023976609590814, -1013.9070425310053, -19.023976609590783],
1277+
decimal=5,
1278+
)
12661279
assert dss.CktElement.NormalAmps() == 400.0
12671280
assert dss.CktElement.NumConductors() == 3
12681281
assert dss.CktElement.NumControls() == 0
12691282
assert dss.CktElement.NumPhases() == 3
1270-
assert dss.CktElement.NumProperties() == 37
1283+
assert dss.CktElement.NumProperties() == 38
12711284
assert dss.CktElement.NumTerminals() == 2
12721285
assert dss.CktElement.OCPDevIndex() == 0
12731286
assert dss.CktElement.OCPDevType() == 0
@@ -1584,6 +1597,7 @@ def test_13Node_Element(dss):
15841597
u"B0",
15851598
u"Seasons",
15861599
u"Ratings",
1600+
u"LineType",
15871601
u"normamps",
15881602
u"emergamps",
15891603
u"faultrate",
@@ -1594,7 +1608,7 @@ def test_13Node_Element(dss):
15941608
u"like",
15951609
]
15961610
assert dss.Element.Name() == u"Line.671692"
1597-
assert dss.Element.NumProperties() == 37
1611+
assert dss.Element.NumProperties() == 38
15981612

15991613

16001614
def test_13Node_Executive(dss):
@@ -1604,8 +1618,8 @@ def test_13Node_Executive(dss):
16041618
== u"Create a new object within the DSS. Object becomes the active object\nExample: New Line.line1 ..."
16051619
)
16061620
assert (
1607-
dss.Executive.NumCommands() == 114
1608-
) # adjusted to the latest version on 2020-07-28
1621+
dss.Executive.NumCommands() == 118
1622+
) # adjusted to the latest version on 2020-12-28
16091623
assert (
16101624
dss.Executive.NumOptions() == 115
16111625
) # adjusted to the latest version on 2020-07-28
@@ -1937,6 +1951,7 @@ def test_13Node_Meters(dss):
19371951
assert dss.Meters.AllNames() == []
19381952
assert dss.Meters.SampleAll() is None
19391953
assert dss.Meters.SaveAll() is None
1954+
assert dss.Meters.ZonePCE() == []
19401955

19411956

19421957
def test_13Node_Monitors(dss):
@@ -4774,7 +4789,7 @@ def test_storage_to_dataframe(dss):
47744789
"duty": {"Storage.631": ""},
47754790
"enabled": {"Storage.631": True},
47764791
"kVA": {"Storage.631": "25"},
4777-
"kW": {"Storage.631": "-0.25"},
4792+
"kW": {"Storage.631": "0"},
47784793
"kWhrated": {"Storage.631": "50"},
47794794
"kWhstored": {"Storage.631": "50"},
47804795
"kWrated": {"Storage.631": "25"},
@@ -4838,6 +4853,7 @@ def test_linegeometry_class_to_dataframe():
48384853
"linegeometry.hc2_336_1neut_0mess": {
48394854
"Seasons": "1",
48404855
"Ratings": ["0"],
4856+
"LineType": "ug",
48414857
"nconds": "4",
48424858
"nphases": "3",
48434859
"cond": "4",
@@ -5672,35 +5688,35 @@ def test_wiredata_class_to_dataframe():
56725688

56735689
assert data == {
56745690
"wiredata.acsr1/0": {
5675-
"Capradius": "-1",
5691+
"Capradius": "0.199",
56765692
"Seasons": "1",
56775693
"Ratings": ["-1"],
5678-
"GMRac": "0.0044600",
5694+
"GMRac": "0.00446",
56795695
"GMRunits": "ft",
5680-
"Rac": "1.120000",
5681-
"Rdc": "-1",
5696+
"Rac": "1.12",
5697+
"Rdc": "1.09804",
56825698
"Runits": "mi",
5683-
"diam": "0.3980000",
5684-
"emergamps": "-1",
5699+
"diam": "0.398",
5700+
"emergamps": "345",
56855701
"like": "",
5686-
"normamps": "230.0000",
5687-
"radius": "-1",
5702+
"normamps": "230",
5703+
"radius": "0.199",
56885704
"radunits": "in",
56895705
},
56905706
"wiredata.acsr336": {
5691-
"Capradius": "-1",
5707+
"Capradius": "0.3705",
56925708
"Seasons": "1",
56935709
"Ratings": ["-1"],
5694-
"GMRac": "0.0255000",
5710+
"GMRac": "0.0255",
56955711
"GMRunits": "ft",
5696-
"Rac": "0.3060000",
5697-
"Rdc": "-1",
5712+
"Rac": "0.306",
5713+
"Rdc": "0.3",
56985714
"Runits": "mi",
5699-
"diam": "0.7410000",
5700-
"emergamps": "-1",
5715+
"diam": "0.741",
5716+
"emergamps": "795",
57015717
"like": "",
5702-
"normamps": "530.0000",
5703-
"radius": "-1",
5718+
"normamps": "530",
5719+
"radius": "0.3705",
57045720
"radunits": "in",
57055721
},
57065722
}

0 commit comments

Comments
 (0)