Skip to content

Commit

Permalink
fix stats hemisphere when no entities to display
Browse files Browse the repository at this point in the history
  • Loading branch information
hoishing committed Nov 1, 2024
1 parent 96fb23f commit 342e3ed
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
9 changes: 5 additions & 4 deletions natal/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,11 @@ def hemisphere(self) -> StatData:
title = f"Hemispheres ({self.data1.name})"
grid = [("hemisphere", "count", "bodies")]
data = self.quadrant.grid[1:]
left = ("←", data[0][1] + data[3][1], f"{data[0][2]}, {data[3][2]}")
right = ("→", data[1][1] + data[2][1], f"{data[1][2]}, {data[2][2]}")
top = ("↑", data[2][1] + data[3][1], f"{data[2][2]}, {data[3][2]}")
bottom = ("↓", data[0][1] + data[1][1], f"{data[0][2]}, {data[1][2]}")
formatter = lambda a, b: (data[a][2] + ", " + data[b][2]).strip(" ,")
left = ("←", data[0][1] + data[3][1], formatter(0, 3))
right = ("→", data[1][1] + data[2][1], formatter(1, 2))
top = ("↑", data[2][1] + data[3][1], formatter(2, 3))
bottom = ("↓", data[0][1] + data[1][1], formatter(0, 1))
return StatData(title, grid + [left, right, top, bottom])

@property
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "natal"
version = "0.6.2"
version = "0.6.3"
description = "create Natal Chart with ease"
license = "MIT"
repository = "https://github.com/hoishing/natal"
Expand Down
8 changes: 8 additions & 0 deletions tests/test_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,3 +303,11 @@ def test_inner_planets_cross_ref_grid(inner_planets_cross_ref_grid):
d2 = Data(**person2)
stats = Stats(data1=d1, data2=d2)
assert stats.cross_ref.grid == inner_planets_cross_ref_grid

def test_display_no_entities():
display = Display(**dict.fromkeys(Display(), False))
stats = Stats(data1=Data(**person1, config=Config(display=display)))
assert stats.quadrant.grid[1][1] == 0
assert stats.quadrant.grid[1][2] == ""
assert stats.hemisphere.grid[1][1] == 0
assert stats.hemisphere.grid[1][2] == ""

0 comments on commit 342e3ed

Please sign in to comment.