Exemple #1
0
 def test_writeLabelsAscii(self):
     labelsData = labels.readBinary("labels.binary")
     labels.writeAscii(labelsData, self._testMethodName + "labels.ascii")
     with open(self._testMethodName + "labels.ascii", "r") as f:
         actualData = f.read().splitlines()
     with open("labels.ascii", "r") as f:
         expectedData = f.read().splitlines()
     for i in range(len(actualData)):
         self.assertEqual(expectedData[i], actualData[i])
     os.remove(self._testMethodName + "labels.ascii")
Exemple #2
0
 def test_writeLabelsAscii(self):
     labelsData = labels.readBinary(LABELS_FILE_BIN)
     labels.writeAscii(labelsData, self._testMethodName + "labels.ascii")
     with open(self._testMethodName + "labels.ascii", "r") as f:
         actualData = f.read().splitlines()
     with open(LABELS_FILE_ASCII) as f:
         expectedData = f.read().splitlines()
     for expected, actual in zip(expectedData, actualData):
         self.assertEqual(expected, actual)
     os.remove(self._testMethodName + "labels.ascii")
Exemple #3
0
 def test_readLabelsBinary(self):
     expectedName = "LABELS"
     expectedTrianglesPerHex = 6
     expectedNumZones = 5800
     expectedNumRegions = 2900
     expectedNumHexagonalRings = 13
     labelsData = labels.readBinary(os.path.join("labels.binary"))
     self.assertEqual(labelsData._metadata["hname"], expectedName)  # pylint: disable=protected-access
     self.assertEqual(labelsData._metadata["numTrianglesPerHex"],
                      expectedTrianglesPerHex)  # pylint: disable=protected-access
     self.assertEqual(labelsData._metadata["numZones"], expectedNumZones)  # pylint: disable=protected-access
     self.assertEqual(labelsData._metadata["numRegions"],
                      expectedNumRegions)  # pylint: disable=protected-access
     self.assertEqual(labelsData._metadata["numHexagonalRings"],
                      expectedNumHexagonalRings)  # pylint: disable=protected-access
Exemple #4
0
 def test_readLabelsBinary(self):
     expectedName = "LABELS"
     expectedTrianglesPerHex = 6
     expectedNumZones = 5800
     expectedNumRegions = 2900
     expectedNumHexagonalRings = 13
     labelsData = labels.readBinary(LABELS_FILE_BIN)
     self.assertEqual(labelsData.metadata["hname"], expectedName)
     self.assertEqual(
         labelsData.metadata["numTrianglesPerHex"], expectedTrianglesPerHex
     )
     self.assertEqual(labelsData.metadata["numZones"], expectedNumZones)
     self.assertEqual(labelsData.metadata["numRegions"], expectedNumRegions)
     self.assertEqual(
         labelsData.metadata["numHexagonalRings"], expectedNumHexagonalRings
     )
     self.assertEqual(len(labelsData.regionLabels), expectedNumRegions)
Exemple #5
0
 def _readGeometry(self):
     """Read basic region labels and geometry information into memory."""
     self._geom = geodst.readBinary(geodst.GEODST)
     self._labels = labels.readBinary(labels.LABELS)