Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug with drag key init at Profile.estimate #90

Closed
wants to merge 16 commits into from

Conversation

XaviTorello
Copy link
Contributor

Related to #87, it seems like drag key used to handle the Dragging of the decimal part of current hour estimation points to the period of the past hour instead of the current one.

Maybe i'm not understanding properly the rounding process and simply it's not a bug, but I think that will be interesting to be analyzed with the team.

Log of executions

Current drag key setting

(0, 'P2', datetime.datetime(2017, 9, 1, 0, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 0, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=1, valid=True, accumulated=Decimal('-0.139893554446')))
(1, 'P2', datetime.datetime(2017, 9, 1, 1, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 1, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=1, valid=True, accumulated=Decimal('-0.279787108892')))
(2, 'P2', datetime.datetime(2017, 9, 1, 2, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 2, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=1, valid=True, accumulated=Decimal('-0.479025677668')))
(3, 'P2', datetime.datetime(2017, 9, 1, 3, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 3, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=0, valid=True, accumulated=Decimal('0.290525706898')))
(4, 'P2', datetime.datetime(2017, 9, 1, 4, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 4, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=1, valid=True, accumulated=Decimal('0.050347776460')))
(5, 'P2', datetime.datetime(2017, 9, 1, 5, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 5, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=1, valid=True, accumulated=Decimal('-0.197891472200')))
(6, 'P2', datetime.datetime(2017, 9, 1, 6, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 6, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=1, valid=True, accumulated=Decimal('-0.449236618250')))
(7, 'P2', datetime.datetime(2017, 9, 1, 7, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 7, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=0, valid=True, accumulated=Decimal('0.324353453521')))
(8, 'P2', datetime.datetime(2017, 9, 1, 8, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 8, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=1, valid=True, accumulated=Decimal('0.007762823172')))
(9, 'P2', datetime.datetime(2017, 9, 1, 9, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 9, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=0, valid=True, accumulated=Decimal('0.418947145216')))
(10, 'P2', datetime.datetime(2017, 9, 1, 10, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 10, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=1, valid=True, accumulated=Decimal('-0.173606101109')))
(11, 'P2', datetime.datetime(2017, 9, 1, 11, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 11, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=0, valid=True, accumulated=Decimal('0.247671020582')))
(12, 'P2', datetime.datetime(2017, 9, 1, 12, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 12, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=1, valid=True, accumulated=Decimal('-0.337222773926')))
(13, 'P2', datetime.datetime(2017, 9, 1, 13, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 13, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=0, valid=True, accumulated=Decimal('0.073030465375')))
(14, 'P2', datetime.datetime(2017, 9, 1, 14, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 14, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=2, valid=True, accumulated=Decimal('-0.333962070125')))
(15, 'P1', datetime.datetime(2017, 9, 1, 15, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 15, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=2, valid=True, accumulated=Decimal('-0.438135556')))
(16, 'P1', datetime.datetime(2017, 9, 1, 16, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 16, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=1, valid=True, accumulated=Decimal('-0.00634056021')))
(17, 'P1', datetime.datetime(2017, 9, 1, 17, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 17, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=1, valid=True, accumulated=Decimal('0.35833463461')))
(18, 'P1', datetime.datetime(2017, 9, 1, 18, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 18, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=2, valid=True, accumulated=Decimal('-0.26476391286')))
(19, 'P1', datetime.datetime(2017, 9, 1, 19, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 19, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=1, valid=True, accumulated=Decimal('0.11783322792')))
(20, 'P1', datetime.datetime(2017, 9, 1, 20, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 20, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=2, valid=True, accumulated=Decimal('-0.46201268770')))
(21, 'P1', datetime.datetime(2017, 9, 1, 21, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 21, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=2, valid=True, accumulated=Decimal('0.11807095878')))
(22, 'P1', datetime.datetime(2017, 9, 1, 22, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 22, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=4, valid=True, accumulated=Decimal('-0.19752737839')))
(23, 'P1', datetime.datetime(2017, 9, 1, 23, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 23, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=3, valid=True, accumulated=Decimal('0.40699253550')))
(24, 'P1', datetime.datetime(2017, 9, 2, 0, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 2, 0, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=1, valid=True, accumulated=Decimal('0.333962070125')))

Proposed changes

(0, 'P2', datetime.datetime(2017, 9, 1, 0, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 0, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=1, valid=True, accumulated=Decimal('-0.139893554446')))
(1, 'P2', datetime.datetime(2017, 9, 1, 1, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 1, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=1, valid=True, accumulated=Decimal('-0.279787108892')))
(2, 'P2', datetime.datetime(2017, 9, 1, 2, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 2, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=1, valid=True, accumulated=Decimal('-0.479025677668')))
(3, 'P2', datetime.datetime(2017, 9, 1, 3, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 3, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=0, valid=True, accumulated=Decimal('0.290525706898')))
(4, 'P2', datetime.datetime(2017, 9, 1, 4, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 4, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=1, valid=True, accumulated=Decimal('0.050347776460')))
(5, 'P2', datetime.datetime(2017, 9, 1, 5, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 5, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=1, valid=True, accumulated=Decimal('-0.197891472200')))
(6, 'P2', datetime.datetime(2017, 9, 1, 6, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 6, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=1, valid=True, accumulated=Decimal('-0.449236618250')))
(7, 'P2', datetime.datetime(2017, 9, 1, 7, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 7, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=0, valid=True, accumulated=Decimal('0.324353453521')))
(8, 'P2', datetime.datetime(2017, 9, 1, 8, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 8, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=1, valid=True, accumulated=Decimal('0.007762823172')))
(9, 'P2', datetime.datetime(2017, 9, 1, 9, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 9, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=0, valid=True, accumulated=Decimal('0.418947145216')))
(10, 'P2', datetime.datetime(2017, 9, 1, 10, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 10, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=1, valid=True, accumulated=Decimal('-0.173606101109')))
(11, 'P2', datetime.datetime(2017, 9, 1, 11, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 11, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=0, valid=True, accumulated=Decimal('0.247671020582')))
(12, 'P2', datetime.datetime(2017, 9, 1, 12, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 12, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=1, valid=True, accumulated=Decimal('-0.337222773926')))
(13, 'P2', datetime.datetime(2017, 9, 1, 13, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 13, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=0, valid=True, accumulated=Decimal('0.073030465375')))
(14, 'P1', datetime.datetime(2017, 9, 1, 14, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 14, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=2, valid=True, accumulated=Decimal('-0.4069925355')))
(15, 'P1', datetime.datetime(2017, 9, 1, 15, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 15, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=1, valid=True, accumulated=Decimal('0.1548719085')))
(16, 'P1', datetime.datetime(2017, 9, 1, 16, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 16, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=2, valid=True, accumulated=Decimal('-0.41333309571')))
(17, 'P1', datetime.datetime(2017, 9, 1, 17, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 17, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=1, valid=True, accumulated=Decimal('-0.04865790089')))
(18, 'P1', datetime.datetime(2017, 9, 1, 18, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 18, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=1, valid=True, accumulated=Decimal('0.32824355164')))
(19, 'P1', datetime.datetime(2017, 9, 1, 19, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 19, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=2, valid=True, accumulated=Decimal('-0.28915930758')))
(20, 'P1', datetime.datetime(2017, 9, 1, 20, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 20, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=1, valid=True, accumulated=Decimal('0.13099477680')))
(21, 'P1', datetime.datetime(2017, 9, 1, 21, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 21, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=3, valid=True, accumulated=Decimal('-0.28892157672')))
(22, 'P1', datetime.datetime(2017, 9, 1, 22, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 22, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=3, valid=True, accumulated=Decimal('0.39548008611')))
(23, 'P1', datetime.datetime(2017, 9, 1, 23, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 1, 23, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=4, valid=True, accumulated=Decimal('0E-11')))
(24, 'P2', datetime.datetime(2017, 9, 2, 0, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), ProfileHour(date=datetime.datetime(2017, 9, 2, 0, 0, tzinfo=<DstTzInfo 'Europe/Madrid' CEST+2:00:00 DST>), measure=1, valid=True, accumulated=Decimal('0E-12')))

To assert that accumulated extraction method is working
… variation

Hardcoded spec, random energy_by_period is complicated to predict the
difference of energy for the initial accumulated
This will support the increase/decrease of estimated energy based on the
previous hour although this is not included on current dates scope.

Basic type and valid range of values validation is performed
This will be used transparently in the first real use of the Dragger

Fix #86
Strange situation that must be handled!
@XaviTorello XaviTorello self-assigned this Jan 31, 2018
@XaviTorello XaviTorello changed the base branch from gd_profiles to master February 5, 2018 15:43
@XaviTorello XaviTorello closed this Feb 5, 2018
@XaviTorello XaviTorello deleted the BUG_with_drag_key_init_at_estimate branch February 5, 2018 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant