Skip to content
Snippets Groups Projects
Unverified Commit f237261b authored by Benjamin Loison's avatar Benjamin Loison
Browse files

Proposal failing due to `x` not being a passed datetime

parent bc9f690c
Branches
No related tags found
No related merge requests found
......@@ -24,7 +24,9 @@ axes = [targetsAxis, compressedSizeAxis, compressedScoreAxis, targetsAxis.twinx(
targets = data['targets']
timestamps = [(timestampsIndex, datetime.datetime.fromtimestamp(timestamp)) for timestampsIndex, timestamp in enumerate(data['timestamps'])]
timestamps = [datetime.datetime.fromtimestamp(timestamp) for timestamp in data['timestamps']]
blockHeights = {timestamp: timestampsIndex for timestampsIndex, timestamp in enumerate(timestamps)}
for x, (target, nextTarget) in enumerate(zip(targets, targets[1:])):
if nextTarget < target:
......@@ -46,8 +48,8 @@ axesYValues = [targets, data['compressSize'], data['compressScore'], dataConstan
class CustomDateFormatter(mdates.ticker.Formatter):
def __call__(self, x, pos=0):
blockHeight, timestamp = x
result = mdates.num2date(timestamp).strftime(f'%m/%Y - {blockHeight}')
datetime_ = mdates.num2date(x)
result = datetime_.strftime(f'%m/%Y - {blockHeights[datetime_]}')
return result
plt.gca().xaxis.set_major_formatter(CustomDateFormatter())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment