Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazify various calls to all() by using generators instead of comprehensions #1829

Merged
merged 4 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/sphinx/source/whatsnew/v0.10.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,4 @@ Contributors
* Anton Driesse (:ghuser:`adriesse`)
* Lukas Grossar (:ghuser:`tongpu`)
* Areeba Turabi (:ghuser:`aturabi`)
* Miroslav Šedivý (:ghuser:`eumiro`)
2 changes: 1 addition & 1 deletion pvlib/modelchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -1994,7 +1994,7 @@ def _irrad_for_celltemp(total_irrad, effective_irradiance):

"""
if isinstance(total_irrad, tuple):
if all(['poa_global' in df for df in total_irrad]):
if all('poa_global' in df for df in total_irrad):
return _tuple_from_dfs(total_irrad, 'poa_global')
else:
return effective_irradiance
Expand Down
10 changes: 4 additions & 6 deletions pvlib/pvsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -1297,20 +1297,18 @@ def dc_ohms_from_percent(self):
"""

# get relevent Vmp and Imp parameters from CEC parameters
if all([elem in self.module_parameters
for elem in ['V_mp_ref', 'I_mp_ref']]):
if all(elem in self.module_parameters
for elem in ['V_mp_ref', 'I_mp_ref']):
vmp_ref = self.module_parameters['V_mp_ref']
imp_ref = self.module_parameters['I_mp_ref']

# get relevant Vmp and Imp parameters from SAPM parameters
elif all([elem in self.module_parameters
for elem in ['Vmpo', 'Impo']]):
elif all(elem in self.module_parameters for elem in ['Vmpo', 'Impo']):
vmp_ref = self.module_parameters['Vmpo']
imp_ref = self.module_parameters['Impo']

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

Expand Down
4 changes: 2 additions & 2 deletions pvlib/tests/iotools/test_pvgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ def test_get_pvgis_tmy_error():
@pytest.mark.flaky(reruns=RERUNS, reruns_delay=RERUNS_DELAY)
def test_get_pvgis_map_variables(pvgis_tmy_mapped_columns):
actual, _, _, _ = get_pvgis_tmy(45, 8, map_variables=True)
assert all([c in pvgis_tmy_mapped_columns for c in actual.columns])
assert all(c in pvgis_tmy_mapped_columns for c in actual.columns)


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


def test_read_pvgis_tmy_json(expected, month_year_expected, inputs_expected,
Expand Down
2 changes: 1 addition & 1 deletion pvlib/tests/iotools/test_srml.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def test_get_srml_minute():
expected_index = pd.date_range(start='2018-01-01', end='2018-01-31 23:59',
freq='1min', tz='Etc/GMT+8')
assert_index_equal(data_get.index, expected_index)
assert all([c in data_get.columns for c in data_read.columns])
assert all(c in data_get.columns for c in data_read.columns)
# Check that all indices in example file are present in remote file
assert data_read.index.isin(data_get.index).all()
assert meta['station'] == 'EU'
Expand Down
3 changes: 1 addition & 2 deletions pvlib/tests/test_modelchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -2059,5 +2059,4 @@ def test_ModelChainResult___repr__(sapm_dc_snl_ac_system, location, weather):
mcres = mc.results.__repr__()
mc_attrs = dir(mc.results)
mc_attrs = [a for a in mc_attrs if not a.startswith('_')]
assert all([a in mcres for a in mc_attrs])

assert all(a in mcres for a in mc_attrs)
Loading