Skip to content

Commit 29074f5

Browse files
eumirokandersolar
andauthored
Lazify various calls to all() by using generators instead of comprehensions (#1829)
* Lazify all() * stickler * whatsnew --------- Co-authored-by: Kevin Anderson <[email protected]>
1 parent f8b1294 commit 29074f5

File tree

6 files changed

+10
-12
lines changed

6 files changed

+10
-12
lines changed

docs/sphinx/source/whatsnew/v0.10.2.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,4 @@ Contributors
6464
* Anton Driesse (:ghuser:`adriesse`)
6565
* Lukas Grossar (:ghuser:`tongpu`)
6666
* Areeba Turabi (:ghuser:`aturabi`)
67+
* Miroslav Šedivý (:ghuser:`eumiro`)

pvlib/modelchain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1994,7 +1994,7 @@ def _irrad_for_celltemp(total_irrad, effective_irradiance):
19941994
19951995
"""
19961996
if isinstance(total_irrad, tuple):
1997-
if all(['poa_global' in df for df in total_irrad]):
1997+
if all('poa_global' in df for df in total_irrad):
19981998
return _tuple_from_dfs(total_irrad, 'poa_global')
19991999
else:
20002000
return effective_irradiance

pvlib/pvsystem.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,20 +1297,18 @@ def dc_ohms_from_percent(self):
12971297
"""
12981298

12991299
# get relevent Vmp and Imp parameters from CEC parameters
1300-
if all([elem in self.module_parameters
1301-
for elem in ['V_mp_ref', 'I_mp_ref']]):
1300+
if all(elem in self.module_parameters
1301+
for elem in ['V_mp_ref', 'I_mp_ref']):
13021302
vmp_ref = self.module_parameters['V_mp_ref']
13031303
imp_ref = self.module_parameters['I_mp_ref']
13041304

13051305
# get relevant Vmp and Imp parameters from SAPM parameters
1306-
elif all([elem in self.module_parameters
1307-
for elem in ['Vmpo', 'Impo']]):
1306+
elif all(elem in self.module_parameters for elem in ['Vmpo', 'Impo']):
13081307
vmp_ref = self.module_parameters['Vmpo']
13091308
imp_ref = self.module_parameters['Impo']
13101309

13111310
# get relevant Vmp and Imp parameters if they are PVsyst-like
1312-
elif all([elem in self.module_parameters
1313-
for elem in ['Vmpp', 'Impp']]):
1311+
elif all(elem in self.module_parameters for elem in ['Vmpp', 'Impp']):
13141312
vmp_ref = self.module_parameters['Vmpp']
13151313
imp_ref = self.module_parameters['Impp']
13161314

pvlib/tests/iotools/test_pvgis.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ def test_get_pvgis_tmy_error():
496496
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
497497
def test_get_pvgis_map_variables(pvgis_tmy_mapped_columns):
498498
actual, _, _, _ = get_pvgis_tmy(45, 8, map_variables=True)
499-
assert all([c in pvgis_tmy_mapped_columns for c in actual.columns])
499+
assert all(c in pvgis_tmy_mapped_columns for c in actual.columns)
500500

501501

502502
@pytest.mark.remote_data
@@ -519,7 +519,7 @@ def test_read_pvgis_horizon_invalid_coords():
519519
def test_read_pvgis_tmy_map_variables(pvgis_tmy_mapped_columns):
520520
fn = DATA_DIR / 'tmy_45.000_8.000_2005_2016.json'
521521
actual, _, _, _ = read_pvgis_tmy(fn, map_variables=True)
522-
assert all([c in pvgis_tmy_mapped_columns for c in actual.columns])
522+
assert all(c in pvgis_tmy_mapped_columns for c in actual.columns)
523523

524524

525525
def test_read_pvgis_tmy_json(expected, month_year_expected, inputs_expected,

pvlib/tests/iotools/test_srml.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def test_get_srml_minute():
146146
expected_index = pd.date_range(start='2018-01-01', end='2018-01-31 23:59',
147147
freq='1min', tz='Etc/GMT+8')
148148
assert_index_equal(data_get.index, expected_index)
149-
assert all([c in data_get.columns for c in data_read.columns])
149+
assert all(c in data_get.columns for c in data_read.columns)
150150
# Check that all indices in example file are present in remote file
151151
assert data_read.index.isin(data_get.index).all()
152152
assert meta['station'] == 'EU'

pvlib/tests/test_modelchain.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2059,5 +2059,4 @@ def test_ModelChainResult___repr__(sapm_dc_snl_ac_system, location, weather):
20592059
mcres = mc.results.__repr__()
20602060
mc_attrs = dir(mc.results)
20612061
mc_attrs = [a for a in mc_attrs if not a.startswith('_')]
2062-
assert all([a in mcres for a in mc_attrs])
2063-
2062+
assert all(a in mcres for a in mc_attrs)

0 commit comments

Comments
 (0)