Skip to content

Commit

Permalink
Remove grow() in favor of size assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
numirias committed Dec 17, 2017
1 parent 78dfe4c commit df8a772
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 24 deletions.
9 changes: 0 additions & 9 deletions plasma/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,15 +390,6 @@ def min_size_bound(self):
def reset_size(self):
self._size = None

def grow(self, amt, orient=None):
# TODO Deprecate grow, it should be replaced by size assignment
if self.is_root:
return
if orient is ~self.parent.orient:
self.parent.grow(amt)
return
self.size += amt

@property
def flexible(self):
"""A node is flexible if its size isn't (explicitly or implictly)
Expand Down
30 changes: 15 additions & 15 deletions tests/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from pytest import approx

from plasma.debug import draw, info # noqa
from plasma.node import Node, VERTICAL, HORIZONTAL, AddMode, NotRestorableError
from plasma.node import Node, HORIZONTAL, AddMode, NotRestorableError

from .conftest import Nodes

Expand Down Expand Up @@ -68,8 +68,8 @@ def test_add_child_after_with_sizes(self, root):
a, b, c = Nodes('a b c')
root.add_child(a)
root.add_child(b)
a.grow(10)
b.grow(10)
a.size += 10
b.size += 10
b.parent.add_child_after(c, b)
assert a.size == b.size == c.size == 40

Expand Down Expand Up @@ -450,7 +450,7 @@ def test_capacity2(self, root):

def test_resize(self, root, grid):
a, b, c, d, e = grid
a.grow(10)
a.size += 10
assert a.width == a.size == 70
assert b.height == b.size == 25
assert b.width == 50
Expand All @@ -460,10 +460,10 @@ def test_resize(self, root, grid):
assert c.pos == (70, 25)
assert d.pos == (70 + 50/3, 25)
assert e.pos == (70 + (50/3)*2, 25)
b.grow(-5)
b.size -= 5
assert c.width == d.width == e.width == 50/3
assert c.height == d.height == e.height == 30
d.grow(5)
d.size += 5
assert d.width == 50/3 + 5
d.move_up()
assert d.size == (50 - b.size) / 2
Expand Down Expand Up @@ -511,11 +511,11 @@ def test_resize_absolute_and_relative2(self, root):
root.add_child(a)
root.add_child(b)
root.add_child(c)
a.grow(10)
a.size += 10
assert a.size == 50
assert b.size == 35
assert c.size == 35
b.grow(10)
b.size += 10
assert a.size == 50
assert b.size == 45
assert c.size == 25
Expand All @@ -540,7 +540,7 @@ def test_resize_flat(self, root):

def test_resize_minimum(self, grid):
a, b, c, d, e = grid
b.grow(-100)
b.size -= 100
assert b.size == 10

def test_resize_all_absolute_underflow(self, root, grid):
Expand Down Expand Up @@ -607,7 +607,7 @@ def test_resize_only_absolute_remains(self, root):

def test_reset_size(self, grid):
a, b, c, d, e = grid
a.grow(5)
a.size += 5
assert a.size == 65
a.reset_size()
assert a.size == 60
Expand All @@ -616,7 +616,7 @@ def test_size_after_split(self, root):
a, b, c = Nodes('a b c')
root.add_child(a)
root.add_child(b)
b.grow(-20)
b.size -= 20
b.flip_with(c)
assert b.parent.size == 40
assert b.size == c.size == 25
Expand All @@ -642,7 +642,7 @@ def test_resize_parents(self, root):
root.add_child(a)
root.add_child(b)
b.flip_with(c)
b.grow(10, HORIZONTAL)
b.width += 10
assert b.parent.size == 70
assert b.size == c.size == 25

Expand Down Expand Up @@ -673,9 +673,9 @@ def test_resize_root(self, root):
a, b, c = Nodes('a b c')
root.add_child(a)
root.add_child(b)
a.grow(10, orient=VERTICAL)
root.grow(10, orient=VERTICAL)
root.grow(10, orient=HORIZONTAL)
a.height += 10
root.height += 10
root.width += 10
root.size = 10
assert a._size is b._size is root._size is None

Expand Down

0 comments on commit df8a772

Please sign in to comment.