Skip to content

Commit 4736b8e

Browse files
authored
Merge pull request PauloRadatz#48 from eniovianna/master
Minor refactor
2 parents 234dc1c + e7b790a commit 4736b8e

23 files changed

+262
-249
lines changed

setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ def read(*names, **kwargs):
5757
'Programming Language :: Python :: 3.6',
5858
'Programming Language :: Python :: 3.7',
5959
'Programming Language :: Python :: 3.8',
60+
'Programming Language :: Python :: 3.9',
61+
'Programming Language :: Python :: 3.10',
6062
'Programming Language :: Python :: Implementation :: CPython',
6163
'Programming Language :: Python :: Implementation :: PyPy',
6264
'Topic :: Utilities',

src/py_dss_interface/models/Lines/LinesF.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
import ctypes
66

77
from py_dss_interface.models.Base import Base
8-
from py_dss_interface.models.Lines import LinesS
9-
from py_dss_interface.models.Text.Text import Text
108

119

1210
class LinesF(Base):
@@ -105,7 +103,7 @@ def lines_write_emerg_amps(self, argument: float) -> float:
105103
return float(self.dss_obj.LinesF(ctypes.c_int32(17), ctypes.c_double(argument)))
106104

107105
def lines_read_rg(self) -> float:
108-
"""Gets the earth return value used to compute line impedances at power frequency."""
106+
"""Gets the earth return value used to compute line impedance's at power frequency."""
109107
return float(self.dss_obj.LinesF(ctypes.c_int32(18), ctypes.c_double(0)))
110108

111109
def lines_write_rg(self, argument: float) -> float:

tests/py_dss_interface/conftest.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,23 @@
55
# @File : conftest.py
66
# @Software: PyCharm
77

8-
import pytest
9-
import pathlib
108
import os
9+
import pathlib
10+
11+
import pytest
12+
1113
import py_dss_interface
12-
import time
1314

1415
script_path = os.path.dirname(os.path.abspath(__file__))
1516

1617

1718
@pytest.fixture(scope='function')
1819
def solve_snap_13bus():
19-
dss = py_dss_interface.DSSDLL(r"C:\OpenDSS")
20+
dss = py_dss_interface.DSSDLL()
2021
actual = dss.started
21-
expected = True
22+
# expected = True
2223

23-
message = f"OpenDSSDirectDLL has been loaded: {actual}"
24+
# message = f"OpenDSSDirectDLL has been loaded: {actual}"
2425

2526
# assert actual is expected, message
2627

tests/py_dss_interface/test_activeclass.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def test_active_class_get_name(self, dss):
5555

5656
def test_active_class_write_name(self, dss):
5757
expected = '645646'
58-
actual = dss.active_class_write_name(expected)
58+
dss.active_class_write_name(expected)
5959
actual = dss.active_class_get_name()
6060
assert actual == expected
6161

tests/py_dss_interface/test_cktelement.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def test_cktelement_energymeter(self, dss):
170170
def test_cktelement_controller(self, dss):
171171
# https://github.com/PauloRadatz/py_dss_interface/issues/2 - Issue solved =)
172172
dss.text("New 'Fuse.f1' MonitoredObj=Line.650632 MonitoredTerm=1 FuseCurve=Klink RatedCurrent=65")
173-
# After include a new element it become the active element. So, we need activate another element to test the
173+
# After include a new element it becomes the active element. So, we need activate another element to test the
174174
# methods below
175175
dss.circuit_set_active_element('Line.650632')
176176
expected = "Fuse.f1"

tests/py_dss_interface/test_cmathlib.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ def test_cmathlib_cabs(self, dss):
2626
assert actual == expected
2727

2828
def test_cmathlib_cdang(self, dss):
29-
real, imag = 1, 1
3029
expected = 45
3130
actual = dss.cmathlib_cdang(1, 1)
3231
assert actual == expected
@@ -50,3 +49,5 @@ def test_cmathlib_pdegtocomplex(self, dss):
5049
real, imag = 3.1622776601683795, 1.2490457723982544
5150
actual = dss.cmathlib_pdegtocomplex(real, imag)
5251
expected = complex(real, imag)
52+
assert actual == expected
53+

tests/py_dss_interface/test_dssinterface.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
# @Software: PyCharm
77

88

9-
import pytest
109
import os
1110
import pathlib
1211

12+
import pytest
13+
1314

1415
class TestDSSInterface13Bus:
1516

@@ -84,14 +85,16 @@ def test_dss_write_allow_forms(self, dss):
8485
def test_dss_read_datapath(self, dss):
8586
expected = r"C:\\PauloRadatz\\GitHub\\py-dss-interface\\tests\\py_dss_interface\\cases\\13Bus\\"
8687
actual = dss.dss_read_datapath()
87-
assert actual.replace("\\", "").split("py-dss-interfacetests")[1] == expected.replace("\\", "").split("py-dss-interfacetests")[1]
88+
assert actual.replace("\\", "").split("py-dss-interfacetests")[1] == \
89+
expected.replace("\\", "").split("py-dss-interfacetests")[1]
8890

8991
def test_dss_write_datapath(self, dss):
9092
data_path = str(pathlib.Path(os.path.dirname(__file__)).joinpath("cases", "13Bus", "datapath"))
9193
dss.dss_write_datapath(data_path)
9294
expected = data_path
9395
actual = dss.dss_read_datapath()
94-
assert actual.replace("\\", "").split("py-dss-interfacetests")[1] == expected.replace("\\", "").split("py-dss-interfacetests")[1]
96+
assert actual.replace("\\", "").split("py-dss-interfacetests")[1] == \
97+
expected.replace("\\", "").split("py-dss-interfacetests")[1]
9598

9699
def test_dss_default_editor(self, dss):
97100
expected = 'Notepad.exe'

tests/py_dss_interface/test_generators.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ def dss(self, solve_snap_13bus):
2020

2121
return dss
2222

23-
def include_generator(self, dss):
23+
@staticmethod
24+
def include_generator(dss):
2425
dss.text(
2526
'New Generator.G2 Bus1=645.1 phases=1 kV=2.4 kW=100 Model=3 Vpu=1 Maxkvar=500 Minkvar=-400'
2627
)

tests/py_dss_interface/test_lines.py

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,12 @@ def test_lines_read_geometry(self, dss):
123123
def test_lines_write_geometry(self, dss):
124124

125125
dss.text(
126-
"New WireData.1/0_ACSR Rac=0.646847 Runits=km GMRac=0.13589 GMRUnits=cm Radius=0.50546 Radunits=cm Normamps=260 Emergamps=260")
126+
"New WireData.1/0_ACSR Rac=0.646847 Runits=km GMRac=0.13589 GMRUnits=cm Radius=0.50546 Radunits=cm "
127+
"Normamps=260 Emergamps=260")
127128
dss.text("New LineGeometry.1PH-x4_ACSRx4_ACSR nconds=2 nphases=1 "
128-
" cond=1 wire=1/0_ACSR x=-0.1524 h=10.5156 units=m "
129-
" cond=2 wire=1/0_ACSR x=0.1524 h=8.2296 units=m "
130-
" reduce=y ")
129+
" cond=1 wire=1/0_ACSR x=-0.1524 h=10.5156 units=m "
130+
" cond=2 wire=1/0_ACSR x=0.1524 h=8.2296 units=m "
131+
" reduce=y ")
131132

132133
expected = '1PH-x4_ACSRx4_ACSR'.lower()
133134
dss.lines_write_geometry(expected)
@@ -163,10 +164,10 @@ def test_lines_write_length(self, dss):
163164
def test_lines_read_r1(self, dss):
164165

165166
dss.text("New linecode.Sequences nphases=3 "
166-
"r1=0.3489 x1=0.426198 r0=0.588811 x0=1.29612 "
167-
"c1=10.4308823411236 c0=4.48501282215346 "
168-
"units=km baseFreq=60 normamps=310 emergamps=310 "
169-
"faultrate=0.1 pctperm=20 repair=3")
167+
"r1=0.3489 x1=0.426198 r0=0.588811 x0=1.29612 "
168+
"c1=10.4308823411236 c0=4.48501282215346 "
169+
"units=km baseFreq=60 normamps=310 emergamps=310 "
170+
"faultrate=0.1 pctperm=20 repair=3")
170171

171172
dss.text("New line.MyLine linecode=Sequences length=1")
172173
dss.lines_write_name('MyLine')
@@ -177,10 +178,10 @@ def test_lines_read_r1(self, dss):
177178

178179
def test_lines_write_r1(self, dss):
179180
dss.text("New linecode.Sequences nphases=3 "
180-
"r1=0.3489 x1=0.426198 r0=0.588811 x0=1.29612 "
181-
"c1=10.4308823411236 c0=4.48501282215346 "
182-
"units=km baseFreq=60 normamps=310 emergamps=310 "
183-
"faultrate=0.1 pctperm=20 repair=3")
181+
"r1=0.3489 x1=0.426198 r0=0.588811 x0=1.29612 "
182+
"c1=10.4308823411236 c0=4.48501282215346 "
183+
"units=km baseFreq=60 normamps=310 emergamps=310 "
184+
"faultrate=0.1 pctperm=20 repair=3")
184185

185186
dss.text("New line.MyLine linecode=Sequences length=1")
186187
dss.lines_write_name('MyLine')
@@ -192,10 +193,10 @@ def test_lines_write_r1(self, dss):
192193

193194
def test_lines_read_x1(self, dss):
194195
dss.text("New linecode.Sequences nphases=3 "
195-
"r1=0.3489 x1=0.426198 r0=0.588811 x0=1.29612 "
196-
"c1=10.4308823411236 c0=4.48501282215346 "
197-
"units=km baseFreq=60 normamps=310 emergamps=310 "
198-
"faultrate=0.1 pctperm=20 repair=3")
196+
"r1=0.3489 x1=0.426198 r0=0.588811 x0=1.29612 "
197+
"c1=10.4308823411236 c0=4.48501282215346 "
198+
"units=km baseFreq=60 normamps=310 emergamps=310 "
199+
"faultrate=0.1 pctperm=20 repair=3")
199200

200201
dss.text("New line.MyLine linecode=Sequences length=1")
201202
dss.lines_write_name('MyLine')
@@ -206,10 +207,10 @@ def test_lines_read_x1(self, dss):
206207

207208
def test_lines_write_x1(self, dss):
208209
dss.text("New linecode.Sequences nphases=3 "
209-
"r1=0.3489 x1=0.426198 r0=0.588811 x0=1.29612 "
210-
"c1=10.4308823411236 c0=4.48501282215346 "
211-
"units=km baseFreq=60 normamps=310 emergamps=310 "
212-
"faultrate=0.1 pctperm=20 repair=3")
210+
"r1=0.3489 x1=0.426198 r0=0.588811 x0=1.29612 "
211+
"c1=10.4308823411236 c0=4.48501282215346 "
212+
"units=km baseFreq=60 normamps=310 emergamps=310 "
213+
"faultrate=0.1 pctperm=20 repair=3")
213214

214215
dss.text("New line.MyLine linecode=Sequences length=1")
215216
dss.lines_write_name('MyLine')

tests/py_dss_interface/test_load.py

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
# @File : test_load.py
66
# @Software: PyCharm
77

8-
import pytest
98
import platform
109

10+
import pytest
11+
1112

1213
class TestLoad13Bus:
1314

@@ -123,11 +124,11 @@ def test_loads_read_cvr_curve(self, dss):
123124

124125
def test_loads_write_cvr_curve(self, dss):
125126
dss.text("New Loadshape.Test npts=24 interval=1 "
126-
"mult= "
127-
"(0.18000001 0.19000000 0.23999999 0.33000001 0.38999999 0.41000000 "
128-
"0.64999998 1.23000002 1.88999999 1.88999999 1.96000004 1.98000002 "
129-
"1.45000005 1.62000000 1.88999999 1.79999995 1.78999996 1.19000006 "
130-
"0.80000001 0.66000003 0.51999998 0.40000001 0.28000000 0.23000000)")
127+
"mult= "
128+
"(0.18000001 0.19000000 0.23999999 0.33000001 0.38999999 0.41000000 "
129+
"0.64999998 1.23000002 1.88999999 1.88999999 1.96000004 1.98000002 "
130+
"1.45000005 1.62000000 1.88999999 1.79999995 1.78999996 1.19000006 "
131+
"0.80000001 0.66000003 0.51999998 0.40000001 0.28000000 0.23000000)")
131132
expected = 'Test'
132133
dss.loads_write_cvr_curve(expected)
133134
actual = dss.loads_read_cvr_curve()
@@ -140,11 +141,11 @@ def test_loads_read_daily(self, dss):
140141

141142
def test_loads_write_daily(self, dss):
142143
dss.text("New Loadshape.Test npts=24 interval=1 "
143-
"mult= "
144-
"(0.18000001 0.19000000 0.23999999 0.33000001 0.38999999 0.41000000 "
145-
"0.64999998 1.23000002 1.88999999 1.88999999 1.96000004 1.98000002 "
146-
"1.45000005 1.62000000 1.88999999 1.79999995 1.78999996 1.19000006 "
147-
"0.80000001 0.66000003 0.51999998 0.40000001 0.28000000 0.23000000)")
144+
"mult= "
145+
"(0.18000001 0.19000000 0.23999999 0.33000001 0.38999999 0.41000000 "
146+
"0.64999998 1.23000002 1.88999999 1.88999999 1.96000004 1.98000002 "
147+
"1.45000005 1.62000000 1.88999999 1.79999995 1.78999996 1.19000006 "
148+
"0.80000001 0.66000003 0.51999998 0.40000001 0.28000000 0.23000000)")
148149
expected = 'Test'
149150
dss.loads_write_daily(expected)
150151
actual = dss.loads_read_daily()
@@ -162,10 +163,10 @@ def test_loads_read_spectrum(self, dss):
162163

163164
def test_loads_write_spectrum(self, dss):
164165
dss.text("New Spectrum.Test "
165-
"NumHarm=7 "
166-
"harmonic=(1, 3, 5, 7, 9, 11, 13, ) "
167-
"%mag=(100, 1.5, 20, 14, 1, 9, 7, ) "
168-
"angle=(0, 180, 180, 180, 180, 180, 180, )")
166+
"NumHarm=7 "
167+
"harmonic=(1, 3, 5, 7, 9, 11, 13, ) "
168+
"%mag=(100, 1.5, 20, 14, 1, 9, 7, ) "
169+
"angle=(0, 180, 180, 180, 180, 180, 180, )")
169170
expected = 'Test'
170171
dss.loads_write_spectrum(expected)
171172
actual = dss.loads_read_spectrum()
@@ -178,11 +179,11 @@ def test_loads_read_yearly(self, dss):
178179

179180
def test_loads_write_yearly(self, dss):
180181
dss.text("New Loadshape.Test npts=24 interval=1 "
181-
"mult= "
182-
"(0.18000001 0.19000000 0.23999999 0.33000001 0.38999999 0.41000000 "
183-
"0.64999998 1.23000002 1.88999999 1.88999999 1.96000004 1.98000002 "
184-
"1.45000005 1.62000000 1.88999999 1.79999995 1.78999996 1.19000006 "
185-
"0.80000001 0.66000003 0.51999998 0.40000001 0.28000000 0.23000000)")
182+
"mult= "
183+
"(0.18000001 0.19000000 0.23999999 0.33000001 0.38999999 0.41000000 "
184+
"0.64999998 1.23000002 1.88999999 1.88999999 1.96000004 1.98000002 "
185+
"1.45000005 1.62000000 1.88999999 1.79999995 1.78999996 1.19000006 "
186+
"0.80000001 0.66000003 0.51999998 0.40000001 0.28000000 0.23000000)")
186187
expected = 'Test'
187188
dss.loads_write_yearly(expected)
188189
actual = dss.loads_read_yearly()

0 commit comments

Comments
 (0)