1313import warnings
1414import requests
1515import os
16+ from collections import namedtuple
1617from windpowerlib .tools import WindpowerlibUserWarning
1718
1819
@@ -213,8 +214,9 @@ def to_group(self, number_turbines=None, total_capacity=None):
213214
214215 Returns
215216 -------
216- dict
217- A dictionary with two keys ('number_of_turbines' and 'wind_turbine'
217+ namedtuple
218+ A namedtuple with two fields: 'number_of_turbines' and
219+ 'wind_turbine'.
218220
219221 Examples
220222 --------
@@ -223,16 +225,18 @@ def to_group(self, number_turbines=None, total_capacity=None):
223225 ... 'hub_height': 135,
224226 ... 'turbine_type': 'E-126/4200'}
225227 >>> e126 = WindTurbine(**enerconE126)
226- >>> e126.to_group(5)[' number_of_turbines']
228+ >>> e126.to_group(5). number_of_turbines
227229 5
228- >>> e126.to_group()[' number_of_turbines']
230+ >>> e126.to_group(). number_of_turbines
229231 1
230- >>> e126.to_group(number_turbines=7)[' number_of_turbines']
232+ >>> e126.to_group(number_turbines=7). number_of_turbines
231233 7
232- >>> e126.to_group(total_capacity=12600000)[' number_of_turbines']
234+ >>> e126.to_group(total_capacity=12600000). number_of_turbines
233235 3.0
234- >>> e126.to_group(total_capacity=14700000)[' number_of_turbines']
236+ >>> e126.to_group(total_capacity=14700000). number_of_turbines
235237 3.5
238+ >>> e126.to_group(total_capacity=12600000).wind_turbine.nominal_power
239+ 4200000.0
236240 """
237241 if number_turbines is not None and total_capacity is not None :
238242 raise ValueError ("The 'number' and the 'total_capacity parameter "
@@ -241,7 +245,10 @@ def to_group(self, number_turbines=None, total_capacity=None):
241245 number_turbines = total_capacity / self .nominal_power
242246 elif number_turbines is None :
243247 number_turbines = 1
244- return {'wind_turbine' : self , 'number_of_turbines' : number_turbines }
248+ wind_turbine_group = namedtuple ('WindTurbineGroup' ,
249+ 'wind_turbine number_of_turbines' )
250+ return wind_turbine_group (
251+ wind_turbine = self , number_of_turbines = number_turbines )
245252
246253
247254def get_turbine_data_from_file (turbine_type , path ):
0 commit comments