UCL / TLOmodel

Epidemiology modelling framework for the Thanzi la Onse project
https://www.tlomodel.org/
MIT License
13 stars 5 forks source link

Use isinstance instead of equality comparison on type in `tlo.analysis.utils` #1449

Closed matt-graham closed 2 months ago

matt-graham commented 3 months ago

The checks workflow is failing on a couple of PRs (#1164, #1310) I've updated on a file not touched by those PRs due a ruff complaining about a type comparison in tlo.analysis.utils

src/tlo/analysis/utils.py:293:24: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
    |
291 |                 df: pd.DataFrame = load_pickled_dataframes(results_folder, draw, run, module)[module][key]
292 |                 output_from_eval: pd.Series = generate_series(df)
293 |                 assert pd.Series == type(output_from_eval), 'Custom command does not generate a pd.Series'
    |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E721
294 |                 if do_scaling:
295 |                     res[draw_run] = output_from_eval * get_multiplier(draw, run)
    |

This PR is a one line fix for the above by changing the equality == comparison to instead use isinstance.

matt-graham commented 2 months ago

I forgot I had already opened this when I created #1459 😅 - that is now merged and resolves the same issue so closing here.