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 plant error when adding new value #25302

Merged
merged 3 commits into from Jul 19, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -363,7 +363,7 @@ def __init__(self, max_length):
def add_measurement(self, value, timestamp=None):
"""Add a new measurement for a certain day."""
day = (timestamp or datetime.now()).date()
if value is None:
if value is None or not isinstance(value, (int, float)):
This conversation was marked as resolved by cgtobi

This comment has been minimized.

Copy link
@pvizeli

pvizeli Jul 19, 2019

Member

if not isinstance(...): should be enought

This conversation was marked as resolved by cgtobi

This comment has been minimized.

Copy link
@cgtobi

cgtobi Jul 19, 2019

Author Collaborator
Suggested change
if value is None or not isinstance(value, (int, float)):
if not isinstance(value, (int, float)):
return
if self._days is None:
self._days = deque()
@@ -388,4 +388,6 @@ def _add_day(self, day, value):
oldest = self._days.popleft()
del self._max_dict[oldest]
self._days.append(day)
if value is None or not isinstance(value, (int, float)):
This conversation was marked as resolved by cgtobi

This comment has been minimized.

Copy link
@cgtobi

cgtobi Jul 19, 2019

Author Collaborator
Suggested change
if value is None or not isinstance(value, (int, float)):
if not isinstance(value, (int, float)):
return
self._max_dict[day] = value
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.