Skip to content

Commit 666e84b

Browse files
committed
more lint fixes
1 parent 61d186d commit 666e84b

File tree

5 files changed

+32
-22
lines changed

5 files changed

+32
-22
lines changed

pygridsim/core.py

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def __init__(self):
1313
1414
Instantiate an OpenDSS circuit that user can build circuit components on.
1515
Stores numbers of circuit components to ensure unique naming of repeat circuit components.
16-
16+
1717
Attributes:
1818
num_loads (int): Number of loads in circuit so far.
1919
num_lines (int): Number of lines in circuit so far.
@@ -29,12 +29,15 @@ def __init__(self):
2929
altdss.ClearAll()
3030
altdss('new circuit.MyCircuit')
3131

32-
def add_load_nodes(self, load_type: str = "house", params: dict[str, int] = None, num: int = 1):
32+
def add_load_nodes(self,
33+
load_type: str = "house",
34+
params: dict[str, int] = None,
35+
num: int = 1):
3336
"""Adds Load Node(s) to circuit.
3437
3538
Allows the user to add num load nodes, either with customized parameters or using a default load_type.
3639
37-
Args:
40+
Args:
3841
load_type (str, optional):
3942
Load type as a string, one of "house", "commercial", "industrial". Defaults to "house".
4043
params (dict[str, int], optional):
@@ -75,7 +78,10 @@ def update_source(self, source_type: str = "turbine", params: dict[str, int] = N
7578
params = params or dict()
7679
return _make_source_node(params, source_type)
7780

78-
def add_PVSystem(self, load_nodes: list[str], params: dict[str, int] = None, num_panels: int = 1):
81+
def add_PVSystem(self,
82+
load_nodes: list[str],
83+
params: dict[str, int] = None,
84+
num_panels: int = 1):
7985
"""Adds a photovoltaic (PV) system to the specified load nodes.
8086
8187
Adds PV system with num_panels to each of the listed load nodes.
@@ -103,10 +109,10 @@ def add_PVSystem(self, load_nodes: list[str], params: dict[str, int] = None, num
103109
self.num_pv += 1
104110

105111
return PV_nodes
106-
112+
107113
def add_generator(self, num: int = 1, gen_type: str = "small", params: dict[str, int] = None):
108114
"""Adds generator(s) to the system.
109-
115+
110116
Args:
111117
num (int, optional):
112118
The number of generator units to add. Defaults to 1.
@@ -126,9 +132,12 @@ def add_generator(self, num: int = 1, gen_type: str = "small", params: dict[str,
126132
self.num_generators += 1
127133

128134
return generators
129-
130135

131-
def add_lines(self, connections: list[tuple], line_type: str = "lv", params: dict[str, int] = None, transformer: bool = True):
136+
def add_lines(self,
137+
connections: list[tuple],
138+
line_type: str = "lv",
139+
params: dict[str, int] = None,
140+
transformer: bool = True):
132141
"""Adds lines to the system.
133142
134143
Adds electrical lines according to the given connections.
@@ -155,18 +164,18 @@ def add_lines(self, connections: list[tuple], line_type: str = "lv", params: dic
155164
def solve(self):
156165
"""Solves the OpenDSS circuit.
157166
158-
Initializes "solve" mode in OpenDSS, which then allows the user to query results on the circuit.
167+
Initializes "solve" mode in OpenDSS, which allows user to query results on the circuit.
159168
160169
Returns:
161170
None
162171
"""
163172
altdss.Solution.Solve()
164173

165-
def results(self, queries: list[str], export_path = ""):
174+
def results(self, queries: list[str], export_path=""):
166175
"""Gets simulation results based on specified queries.
167-
176+
168177
Allows the user to query for many results at once by providing a list of desired queries.
169-
178+
170179
Args:
171180
queries (list[str]):
172181
A list of queries to the circuit ("Voltages", "Losses", "TotalPower")
@@ -185,7 +194,7 @@ def results(self, queries: list[str], export_path = ""):
185194
_export_results(results, export_path)
186195

187196
return results
188-
197+
189198
def clear(self):
190199
"""Clears the OpenDSS circuit.
191200

pygridsim/defaults.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
HV_SUBSTATION_BASE_KV = [66, 500]
3838
SHV_SUBSTATION_BASE_KV = [500, 1000]
3939

40-
SOLAR_PANEL_BASE_KV = [0.2, 0.4] #per solar panel
40+
SOLAR_PANEL_BASE_KV = [0.2, 0.4] # per solar panel
4141
"""
4242
Generator default values (small, large, industrial)
4343
"""

pygridsim/lines.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def _make_line(src, dst, line_type, count, params={}, transformer=True):
3939
transformer: Transformer = altdss.Transformer.new('transformer' + str(count))
4040
transformer.Phases = defaults.PHASES
4141
transformer.Windings = defaults.NUM_WINDINGS
42-
transformer.XHL = _get_param(params, "XHL", defaults.XHL)
42+
transformer.XHL = _get_param(params, "XHL", defaults.XHL)
4343
transformer.Buses = [src, dst]
4444
transformer.Conns = _get_param(params, "Conns",
4545
[defaults.PRIMARY_CONN, defaults.SECONDARY_CONN])

pygridsim/parameters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def _make_generator(params, gen_type, count):
9191
_check_valid_params(params, defaults.VALID_GENERATOR_PARAMS)
9292
gen_type_obj = _get_enum_obj(GeneratorType, gen_type)
9393

94-
generator : Generator = altdss.Generator.new('generator' + str(count))
94+
generator: Generator = altdss.Generator.new('generator' + str(count))
9595
generator.Bus1 = 'generator' + str(count)
9696
generator.Phases = _get_param(params, "phases", defaults.PHASES)
9797
for attr in ["kV", "kW"]:

tests/test_circuit.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def test_009_generator(self):
111111
circuit.add_lines([("source", "load0"), ("generator0", "load0")])
112112
circuit.solve()
113113
print(circuit.results(["Voltages", "Losses"]))
114-
114+
115115
def test_010_many_sources(self):
116116
circuit = PyGridSim()
117117
circuit.update_source(source_type="powerplant")
@@ -137,7 +137,7 @@ def test_011_configs(self):
137137
# don't want loadtype input, just string
138138
with self.assertRaises(Exception):
139139
circuit.add_load_nodes(num=2, load_type=LoadType.HOUSE)
140-
140+
141141
# LINE CONFIG
142142
# works, because not case sensitive
143143
circuit.add_lines([("source", "load0")], line_type="HV")
@@ -178,19 +178,20 @@ def tearDown(self):
178178
def test_100_one_source_one_load(self):
179179
circuit = PyGridSim()
180180
circuit.update_source(params={"kV": 100, "R0": 0.1, "R1": 0.2, "X0": 0.3, "X1": 0.4})
181-
circuit.add_load_nodes(num=1, params={"kV": 10, "kW": 20, "kvar":1})
181+
circuit.add_load_nodes(num=1, params={"kV": 10, "kW": 20, "kvar": 1})
182182
circuit.add_lines([("source", "load0")], params={"length": 20})
183183
circuit.solve()
184184
print(circuit.results(["Voltages", "Losses"]))
185185
circuit.clear()
186186

187187
def test_100_one_source_multi_load(self):
188188
"""
189-
Creates 10 loads, some of which are connected to source. All loads and lines here have the same params.
189+
Creates 10 loads, some of which are connected to source.
190+
All loads and lines here have the same params.
190191
"""
191192
circuit = PyGridSim()
192193
circuit.update_source(params={"kV": 100})
193-
circuit.add_load_nodes(num=10, params={"kV": 10, "kW": 20, "kvar":1})
194+
circuit.add_load_nodes(num=10, params={"kV": 10, "kW": 20, "kvar": 1})
194195
circuit.add_lines([("source", "load0"), ("source", "load4"), ("source", "load6")],
195196
params={"length": 20})
196197
circuit.solve()
@@ -207,7 +208,7 @@ def test_101_bad_parameter(self):
207208
with self.assertRaises(KeyError):
208209
circuit.add_load_nodes(num=4, params={"badParam": 100})
209210
# add load nodes so we can test pv system erroring
210-
circuit.add_load_nodes(num=2, params={"kV": 10, "kW": 20, "kvar":1})
211+
circuit.add_load_nodes(num=2, params={"kV": 10, "kW": 20, "kvar": 1})
211212
with self.assertRaises(KeyError):
212213
circuit.add_generator(num=4, params={"badParam": 100})
213214
with self.assertRaises(KeyError):

0 commit comments

Comments
 (0)