|
| 1 | +from hub.schema import Segmentation |
1 | 2 | from hub.schema.class_label import ClassLabel, _load_names_from_file |
2 | 3 | from hub.schema.features import HubSchema, SchemaDict |
3 | 4 | import pytest |
@@ -49,9 +50,31 @@ def test_feature_dict_repr(): |
49 | 50 | assert expected_output == feature_dict_object.__repr__() |
50 | 51 |
|
51 | 52 |
|
| 53 | +def test_segmentation_repr(): |
| 54 | + seg1 = Segmentation(shape=(3008, 3008), dtype="uint8", num_classes=5) |
| 55 | + seg2 = Segmentation(shape=(3008, 3008), dtype="uint8", names=["apple", "orange", "banana"]) |
| 56 | + |
| 57 | + text1 = "Segmentation(shape=(3008, 3008), dtype='uint8', num_classes=5)" |
| 58 | + text2 = "Segmentation(shape=(3008, 3008), dtype='uint8', names=['apple', 'orange', 'banana'], num_classes=3)" |
| 59 | + assert seg1.__repr__() == text1 |
| 60 | + assert seg2.__repr__() == text2 |
| 61 | + |
| 62 | + |
| 63 | +def test_classlabel_repr(): |
| 64 | + cl1 = ClassLabel(num_classes=5) |
| 65 | + cl2 = ClassLabel(names=["apple", "orange", "banana"]) |
| 66 | + |
| 67 | + text1 = "ClassLabel(shape=(), dtype='int64', num_classes=5)" |
| 68 | + text2 = "ClassLabel(shape=(), dtype='int64', names=['apple', 'orange', 'banana'], num_classes=3)" |
| 69 | + assert cl1.__repr__() == text1 |
| 70 | + assert cl2.__repr__() == text2 |
| 71 | + |
| 72 | + |
52 | 73 | if __name__ == "__main__": |
53 | 74 | test_load_names_from_file() |
54 | 75 | test_class_label() |
55 | 76 | test_hub_feature_flatten() |
56 | 77 | test_feature_dict_str() |
57 | 78 | test_feature_dict_repr() |
| 79 | + test_classlabel_repr() |
| 80 | + test_segmentation_repr() |
0 commit comments