Fix mutable defaults, debug print, and duplicate imports#94
Open
arpitjain099 wants to merge 1 commit into
Open
Fix mutable defaults, debug print, and duplicate imports#94arpitjain099 wants to merge 1 commit into
arpitjain099 wants to merge 1 commit into
Conversation
- 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 withisinstance()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.