コード例 #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()
コード例 #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()
コード例 #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()
コード例 #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)
コード例 #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)
コード例 #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)
コード例 #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)
コード例 #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)
コード例 #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)
コード例 #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)
コード例 #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.")
コード例 #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.")
コード例 #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)
コード例 #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.")
コード例 #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)
コード例 #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()