Skip to content

Commit 199eb9d

Browse files
committed
Test automatic fixing of stickler and black
1 parent 6e9b0a5 commit 199eb9d

25 files changed

+654
-654
lines changed

example/modelchain_example.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
try:
2020
from matplotlib import pyplot as plt
2121
except ImportError:
22-
plt = None
22+
plt=None
2323

2424
from windpowerlib import ModelChain
2525
from windpowerlib import WindTurbine
@@ -65,23 +65,23 @@ def get_weather_data(filename='weather.csv', **kwargs):
6565
"""
6666

6767
if 'datapath' not in kwargs:
68-
kwargs['datapath'] = os.path.join(os.path.split(
68+
kwargs['datapath']=os.path.join(os.path.split(
6969
os.path.dirname(__file__))[0], 'example')
70-
file = os.path.join(kwargs['datapath'], filename)
70+
file=os.path.join(kwargs['datapath'], filename)
7171

7272
# read csv file
73-
weather_df = pd.read_csv(
73+
weather_df=pd.read_csv(
7474
file, index_col=0, header=[0, 1],
7575
date_parser=lambda idx: pd.to_datetime(idx, utc=True))
7676

7777
# change type of index to datetime and set time zone
78-
weather_df.index = pd.to_datetime(weather_df.index).tz_convert(
78+
weather_df.index=pd.to_datetime(weather_df.index).tz_convert(
7979
'Europe/Berlin')
8080

8181
# change type of height from str to int by resetting columns
82-
l0 = [_[0] for _ in weather_df.columns]
83-
l1 = [int(_[1]) for _ in weather_df.columns]
84-
weather_df.columns = [l0, l1]
82+
l0=[_[0] for _ in weather_df.columns]
83+
l1=[int(_[1]) for _ in weather_df.columns]
84+
weather_df.columns=[l0, l1]
8585

8686
return weather_df
8787

@@ -111,16 +111,16 @@ def initialize_wind_turbines():
111111

112112
# specification of wind turbine where data is provided in the oedb
113113
# turbine library
114-
enercon_e126 = {
114+
enercon_e126={
115115
'turbine_type': 'E-126/4200', # turbine type as in register
116116
'hub_height': 135 # in m
117117
}
118118
# initialize WindTurbine object
119-
e126 = WindTurbine(**enercon_e126)
119+
e126=WindTurbine(**enercon_e126)
120120

121121
# specification of own wind turbine (Note: power values and nominal power
122122
# have to be in Watt)
123-
my_turbine = {
123+
my_turbine={
124124
'nominal_power': 3e6, # in W
125125
'hub_height': 105, # in m
126126
'power_curve': pd.DataFrame(
@@ -129,19 +129,19 @@ def initialize_wind_turbines():
129129
'wind_speed': [0.0, 3.0, 5.0, 10.0, 15.0, 25.0]}) # in m/s
130130
}
131131
# initialize WindTurbine object
132-
my_turbine = WindTurbine(**my_turbine)
132+
my_turbine=WindTurbine(**my_turbine)
133133

134134
# specification of wind turbine where power coefficient curve and nominal
135135
# power is provided in an own csv file
136-
csv_path = os.path.join(os.path.dirname(__file__), 'data')
137-
dummy_turbine = {
136+
csv_path=os.path.join(os.path.dirname(__file__), 'data')
137+
dummy_turbine={
138138
'turbine_type': "DUMMY 1",
139139
'hub_height': 100, # in m
140140
'rotor_diameter': 70, # in m
141141
'path': csv_path
142142
}
143143
# initialize WindTurbine object
144-
dummy_turbine = WindTurbine(**dummy_turbine)
144+
dummy_turbine=WindTurbine(**dummy_turbine)
145145

146146
return my_turbine, e126, dummy_turbine
147147

@@ -175,13 +175,13 @@ def calculate_power_output(weather, my_turbine, e126, dummy_turbine):
175175
# power output calculation for my_turbine
176176
# initialize ModelChain with default parameters and use run_model method
177177
# to calculate power output
178-
mc_my_turbine = ModelChain(my_turbine).run_model(weather)
178+
mc_my_turbine=ModelChain(my_turbine).run_model(weather)
179179
# write power output time series to WindTurbine object
180-
my_turbine.power_output = mc_my_turbine.power_output
180+
my_turbine.power_output=mc_my_turbine.power_output
181181

182182
# power output calculation for e126
183183
# own specifications for ModelChain setup
184-
modelchain_data = {
184+
modelchain_data={
185185
'wind_speed_model': 'logarithmic', # 'logarithmic' (default),
186186
# 'hellman' or
187187
# 'interpolation_extrapolation'
@@ -196,16 +196,16 @@ def calculate_power_output(weather, my_turbine, e126, dummy_turbine):
196196
'hellman_exp': None} # None (default) or None
197197
# initialize ModelChain with own specifications and use run_model method
198198
# to calculate power output
199-
mc_e126 = ModelChain(e126, **modelchain_data).run_model(weather)
199+
mc_e126=ModelChain(e126, **modelchain_data).run_model(weather)
200200
# write power output time series to WindTurbine object
201-
e126.power_output = mc_e126.power_output
201+
e126.power_output=mc_e126.power_output
202202

203203
# power output calculation for example_turbine
204204
# own specification for 'power_output_model'
205-
mc_example_turbine = ModelChain(
205+
mc_example_turbine=ModelChain(
206206
dummy_turbine,
207207
power_output_model='power_coefficient_curve').run_model(weather)
208-
dummy_turbine.power_output = mc_example_turbine.power_output
208+
dummy_turbine.power_output=mc_example_turbine.power_output
209209

210210
return
211211

@@ -272,8 +272,8 @@ def run_example():
272272
Runs the basic example.
273273
274274
"""
275-
weather = get_weather_data('weather.csv')
276-
my_turbine, e126, dummy_turbine = initialize_wind_turbines()
275+
weather=get_weather_data('weather.csv')
276+
my_turbine, e126, dummy_turbine=initialize_wind_turbines()
277277
calculate_power_output(weather, my_turbine, e126, dummy_turbine)
278278
plot_or_print(my_turbine, e126, dummy_turbine)
279279

example/test_examples.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ class TestExamples:
1818

1919
def test_modelchain_example_flh(self):
2020
# tests full load hours
21-
weather = mc_e.get_weather_data('weather.csv')
22-
my_turbine, e126, dummy_turbine = mc_e.initialize_wind_turbines()
21+
weather=mc_e.get_weather_data('weather.csv')
22+
my_turbine, e126, dummy_turbine=mc_e.initialize_wind_turbines()
2323
mc_e.calculate_power_output(weather, my_turbine, e126, dummy_turbine)
2424

2525
assert_allclose(2764.194772, (e126.power_output.sum() /
@@ -29,11 +29,11 @@ def test_modelchain_example_flh(self):
2929

3030
def test_turbine_cluster_modelchain_example_flh(self):
3131
# tests full load hours
32-
weather = mc_e.get_weather_data('weather.csv')
33-
my_turbine, e126, dummy_turbine = mc_e.initialize_wind_turbines()
34-
example_farm, example_farm_2 = tc_mc_e.initialize_wind_farms(
32+
weather=mc_e.get_weather_data('weather.csv')
33+
my_turbine, e126, dummy_turbine=mc_e.initialize_wind_turbines()
34+
example_farm, example_farm_2=tc_mc_e.initialize_wind_farms(
3535
my_turbine, e126)
36-
example_cluster = tc_mc_e.initialize_wind_turbine_cluster(
36+
example_cluster=tc_mc_e.initialize_wind_turbine_cluster(
3737
example_farm, example_farm_2)
3838
tc_mc_e.calculate_power_output(weather, example_farm, example_cluster)
3939
assert_allclose(1956.164053, (example_farm.power_output.sum() /
@@ -46,33 +46,33 @@ def _notebook_run(self, path):
4646
Execute a notebook via nbconvert and collect output.
4747
Returns (parsed nb object, execution errors)
4848
"""
49-
dirname, __ = os.path.split(path)
49+
dirname, __=os.path.split(path)
5050
os.chdir(dirname)
5151
with tempfile.NamedTemporaryFile(suffix=".ipynb") as fout:
52-
args = ["jupyter", "nbconvert", "--to", "notebook", "--execute",
52+
args=["jupyter", "nbconvert", "--to", "notebook", "--execute",
5353
"--ExecutePreprocessor.timeout=60",
5454
"--output", fout.name, path]
5555
subprocess.check_call(args)
5656

5757
fout.seek(0)
58-
nb = nbformat.read(fout, nbformat.current_nbformat)
58+
nb=nbformat.read(fout, nbformat.current_nbformat)
5959

60-
errors = [output for cell in nb.cells if "outputs" in cell
60+
errors=[output for cell in nb.cells if "outputs" in cell
6161
for output in cell["outputs"]
6262
if output.output_type == "error"]
6363

6464
return nb, errors
6565

6666
@pytest.mark.skipif(sys.version_info < (3, 6), reason="requires python3.6")
6767
def test_modelchain_example_ipynb(self):
68-
dir_path = os.path.dirname(os.path.realpath(__file__))
69-
nb, errors = self._notebook_run(
68+
dir_path=os.path.dirname(os.path.realpath(__file__))
69+
nb, errors=self._notebook_run(
7070
os.path.join(dir_path, 'modelchain_example.ipynb'))
7171
assert errors == []
7272

7373
@pytest.mark.skipif(sys.version_info < (3, 6), reason="requires python3.6")
7474
def test_turbine_cluster_modelchain_example_ipynb(self):
75-
dir_path = os.path.dirname(os.path.realpath(__file__))
76-
nb, errors = self._notebook_run(
75+
dir_path=os.path.dirname(os.path.realpath(__file__))
76+
nb, errors=self._notebook_run(
7777
os.path.join(dir_path, 'turbine_cluster_modelchain_example.ipynb'))
7878
assert errors == []

example/turbine_cluster_modelchain_example.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
try:
1616
from matplotlib import pyplot as plt
1717
except ImportError:
18-
plt = None
18+
plt=None
1919

2020
from example import modelchain_example as mc_e
2121
from windpowerlib import WindFarm
@@ -58,24 +58,24 @@ def initialize_wind_farms(my_turbine, e126):
5858
# for each turbine type you can either specify the number of turbines of
5959
# that type in the wind farm (float values are possible as well) or the
6060
# total installed capacity of that turbine type in W
61-
wind_turbine_fleet = pd.DataFrame(
61+
wind_turbine_fleet=pd.DataFrame(
6262
{'wind_turbine': [my_turbine, e126], # as windpowerlib.WindTurbine
6363
'number_of_turbines': [6, None],
6464
'total_capacity': [None, 12.6e6]}
6565
)
6666
# initialize WindFarm object
67-
example_farm = WindFarm(name='example_farm',
67+
example_farm=WindFarm(name='example_farm',
6868
wind_turbine_fleet=wind_turbine_fleet)
6969

7070
# specification of wind farm data (2) containing a wind farm efficiency
7171
# wind turbine fleet is provided using the to_group function
72-
example_farm_2_data = {
72+
example_farm_2_data={
7373
'name': 'example_farm_2',
7474
'wind_turbine_fleet': [my_turbine.to_group(6),
7575
e126.to_group(total_capacity=12.6e6)],
7676
'efficiency': 0.9}
7777
# initialize WindFarm object
78-
example_farm_2 = WindFarm(**example_farm_2_data)
78+
example_farm_2=WindFarm(**example_farm_2_data)
7979

8080
return example_farm, example_farm_2
8181

@@ -103,11 +103,11 @@ def initialize_wind_turbine_cluster(example_farm, example_farm_2):
103103
"""
104104

105105
# specification of cluster data
106-
example_cluster_data = {
106+
example_cluster_data={
107107
'name': 'example_cluster',
108108
'wind_farms': [example_farm, example_farm_2]}
109109
# initialize WindTurbineCluster object
110-
example_cluster = WindTurbineCluster(**example_cluster_data)
110+
example_cluster=WindTurbineCluster(**example_cluster_data)
111111

112112
return example_cluster
113113

@@ -133,17 +133,17 @@ class that provides all necessary steps to calculate the power output of a
133133
WindTurbineCluster object.
134134
135135
"""
136-
example_farm.efficiency = 0.9
136+
example_farm.efficiency=0.9
137137
# power output calculation for example_farm
138138
# initialize TurbineClusterModelChain with default parameters and use
139139
# run_model method to calculate power output
140-
mc_example_farm = TurbineClusterModelChain(example_farm).run_model(weather)
140+
mc_example_farm=TurbineClusterModelChain(example_farm).run_model(weather)
141141
# write power output time series to WindFarm object
142-
example_farm.power_output = mc_example_farm.power_output
142+
example_farm.power_output=mc_example_farm.power_output
143143

144144
# power output calculation for turbine_cluster
145145
# own specifications for TurbineClusterModelChain setup
146-
modelchain_data = {
146+
modelchain_data={
147147
'wake_losses_model':
148148
'wind_farm_efficiency', # 'dena_mean' (default), None,
149149
# 'wind_farm_efficiency' or name
@@ -171,10 +171,10 @@ class that provides all necessary steps to calculate the power output of a
171171
'hellman_exp': None} # None (default) or None
172172
# initialize TurbineClusterModelChain with own specifications and use
173173
# run_model method to calculate power output
174-
mc_example_cluster = TurbineClusterModelChain(
174+
mc_example_cluster=TurbineClusterModelChain(
175175
example_cluster, **modelchain_data).run_model(weather)
176176
# write power output time series to WindTurbineCluster object
177-
example_cluster.power_output = mc_example_cluster.power_output
177+
example_cluster.power_output=mc_example_cluster.power_output
178178

179179
return
180180

@@ -209,10 +209,10 @@ def run_example():
209209
Runs the example.
210210
211211
"""
212-
weather = mc_e.get_weather_data('weather.csv')
213-
my_turbine, e126, dummy_turbine = mc_e.initialize_wind_turbines()
214-
example_farm, example_farm_2 = initialize_wind_farms(my_turbine, e126)
215-
example_cluster = initialize_wind_turbine_cluster(example_farm,
212+
weather=mc_e.get_weather_data('weather.csv')
213+
my_turbine, e126, dummy_turbine=mc_e.initialize_wind_turbines()
214+
example_farm, example_farm_2=initialize_wind_farms(my_turbine, e126)
215+
example_cluster=initialize_wind_turbine_cluster(example_farm,
216216
example_farm_2)
217217
calculate_power_output(weather, example_farm, example_cluster)
218218
plot_or_print(example_farm, example_cluster)

tests/test_density.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,55 +14,55 @@
1414
class TestDensity:
1515

1616
def test_barometric(self):
17-
parameters = {'pressure': pd.Series(data=[101125, 101000]),
17+
parameters={'pressure': pd.Series(data=[101125, 101000]),
1818
'pressure_height': 0,
1919
'hub_height': 100,
2020
'temperature_hub_height': pd.Series(data=[267, 268])}
2121

2222
# Test pressure as pd.Series and temperature_hub_height as pd.Series
2323
# and np.array
24-
rho_exp = pd.Series(data=[1.30305336, 1.29656645])
24+
rho_exp=pd.Series(data=[1.30305336, 1.29656645])
2525
assert_series_equal(barometric(**parameters), rho_exp)
26-
parameters['temperature_hub_height'] = np.array(
26+
parameters['temperature_hub_height']=np.array(
2727
parameters['temperature_hub_height'])
2828
assert_series_equal(barometric(**parameters), rho_exp)
2929

3030
# Test pressure as np.array and temperature_hub_height as pd.Series
31-
parameters['pressure'] = np.array(parameters['pressure'])
32-
parameters['temperature_hub_height'] = pd.Series(
31+
parameters['pressure']=np.array(parameters['pressure'])
32+
parameters['temperature_hub_height']=pd.Series(
3333
data=parameters['temperature_hub_height'])
3434
assert_series_equal(barometric(**parameters), rho_exp)
3535

3636
# Test pressure as np.array and temperature_hub_height as np.array
37-
rho_exp = np.array([1.30305336, 1.29656645])
38-
parameters['temperature_hub_height'] = np.array(
37+
rho_exp=np.array([1.30305336, 1.29656645])
38+
parameters['temperature_hub_height']=np.array(
3939
parameters['temperature_hub_height'])
4040
assert_allclose(barometric(**parameters), rho_exp)
4141
assert isinstance(barometric(**parameters), np.ndarray)
4242

4343
def test_ideal_gas(self):
44-
parameters = {'pressure': pd.Series(data=[101125, 101000]),
44+
parameters={'pressure': pd.Series(data=[101125, 101000]),
4545
'pressure_height': 0,
4646
'hub_height': 100,
4747
'temperature_hub_height': pd.Series(data=[267, 268])}
4848

4949
# Test pressure as pd.Series and temperature_hub_height as pd.Series
5050
# and np.array
51-
rho_exp = pd.Series(data=[1.30309439, 1.29660728])
51+
rho_exp=pd.Series(data=[1.30309439, 1.29660728])
5252
assert_series_equal(ideal_gas(**parameters), rho_exp)
53-
parameters['temperature_hub_height'] = np.array(
53+
parameters['temperature_hub_height']=np.array(
5454
parameters['temperature_hub_height'])
5555
assert_series_equal(ideal_gas(**parameters), rho_exp)
5656

5757
# Test pressure as np.array and temperature_hub_height as pd.Series
58-
parameters['pressure'] = np.array(parameters['pressure'])
59-
parameters['temperature_hub_height'] = pd.Series(
58+
parameters['pressure']=np.array(parameters['pressure'])
59+
parameters['temperature_hub_height']=pd.Series(
6060
data=parameters['temperature_hub_height'])
6161
assert_allclose(ideal_gas(**parameters), rho_exp)
6262

6363
# Test pressure as np.array and temperature_hub_height as np.array
64-
rho_exp = np.array([1.30309439, 1.29660728])
65-
parameters['temperature_hub_height'] = np.array(
64+
rho_exp=np.array([1.30309439, 1.29660728])
65+
parameters['temperature_hub_height']=np.array(
6666
parameters['temperature_hub_height'])
6767
assert_allclose(ideal_gas(**parameters), rho_exp)
6868
assert isinstance(ideal_gas(**parameters), np.ndarray)

0 commit comments

Comments
 (0)