]> gitweb.michael.orlitzky.com - dead/census-tools.git/commitdiff
Removed unused code from the GPS and SummaryFile1 modules.
authorMichael Orlitzky <michael@orlitzky.com>
Mon, 28 Sep 2009 02:26:56 +0000 (22:26 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Mon, 28 Sep 2009 02:26:56 +0000 (22:26 -0400)
Removed the tests utilizing that unused code.

src/GPS.py
src/SummaryFile1.py
src/Tests/Unit/SummaryFile1Test.py

index bc2e20be64b5e04e62ea836369aa73ae601de4fe..acd8e9c570da0f2f12d921a84e5a8b0d22e39d9c 100644 (file)
@@ -7,15 +7,3 @@ class Coordinates:
     def __init__(self):
         self.latitude = 0
         self.longitude = 0
-        
-
-
-def CalculateDistance(p1, p2):
-    """
-    Calculate the distance between two Coordinates, p1 and p2.
-    """
-    delta_x = p2.longitude - p1.longitude
-    delta_y = p2.latitude - p1.latitude
-    euclidean_distance = sqrt(delta_x**2 + delta_y**2)
-    
-    return euclidean_distance
index d646b07e70df62fd9bc0c7d478626840fe91ab7d..7105ff42bfcc8375bdf616c3de1fe81d42c52b46 100644 (file)
@@ -410,32 +410,3 @@ class GeoRecordParser:
           
         
         return record
-    
-
-
-def FindClosestBlock(blocks, target_coords):
-    """
-    Find the closest block (from within blocks) to the GPS
-    coordinates given by target_coords.
-    """
-
-    # Empty by default. Hopefully we're passed some blocks.
-    closest_block = None
-    min_distance = 999999999.0 # Don't look at me like that.
-
-    for block in blocks:
-        this_distance = GPS.CalculateDistance(target_coords, block.coordinates)
-        if (this_distance < min_distance):
-            closest_block = block
-            min_distance = this_distance
-
-    return closest_block
-
-
-
-def FindAveragePopulationDensity(coords, geo_file_path):
-    grp = GeoRecordParser()
-    blocks = grp.parse_blocks(geo_file_path)
-    closest_block = FindClosestBlock(blocks, coords)
-    
-    return closest_block.population_density()
index 18825dde9c10d3ced05cade2364173948c70d0b2..ca187b5c4aa3207f3811b013cf37642579cbc1b0 100644 (file)
@@ -85,50 +85,11 @@ class GeoRecordParserTest(unittest.TestCase):
          fixture_path = Tests.Fixtures.Path() + '/SummaryFile1/mdgeo.uf1'
          blocks = self.grp.parse_blocks(fixture_path)
          self.assertEqual(len(blocks), 79128)
-
-
-class SummaryFile1Test(unittest.TestCase):
-
-    def testEachBlockIsClosestToItself(self):
-        blocks_path = Tests.Fixtures.Path() + '/SummaryFile1/mdgeo.uf1'
-        grp = SummaryFile1.GeoRecordParser()
-        blocks = grp.parse_blocks(blocks_path)
-
-        # Only test 100 of these guys (or however many blocks there
-        # are in those 100 records.
-        fixtures_path = Tests.Fixtures.Path() + '/SummaryFile1/one_hundred_records.txt'
-        fixtures = grp.parse_blocks(fixtures_path)
-        
-        for b in fixtures:
-            # It's probably unnecessary to copy the coordinates
-            # into a new instance here, but whatever.
-            b_coords = GPS.Coordinates()
-            b_coords.latitude = b.coordinates.latitude
-            b_coords.longitude = b.coordinates.longitude
-            
-            closest_block = SummaryFile1.FindClosestBlock(blocks, b_coords)
-            self.assertEqual(b.block, closest_block.block)
-
-
-    def testEachBlockHasItsOwnAverageDensity(self):
-        geo_file_path = Tests.Fixtures.Path() + '/SummaryFile1/mdgeo.uf1'
-
-        # Only test 5 of these guys; they take longer.
-        grp = SummaryFile1.GeoRecordParser()
-        fixtures_path = Tests.Fixtures.Path() + '/SummaryFile1/five_blocks.txt'
-        fixtures = grp.parse_blocks(fixtures_path)
-        
-        for b in fixtures:
-            # It's probably unnecessary to copy the coordinates
-            # into a new instance here, but whatever.
-            avg_density = SummaryFile1.FindAveragePopulationDensity(b.coordinates, geo_file_path)
-            self.assertEqual(b.population_density(), avg_density)
-            
+           
     
 def suite():
     suite = unittest.TestSuite()
     suite.addTest(unittest.makeSuite(GeoRecordParserTest))
-    suite.addTest(unittest.makeSuite(SummaryFile1Test))
     suite.addTest(unittest.makeSuite(BlockTest))
     return suite