Skip to content

Commit

Permalink
Always return a str when using hv.Dimension.pprint_value
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro committed Aug 9, 2022
1 parent ad59a3f commit 0d34c0b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion holoviews/core/dimension.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ def pprint_value(self, value, print_unit=False):
else:
formatted_value = formatter % value
else:
formatted_value = bytes_to_unicode(value)
formatted_value = str(bytes_to_unicode(value))

if print_unit and self.unit is not None:
formatted_value = formatted_value + ' ' + bytes_to_unicode(self.unit)
Expand Down
6 changes: 6 additions & 0 deletions holoviews/tests/core/test_dimensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ def test_name_dimension_repr_params_eval_equality(self):
dim = Dimension('test', label='Test Dimension', unit='m')
self.assertEqual(eval(repr(dim)) == dim, True)

def test_pprint_value_boolean(self):
# https://github.com/holoviz/holoviews/issues/5378
dim = Dimension('test')
self.assertEqual(dim.pprint_value(True), 'True')
self.assertEqual(dim.pprint_value(False), 'False')


class DimensionEqualityTest(ComparisonTestCase):

Expand Down

0 comments on commit 0d34c0b

Please sign in to comment.