Skip to content

Fix mutable defaults, debug print, and duplicate imports#94

Open
arpitjain099 wants to merge 1 commit into
dbetchkal:mainfrom
arpitjain099:fix/code-quality-cleanup
Open

Fix mutable defaults, debug print, and duplicate imports#94
arpitjain099 wants to merge 1 commit into
dbetchkal:mainfrom
arpitjain099:fix/code-quality-cleanup

Conversation

@arpitjain099

Copy link
Copy Markdown
Contributor

Fixes a few related code quality issues across the codebase.

Mutable default arguments - five function signatures used mutable lists or dicts as defaults (metrics.py: clip_events_to_time_period, get_all_geo_stats, clip_srcid_to_time_period, get_all_srcid_stats; run_audible_transits.py: init_audible_transits). Replaced with None + initialization inside the function body.

type() comparisons - get_all_geo_stats and get_all_srcid_stats used type(x)!=type([]) to check if a parameter was a list. Replaced with isinstance() which also handles subclasses correctly.

Debug print - print(save) left in computation.py audibility_to_interval() at the end of the noise-free interval calculation. Removed.

Duplicate imports - clock_drift.py imported pandas, numpy, and shapely.geometry.Point twice each. Removed the duplicates.

- Replace mutable default arguments (list/dict) with None in
  metrics.py (4 functions) and run_audible_transits.py (1 function).
  Mutable defaults are shared across calls and can cause subtle bugs
  when a caller modifies the returned default in place.

- Replace type(x)!=type([]) comparisons with isinstance() in
  get_all_geo_stats and get_all_srcid_stats.

- Remove leftover debug print(save) in computation.py
  audibility_to_interval().

- Remove duplicate imports in clock_drift.py (pandas, numpy,
  shapely.geometry.Point were each imported twice).

Signed-off-by: arpitjain099 <arpitjain099@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant