Skip to content

Commit

Permalink
Merge 763ee0a into a837840
Browse files Browse the repository at this point in the history
  • Loading branch information
slobodan-ilic committed May 1, 2019
2 parents a837840 + 763ee0a commit 0f38246
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/cr/cube/dimension.py
Original file line number Diff line number Diff line change
Expand Up @@ -730,9 +730,15 @@ def anchor(self):
represents missing data.
"""
anchor = self._subtotal_dict["anchor"]

if anchor is None:
# In the case of undefined anchor default to "bottom"
return "bottom"

try:
anchor = int(anchor)
if anchor not in self.valid_elements.element_ids:
# In the case of a non-valid int id, default to "bottom"
return "bottom"
return anchor
except (TypeError, ValueError):
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/test_dimension.py
Original file line number Diff line number Diff line change
Expand Up @@ -1135,6 +1135,8 @@ def addend_ids_fixture(self, request):
({"anchor": 1}, {1, 2, 3}, 1),
({"anchor": 4}, {1, 2, 3}, "bottom"),
({"anchor": "Top"}, {1, 2, 3}, "top"),
# For an undefined anchor default to "bottom"
({"anchor": None}, {1, 2, 3}, "bottom"),
]
)
def anchor_fixture(self, request):
Expand Down

0 comments on commit 0f38246

Please sign in to comment.