You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fromdatetimeimportdateimportbisectclassNumberFromDate:
def__init__(self):
self.data= []
defadd_data(self, data_dict):
# Insert all items from dictionaryforkey, valueindata_dict.items():
bisect.insort(self.data, (key, value))
defget_number(self, date_obj):
# Find the position where the date would be insertedi=bisect.bisect(self.data, (date_obj,))
# If the date is before the first "beginning from" date, return Noneifi==0:
returnNone# Else return the number from the latest "beginning from" date before the input datereturnself.data[i-1][1]
nfd=NumberFromDate()
nfd.add_data({date(2023, 5, 20): 5, date(2023, 5, 22): 10})
print(nfd.get_number(date(2023, 5, 21))) # prints 5print(nfd.get_number(date(2023, 5, 22))) # prints 10print(nfd.get_number(date(2023, 5, 23))) # prints 10
The text was updated successfully, but these errors were encountered:
Instead of the current static INDY constants:
indy-rewards/indy_rewards/config.py
Line 7 in c5da590
Have a more dynamic config like:
This'll be good for backward compatibility.
How to get the INDY for any date
The text was updated successfully, but these errors were encountered: