Skip to content

Commit

Permalink
Use time instead of datetime
Browse files Browse the repository at this point in the history
  • Loading branch information
numirias committed Jun 15, 2018
1 parent afbe4e4 commit c805372
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions plasma/node.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from collections import namedtuple
from datetime import datetime
import time
from math import isclose
import sys

Expand Down Expand Up @@ -70,7 +70,7 @@ def __init__(self, payload=None, x=None, y=None, width=None, height=None):
self._height = height
self._size = None
self.children = []
self.last_accessed = datetime.min
self.last_accessed = 0
self.parent = None
self.restorables = {}

Expand Down Expand Up @@ -406,7 +406,7 @@ def flexible(self):
return all((any(gc.flexible for gc in c) or c.is_leaf) for c in self)

def access(self):
self.last_accessed = datetime.now()
self.last_accessed = time.time()
try:
self.parent.access()
except AttributeError:
Expand Down Expand Up @@ -460,7 +460,7 @@ def close_neighbor(self, direction):
if not nodes:
return None
most_recent = max(nodes, key=lambda n: n.last_accessed)
if most_recent.last_accessed > datetime.min:
if most_recent.last_accessed > 0:
return most_recent
if direction in [UP, DOWN]:
match = lambda n: n.x <= self.x_center <= n.x_end
Expand Down
4 changes: 2 additions & 2 deletions tests/test_layout.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from datetime import datetime
from pathlib import Path
from pytest import fixture, mark
import sys
import time

from plasma import Plasma
from plasma.node import Node
Expand Down Expand Up @@ -74,7 +74,7 @@ def test_access(self, root):
layout = Plasma()
layout.root = root
layout.add('a')
now = datetime.now()
now = time.time()
assert layout.root.find_payload('a').last_accessed < now
layout.focus('a')
assert layout.root.find_payload('a').last_accessed > now
Expand Down

0 comments on commit c805372

Please sign in to comment.