Skip to content

Commit ca6018e

Browse files
fix C416 unnecessary dict comprehension
1 parent f51826b commit ca6018e

File tree

4 files changed

+4
-8
lines changed

4 files changed

+4
-8
lines changed

pyabc/distance/pnorm.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,7 @@ def weights2dict(
252252
"""
253253
# assumes that the summary statistic labels do not change over time
254254
return {
255-
t: {
256-
key: val
257-
for key, val in zip(self.sumstat.get_ids(), weights[t])
258-
}
259-
for t in weights
255+
t: dict(zip(self.sumstat.get_ids(), weights[t])) for t in weights
260256
}
261257

262258

pyabc/distance/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def log_weights(
6060
log_file: File to log formatted output to.
6161
"""
6262
# create weights dictionary with labels
63-
weights = {key: val for key, val in zip(keys, weights[t])}
63+
weights = dict(zip(keys, weights[t]))
6464

6565
vals = [f"'{key}': {val:.4e}" for key, val in weights.items()]
6666
logger.debug(f"{label} weights[{t}] = {{{', '.join(vals)}}}")

pyabc/external/r/r_rpy2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def _dict_to_named_list(dct):
3030
or isinstance(dct, Parameter)
3131
or isinstance(dct, pd.core.series.Series)
3232
):
33-
dct = {key: val for key, val in dct.items()}
33+
dct = dict(dct.items())
3434
# convert numbers, numpy arrays and pandas dataframes to builtin
3535
# types before conversion (see rpy2 #548)
3636
with conversion.localconverter(

pyabc/petab/amici.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def __call__(self, par: Union[Sequence, Mapping]) -> Mapping:
7272

7373
# convenience to allow calling model not only with dicts
7474
if not isinstance(par, Mapping):
75-
par = {key: val for key, val in zip(self.x_free_ids, par)}
75+
par = dict(zip(self.x_free_ids, par))
7676

7777
# add fixed parameters
7878
for key, val in zip(self.x_fixed_ids, self.x_fixed_vals):

0 commit comments

Comments
 (0)