|
2 | 2 | import os
|
3 | 3 | import unittest
|
4 | 4 | import tempfile
|
| 5 | +from typing import List, Union |
5 | 6 |
|
6 | 7 | import pystac
|
7 | 8 | from pystac import Catalog, Item, CatalogType
|
@@ -30,6 +31,59 @@ def test_rel_types(self) -> None:
|
30 | 31 | self.assertEqual(str(LabelRelType.SOURCE), "source")
|
31 | 32 |
|
32 | 33 |
|
| 34 | +class LabelTaskTest(unittest.TestCase): |
| 35 | + def test_rel_types(self) -> None: |
| 36 | + self.assertEqual(str(LabelTask.REGRESSION), "regression") |
| 37 | + self.assertEqual(str(LabelTask.CLASSIFICATION), "classification") |
| 38 | + self.assertEqual(str(LabelTask.DETECTION), "detection") |
| 39 | + self.assertEqual(str(LabelTask.SEGMENTATION), "segmentation") |
| 40 | + |
| 41 | + |
| 42 | +class LabelCountTest(unittest.TestCase): |
| 43 | + def test_label_count_equality(self) -> None: |
| 44 | + count1 = LabelCount.create(name="prop", count=1) |
| 45 | + count2 = LabelCount.create(name="prop", count=1) |
| 46 | + count3 = LabelCount.create(name="other", count=1) |
| 47 | + count4 = LabelCount.create(name="prop", count=2) |
| 48 | + |
| 49 | + self.assertEqual(count1, count2) |
| 50 | + self.assertNotEqual(count1, count3) |
| 51 | + self.assertNotEqual(count1, count4) |
| 52 | + self.assertNotEqual(count1, 42) |
| 53 | + |
| 54 | + |
| 55 | +class LabelOverviewTest(unittest.TestCase): |
| 56 | + def test_label_count_equality(self) -> None: |
| 57 | + stats1 = LabelStatistics.create(name="prop", value=42.3) |
| 58 | + count1 = LabelCount.create(name="prop", count=1) |
| 59 | + |
| 60 | + overview1 = LabelOverview.create( |
| 61 | + property_key="first", counts=[count1], statistics=[stats1] |
| 62 | + ) |
| 63 | + overview2 = LabelOverview.create( |
| 64 | + property_key="first", counts=[count1], statistics=[stats1] |
| 65 | + ) |
| 66 | + overview3 = LabelOverview.create(property_key="first", counts=[count1]) |
| 67 | + overview4 = LabelOverview.create(property_key="first", statistics=[stats1]) |
| 68 | + self.assertEqual(overview1, overview2) |
| 69 | + self.assertNotEqual(overview1, overview3) |
| 70 | + self.assertNotEqual(overview1, overview4) |
| 71 | + self.assertNotEqual(overview1, 42) |
| 72 | + |
| 73 | + |
| 74 | +class LabelStatisticsTest(unittest.TestCase): |
| 75 | + def test_label_statistics_equality(self) -> None: |
| 76 | + stats1 = LabelStatistics.create(name="prop", value=42.3) |
| 77 | + stats2 = LabelStatistics.create(name="prop", value=42.3) |
| 78 | + stats3 = LabelStatistics.create(name="other", value=42.3) |
| 79 | + stats4 = LabelStatistics.create(name="prop", value=73.4) |
| 80 | + |
| 81 | + self.assertEqual(stats1, stats2) |
| 82 | + self.assertNotEqual(stats1, stats3) |
| 83 | + self.assertNotEqual(stats1, stats4) |
| 84 | + self.assertNotEqual(stats1, 42) |
| 85 | + |
| 86 | + |
33 | 87 | class LabelTest(unittest.TestCase):
|
34 | 88 | def setUp(self) -> None:
|
35 | 89 | self.maxDiff = None
|
|
0 commit comments