Ejemplo n.º 1
0
 def setUp(self):
     self.df = pd.DataFrame({
         "id": [1],
         "address": ["This isn't an address."]
     })
     self.address = "address"
     self.geocoder = CobArcGISGeocoder(self.df, self.address)
     self.geocode_df = self.geocoder.geocode_df()
Ejemplo n.º 2
0
 def setUp(self):
     self.df = pd.DataFrame({
         "id": [1],
         "address": ["1 City Hall Plz, Boston, 02108"]
     })
     self.address = "address"
     self.geocoder = CobArcGISGeocoder(self.df, self.address)
     self.geocode_df = self.geocoder.geocode_df()
Ejemplo n.º 3
0
 def setUp(self):
     self.df = pd.DataFrame({
         "id": [1, 2],
         "address": ["89 Orleans Street Boston MA, 02128", None]
     })
     self.address = "address"
     self.geocoder = CobArcGISGeocoder(self.df, self.address)
     self.geocode_df_with_Nulls = self.geocoder.geocode_df()
Ejemplo n.º 4
0
 def setUp(self):
     self.df = pd.DataFrame({
         "id": [1],
         "address": ["89 Orleans Street Boston MA, 02128"]
     })
     self.address_to_geocode = self.df["address"][0]
     self.geocoder = CobArcGISGeocoder(self.df, self.address_to_geocode)
     self.candidates = self.geocoder._find_address_candidates(
         self.address_to_geocode)
Ejemplo n.º 5
0
 def setUp(self):
     SAM_Locators = ["SAM_Sub_Unit_A", "SAM_Alternate"]
     self.df = pd.DataFrame({
         "id": [1],
         "address": ["890 Commonwealth Avenue"]
     })
     self.address_to_geocode = self.df["address"][0]
     self.geocoder = CobArcGISGeocoder(self.df, self.address_to_geocode)
     self.candidates = self.geocoder._find_address_candidates(
         self.address_to_geocode)
     self.picked_candidate = self.geocoder._pick_address_candidate(
         self.candidates, SAM_Locators)
Ejemplo n.º 6
0
 def setUp(self):
     SAM_Locators = ["SAM_Sub_Unit_A", "SAM_Alternate"]
     self.df = pd.DataFrame({
         "id": [1],
         "address": ["89 Orleans Street Boston MA, 02128"]
     })
     self.address_to_geocode = self.df["address"][0]
     self.geocoder = CobArcGISGeocoder(self.df, self.address_to_geocode)
     self.candidates = self.geocoder._find_address_candidates(
         self.address_to_geocode)
     self.picked_candidate = self.geocoder._pick_address_candidate(
         self.candidates, SAM_Locators)
Ejemplo n.º 7
0
class TestReturnsNoneWhenNoCandidates(unittest.TestCase):
    def setUp(self):
        SAM_Locators = ["SAM_Sub_Unit_A", "SAM_Alternate"]
        self.df = pd.DataFrame({
            "id": [1],
            "address": ["This isn't an address"]
        })
        self.address_to_geocode = self.df["address"][0]
        self.geocoder = CobArcGISGeocoder(self.df, self.address_to_geocode)
        self.candidates = self.geocoder._find_address_candidates(
            self.address_to_geocode)
        self.picked_candidate = self.geocoder._pick_address_candidate(
            self.candidates, SAM_Locators)

    def test_returns_none_when_no_candidates(self):
        self.assertEqual(self.picked_candidate, None)
Ejemplo n.º 8
0
class TestAbleToReverseGeocodeToPointAddress(unittest.TestCase):
    def setUp(self):
        self.df = pd.DataFrame({"id": [1], "address": ["100 Legends Way"]})
        self.address = "address"
        self.geocoder = CobArcGISGeocoder(self.df, self.address)
        self.geocode_df = self.geocoder.geocode_df()

    def test_reverse_geocode_to_point_address(self):
        self.assertEqual(self.geocode_df["SAM_ID"][0], 340814)
Ejemplo n.º 9
0
 def setUp(self):
     self.df = pd.DataFrame({
         "id": [1, 2],
         "address": [
             "89 Orleans Street Boston MA, 02128",
             "51 Montebello Road Apt 2 Boston, MA 02130"
         ]
     })
     self.address = "address"
     self.geocoder = CobArcGISGeocoder(self.df, self.address)
Ejemplo n.º 10
0
class TestAbleToCorrectlyPickPointAddressCandidate(unittest.TestCase):
    def setUp(self):
        SAM_Locators = ["SAM_Sub_Unit_A", "SAM_Alternate"]
        self.df = pd.DataFrame({
            "id": [1],
            "address": ["89 Orleans Street Boston MA, 02128"]
        })
        self.address_to_geocode = self.df["address"][0]
        self.geocoder = CobArcGISGeocoder(self.df, self.address_to_geocode)
        self.candidates = self.geocoder._find_address_candidates(
            self.address_to_geocode)
        self.picked_candidate = self.geocoder._pick_address_candidate(
            self.candidates, SAM_Locators)

    def test_picks_highest_score_candidate(self):
        self.assertEqual(self.picked_candidate["score"], 94.57)

    def test_picks_expected_candidate(self):
        self.assertEqual(self.picked_candidate["attributes.Ref_ID"], 105967)
Ejemplo n.º 11
0
class TestReverseGeocodeFindsPoint(unittest.TestCase):
    def setUp(self):
        SAM_Locators = ["SAM_Sub_Unit_A", "SAM_Alternate"]
        self.df = pd.DataFrame({
            "id": [1],
            "address": ["890 Commonwealth Avenue"]
        })
        self.address_to_geocode = self.df["address"][0]
        self.geocoder = CobArcGISGeocoder(self.df, self.address_to_geocode)
        self.candidates = self.geocoder._find_address_candidates(
            self.address_to_geocode)
        self.picked_candidate = self.geocoder._pick_address_candidate(
            self.candidates, SAM_Locators)

    def test_returns_point_address(self):
        self.assertEqual(self.picked_candidate["attributes.Ref_ID"], 11864)

    def test_returns_correct_flag_point_addresses(self):
        self.assertEqual(self.picked_candidate["flag"],
                         "Able to geocode to a non-SAM address.")
Ejemplo n.º 12
0
class TestHandlesNotFindingAddressAsExpected(unittest.TestCase):
    def setUp(self):
        self.df = pd.DataFrame({
            "id": [1],
            "address": ["This isn't an address."]
        })
        self.address = "address"
        self.geocoder = CobArcGISGeocoder(self.df, self.address)
        self.geocode_df = self.geocoder.geocode_df()

    def test_reverse_geocode_to_point_address(self):
        self.assertEqual(self.geocode_df["flag"][0],
                         "Unable to geocode to any address.")
Ejemplo n.º 13
0
class TestAbleToFindPointAddress(unittest.TestCase):
    def setUp(self):
        self.df = pd.DataFrame({
            "id": [1],
            "address": ["1 City Hall Plz, Boston, 02108"]
        })
        self.address = "address"
        self.geocoder = CobArcGISGeocoder(self.df, self.address)
        self.geocode_df = self.geocoder.geocode_df()

    def test_returns_expected_address(self):
        print(self.geocode_df["SAM_ID"])
        self.assertEqual(self.geocode_df["SAM_ID"][0], 32856)
Ejemplo n.º 14
0
class TestAbleToHandleNullAddresses(unittest.TestCase):
    def setUp(self):
        self.df = pd.DataFrame({
            "id": [1, 2],
            "address": ["89 Orleans Street Boston MA, 02128", None]
        })
        self.address = "address"
        self.geocoder = CobArcGISGeocoder(self.df, self.address)
        self.geocode_df_with_Nulls = self.geocoder.geocode_df()

    def test_handle_null_address(self):
        self.assertEqual(self.geocode_df_with_Nulls.loc[:, "flag"][1],
                         "No address provided. Unable to geocode.")
Ejemplo n.º 15
0
class TestAbleToFindAddressCandidates(unittest.TestCase):
    def setUp(self):
        self.df = pd.DataFrame({
            "id": [1],
            "address": ["89 Orleans Street Boston MA, 02128"]
        })
        self.address_to_geocode = self.df["address"][0]
        self.geocoder = CobArcGISGeocoder(self.df, self.address_to_geocode)
        self.candidates = self.geocoder._find_address_candidates(
            self.address_to_geocode)

    def test_parameters_are_as_expected(self):
        print(self.candidates)
        self.assertGreaterEqual(len(self.candidates["candidates"]), 6)
Ejemplo n.º 16
0
 def setUp(self):
     self.df = pd.DataFrame({"id": [1], "address": ["100 Legends Way"]})
     self.address = "address"
     self.geocoder = CobArcGISGeocoder(self.df, self.address)
     self.geocode_df = self.geocoder.geocode_df()