Fix 5 bugs: LRU cache, symbol lookup, asset writer, BeforeClose, write_direct#327
Open
VedantMadane wants to merge 1 commit intostefan-jansen:mainfrom
Open
Fix 5 bugs: LRU cache, symbol lookup, asset writer, BeforeClose, write_direct#327VedantMadane wants to merge 1 commit intostefan-jansen:mainfrom
VedantMadane wants to merge 1 commit intostefan-jansen:mainfrom
Conversation
…te_direct - memoize.py: Remove double-counting of cache misses in _weak_lru_cache (miss incremented on KeyError AND after storing result) - memoize.py: Fix cache_clear() crash - used list indexing (hits[0]) on plain int variables; use nonlocal instead - assets.py: Fix _lookup_symbol_strict exhausting map() iterator before zip() can consume it; use list comprehension instead - asset_writer.py: Fix _all_tables_present returning on first loop iteration instead of checking all tables - asset_writer.py: Fix write_direct swapping data_subset/defaults args for futures in _generate_output_dataframe call - events.py: Fix BeforeClose comparing calendar object to string "us_futures" instead of self.cal.name Fixes stefan-jansen#315 Signed-off-by: Vedant Madane <vedantnm@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.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.
Summary
Fixes 5 bugs reported in #315:
_weak_lru_cachedouble-counts misses (memoize.py): Cache miss counter was incremented both onKeyError(line 159) and after storing the result (line 164). Removed the duplicate increment._weak_lru_cachecache_clear()crashes (memoize.py):cache_clear()used list indexing (hits[0] = misses[0] = 0) on plainintvariables, causing aTypeError. Fixed to usenonlocaland direct assignment._lookup_symbol_strictexhaustsmap()iterator (assets.py):country_codes = map(...)creates a one-shot iterator.set(country_codes)consumed it, leavingzip(country_codes, options)empty. Replaced with a list comprehension._all_tables_presentreturns on first iteration (asset_writer.py): Thereturninside theforloop caused the method to only check the first table. Replaced withany()over all tables.write_directswaps arguments for futures (asset_writer.py):_generate_output_dataframe(_futures_defaults, futures)passeddefaultsasdata_subsetand vice versa. Corrected argument order.BeforeClosecompares calendar object to string (events.py):self.cal == "us_futures"always evaluates toFalsebecauseself.calis a calendar object. Fixed toself.cal.name == "us_futures", consistent withAfterOpen.calculate_dates.Test plan
BeforeClosenow correctly aligns execution times forus_futurescalendarsFixes #315