Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geocoding 2.0 #304

Merged
merged 79 commits into from
Jan 29, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
173d618
Put parents into regions dataframe and geodataframe
IKupriyanov-HORIS Sep 11, 2020
c8f8d1b
Implementing parents in regions_builder.
IKupriyanov-HORIS Sep 14, 2020
1fccca9
Merge branch 'master' into geoservices-1.1.0
IKupriyanov-HORIS Sep 14, 2020
6fef609
WIP: parents
IKupriyanov-HORIS Sep 15, 2020
9b5ae98
Fix tests, sync protocol with server
IKupriyanov-HORIS Sep 15, 2020
38f1db7
Fix more tests
IKupriyanov-HORIS Sep 16, 2020
54b4457
Fix more tests
IKupriyanov-HORIS Sep 25, 2020
299b6aa
New server IP in demo
IKupriyanov-HORIS Sep 25, 2020
701f78c
Merge branch 'master' into geoservices-1.1.0
IKupriyanov-HORIS Oct 5, 2020
a37a3f5
WIP: answers in protocol
IKupriyanov-HORIS Oct 14, 2020
f6ca8a3
WIP: moving to Answers instead of flat list of GeocodedFeature
IKupriyanov-HORIS Oct 14, 2020
52e7c1f
WIP: link between request and response
IKupriyanov-HORIS Oct 15, 2020
be18cc5
Getting rid of a query string from Answer and GeocodedFeature
IKupriyanov-HORIS Oct 17, 2020
e8219a8
Remove query from Answer and GeocodedFeature
IKupriyanov-HORIS Oct 19, 2020
326550b
Fix assertion condition
IKupriyanov-HORIS Oct 20, 2020
f6fc7c8
Remove chunked requests, better docs for new API
IKupriyanov-HORIS Oct 20, 2020
cbc1745
WIP: scope
IKupriyanov-HORIS Oct 21, 2020
02aa0ba
Merge branch 'master' into geoservices-1.1.0
IKupriyanov-HORIS Oct 21, 2020
cca501d
Update example with counties
IKupriyanov-HORIS Oct 22, 2020
91b027a
Update example with counties
IKupriyanov-HORIS Oct 22, 2020
21ec386
Basic support for scope in the new geocoding API
IKupriyanov-HORIS Oct 22, 2020
6f99bbe
Merge branch 'master' into geoservices-1.1.0
IKupriyanov-HORIS Oct 23, 2020
60968ca
Default scope value to None
IKupriyanov-HORIS Oct 26, 2020
f44d979
Unit tests for new geocoding API
IKupriyanov-HORIS Oct 28, 2020
9ed17b0
Merge branch 'master' into geoservices-1.1.0
IKupriyanov-HORIS Oct 28, 2020
539ef98
Merge branch 'master' into geoservices-1.1.0
IKupriyanov-HORIS Oct 28, 2020
4345821
Request validation, tests
IKupriyanov-HORIS Oct 28, 2020
648eef7
Experiment with map and nbviewer
IKupriyanov-HORIS Oct 29, 2020
d492167
Experiment with map and nbviewer and stamen tiles
IKupriyanov-HORIS Oct 29, 2020
bc846fa
Better parents/scope support, more tests
IKupriyanov-HORIS Oct 30, 2020
dcfd17b
where(..., near=..., within=...)
IKupriyanov-HORIS Nov 2, 2020
41e0ce1
Better error handling
IKupriyanov-HORIS Nov 3, 2020
26804b4
Tests for not available features in new API
IKupriyanov-HORIS Nov 4, 2020
fbd7c50
Better error handling for where function (missing key, scope and othe…
IKupriyanov-HORIS Nov 5, 2020
c444036
map_join with multikeys
IKupriyanov-HORIS Nov 14, 2020
0e213d9
Merge branch 'master' into geoservices-1.1.0
IKupriyanov-HORIS Nov 14, 2020
f7f5df8
Single key data_join_on and map_join_on.
IKupriyanov-HORIS Nov 15, 2020
a31ca74
Multi key data_join_on and map_join_on.
IKupriyanov-HORIS Nov 16, 2020
1f69608
Merge branch 'master' into geoservices-1.1.0
IKupriyanov-HORIS Nov 23, 2020
08f250f
map_join with dups, but livemap fails with null values in data
IKupriyanov-HORIS Nov 24, 2020
71060c2
Merge branch 'master' into geoservices-1.1.0
IKupriyanov-HORIS Nov 25, 2020
6c5f57b
Handle null values in pie/bar
IKupriyanov-HORIS Nov 26, 2020
cec1bdc
LP-62
IKupriyanov-HORIS Nov 27, 2020
c5375fb
Better error message on using scope with parents
IKupriyanov-HORIS Dec 4, 2020
5a2569d
Better error message for invalid scope type, countries request suppor…
IKupriyanov-HORIS Dec 7, 2020
4926246
More tests for us-48
IKupriyanov-HORIS Dec 8, 2020
c7c72ba
Merge branch 'master' into geoservices-1.1.0
IKupriyanov-HORIS Dec 8, 2020
dc5a21f
Merge branch 'master' into geoservices-1.1.0
IKupriyanov-HORIS Dec 14, 2020
b0ba74f
WIP: changing public API
IKupriyanov-HORIS Dec 15, 2020
536ed25
Merge branch 'master' into geoservices-1.1.0
IKupriyanov-HORIS Dec 18, 2020
fe750f7
Support Geocoder as geom_xxx(map=...) parameter
IKupriyanov-HORIS Dec 21, 2020
c317a16
Merge branch 'master' into geoservices-1.1.0
IKupriyanov-HORIS Dec 21, 2020
7531be1
Code cleanup, more tests
IKupriyanov-HORIS Dec 22, 2020
425fef3
Copy not matched dups from map on map_join (fix for last cell in geop…
IKupriyanov-HORIS Dec 23, 2020
ed5f0ea
Use single entry parent for all names
IKupriyanov-HORIS Dec 23, 2020
371525a
Fix empty result for select all kind of request
IKupriyanov-HORIS Dec 24, 2020
481b90d
where -> scope, near -> closest_to, single entry scope, remove auto-c…
IKupriyanov-HORIS Jan 11, 2021
4f3e114
Merge branch 'master' into geoservices-1.1.0
IKupriyanov-HORIS Jan 11, 2021
5002f32
Merge branch 'master' into geoservices-1.1.0
IKupriyanov-HORIS Jan 11, 2021
d316cbe
Remove MapRegion from 'scope' type error message
IKupriyanov-HORIS Jan 13, 2021
bfe2d0b
scope can now be used with county and state. scope and country will c…
IKupriyanov-HORIS Jan 14, 2021
f1a3014
Merge branch 'master' into geoservices-1.1.0
IKupriyanov-HORIS Jan 18, 2021
e747a7e
Handle any Iterable types in parents functions (counties/states/count…
IKupriyanov-HORIS Jan 20, 2021
3915dba
Enable gzip for geocoding responses
IKupriyanov-HORIS Jan 21, 2021
d8b1fac
Merge branch 'master' into geoservices-1.1.0
IKupriyanov-HORIS Jan 21, 2021
93c7aaa
Update docs
IKupriyanov-HORIS Jan 21, 2021
f1e98cd
Update docs
IKupriyanov-HORIS Jan 21, 2021
4b4a9ba
Keep original query name for ambiguous result with allow_ambiguous flag
IKupriyanov-HORIS Jan 22, 2021
ffaaab8
Fix error message
IKupriyanov-HORIS Jan 22, 2021
50156ed
Remove method to_data_frame and interface CanToDataFrame
IKupriyanov-HORIS Jan 25, 2021
8131764
WIP: update geocoding.md
IKupriyanov-HORIS Jan 26, 2021
1917b39
WIP: update geocoding.md
IKupriyanov-HORIS Jan 26, 2021
a908666
Revert changes to builder.ipynb
IKupriyanov-HORIS Jan 26, 2021
ff331eb
WIP: update geocoding.md
IKupriyanov-HORIS Jan 26, 2021
b6fa9b4
Use geocoding level instead of 'request' for a column name, remove da…
IKupriyanov-HORIS Jan 28, 2021
851fa40
Merge branch 'master' into geoservices-1.1.0
IKupriyanov-HORIS Jan 28, 2021
83002eb
Support Geocoder in ggplot(data=...)
IKupriyanov-HORIS Jan 29, 2021
99bd3c3
Switch to the new geocoding server
IKupriyanov-HORIS Jan 29, 2021
a203c3b
Merge branch 'master' into geoservices-1.1.0
IKupriyanov-HORIS Jan 29, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove query from Answer and GeocodedFeature
  • Loading branch information
IKupriyanov-HORIS committed Oct 19, 2020
commit e8219a8e21ee5e04657c2eb4947cf83e894ed5ce
7 changes: 2 additions & 5 deletions python-package/lets_plot/geo_data/gis/json_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,10 @@ def parse(response_json: Dict) -> Response:
def _parse_answers(answers_json: List[Dict], response: ResponseBuilder):
answers: List[Answer] = []
for answer_json in answers_json:
query = answer_json.get(ResponseField.query.value)
features_json = answer_json.get(ResponseField.features.value, [])
geocoded_features: List[GeocodedFeature] = []
for feature_json in features_json:
feature = FeatureBuilder().set_query(query)
feature = FeatureBuilder()

FluentDict(feature_json) \
.visit_str(ResponseField.geo_object_id, feature.set_id) \
Expand All @@ -95,7 +94,7 @@ def _parse_answers(answers_json: List[Dict], response: ResponseBuilder):
.visit_object_optional(ResponseField.position, lambda json: feature.set_position(ResponseParser._parse_rect(json)))

geocoded_features.append(feature.build_geocoded())
answers.append(Answer(query, geocoded_features))
answers.append(Answer(geocoded_features))

response.set_answers(answers)

Expand Down Expand Up @@ -169,7 +168,6 @@ def _format_answer(answer: Answer) -> Dict:
for feature in answer.features:
features.append(
FluentDict() \
.put(ResponseField.query, feature.query) \
.put(ResponseField.geo_object_id, feature.id) \
.put(ResponseField.name, feature.name) \
.put(ResponseField.boundary, ResponseFormatter._format_boundary(feature.boundary)) \
Expand All @@ -180,7 +178,6 @@ def _format_answer(answer: Answer) -> Dict:
)

return FluentDict() \
.put(ResponseField.query, answer.query) \
.put(ResponseField.features, features) \
.to_dict()

Expand Down
14 changes: 5 additions & 9 deletions python-package/lets_plot/geo_data/gis/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ def __init__(self, geometry: Union[Multipolygon, Polygon, GeoPoint]):


class GeocodedFeature:
def __init__(self, query: Optional[str], id: str, name: str,
def __init__(self,
id: str, name: str,
highlights: Optional[List[str]],
boundary: Optional[Boundary],
centroid: Optional[GeoPoint],
limit: Optional[GeoRect],
position: Optional[GeoRect]):
assert_optional_type(query, str)
assert_type(id, str)
assert_type(name, str)
assert_optional_list_type(highlights, str)
Expand All @@ -51,7 +51,6 @@ def __init__(self, query: Optional[str], id: str, name: str,
assert_optional_type(limit, GeoRect)
assert_optional_type(position, GeoRect)

self.query: Optional[str] = query # optional for requests like find all countries
self.id: str = id
self.name: str = name
self.highlights: Optional[List[str]] = highlights
Expand All @@ -78,11 +77,8 @@ def __init__(self, message: str):
self.message: str = message

class Answer:
def __init__(self, query: Optional[str], features: List[GeocodedFeature]):
assert_optional_type(query, str)
def __init__(self, features: List[GeocodedFeature]):
assert_list_type(features, GeocodedFeature)

self.query: Optional[str] = query
self.features: List[GeocodedFeature] = features


Expand Down Expand Up @@ -193,7 +189,7 @@ def build_ambiguous(self) -> AmbiguousFeature:
return AmbiguousFeature(self.query, self.total_namesake_count, self.namesake_examples)

def build_geocoded(self) -> GeocodedFeature:
return GeocodedFeature(self.query, self.id, self.name, self.highlights, self.boundary, self.centroid, self.limit, self.position)
return GeocodedFeature(self.id, self.name, self.highlights, self.boundary, self.centroid, self.limit, self.position)


class ResponseBuilder:
Expand Down Expand Up @@ -235,7 +231,7 @@ def set_geocoded_features(self, v: List[GeocodedFeature]):
Exactly matching non-exploding features, i.e. one feature per answer
'''
assert_list_type(v, GeocodedFeature)
self.answers = [Answer(f.query, [f]) for f in v]
self.answers = [Answer([f]) for f in v]
return self


Expand Down
2 changes: 1 addition & 1 deletion python-package/lets_plot/geo_data/regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class Regions(CanToDataFrame):
def __init__(self, level_kind: LevelKind, answers: List[Answer], queries: List[RegionQuery], highlights: bool = False):
assert_list_type(answers, Answer)
assert_list_type(queries, RegionQuery)
assert len(queries) == 0 or len(answers) == len(queries)
assert len(answers) == len(queries)

try:
import geopandas
Expand Down
16 changes: 11 additions & 5 deletions python-package/lets_plot/geo_data/regions_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def _create_queries(request: request_types, scope: scope_types, ambiguity_resovl
positional_matching = isinstance(scopes, list)

if positional_matching:
if len(requests) != len(scopes):
if requests is not None and len(requests) != len(scopes):
raise ValueError('Length of request and scope is not equal')

return [
Expand Down Expand Up @@ -93,9 +93,15 @@ def ensure_is_parent_list(obj):
states = ensure_is_parent_list(states)
counties = ensure_is_parent_list(counties)

assert countries is None or len(countries) == len(requests)
assert states is None or len(states) == len(requests)
assert counties is None or len(counties) == len(requests)

if countries is not None and len(countries) == len(requests):
raise ValueError('Countries count({}) != names count({})'.format(len(countries), len(requests)))

if states is not None and len(states) == len(requests):
raise ValueError('States count({}) != names count({})'.format(len(states), len(requests)))

if counties is not None and len(counties) == len(requests):
raise ValueError('Counties count({}) != names count({})'.format(len(counties), len(requests)))

queries = []
for i in range(len(requests)):
Expand Down Expand Up @@ -269,7 +275,7 @@ def _get_queries(self) -> List[RegionQuery]:
self._queries.append(overriding)

if len(self._queries) == 0:
return []
return [RegionQuery(request=None, scope=None, ambiguity_resolver=self._default_ambiguity_resolver)]

return [
RegionQuery(
Expand Down
24 changes: 11 additions & 13 deletions python-package/test/geo_data/geo_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,13 @@ def assert_found_names(df: DataFrame, names: List[str]):
def make_geocode_region(request: str, name: str, geo_object_id: str, highlights: List[str], level_kind: LevelKind = LevelKind.city) -> Regions:
return Regions(
level_kind=level_kind,
answers=[make_region(request, name, geo_object_id, highlights)],
queries=[RegionQuery(request=request)]
queries=[RegionQuery(request=request)],
answers=[make_region(name, geo_object_id, highlights)]
)


def make_region(request: str, name: str, geo_object_id: str, highlights: List[str]) -> Answer:
return Answer(request,
[FeatureBuilder() \
.set_query(request) \
def make_region(name: str, geo_object_id: str, highlights: List[str]) -> Answer:
return Answer([FeatureBuilder() \
.set_name(name) \
.set_id(geo_object_id) \
.set_highlights(highlights) \
Expand Down Expand Up @@ -252,12 +250,12 @@ def get_map_data_meta(plotSpec, layerIdx: int) -> dict:



def assert_names(df: DataFrame, index: int, name=NAME, found_name=FOUND_NAME):
def assert_names(df: DataFrame, index: int, name=FOUND_NAME, found_name=FOUND_NAME):
assert name == df[DF_REQUEST][index]
assert found_name == df[DF_FOUND_NAME][index]


def assert_limit(limit: DataFrame, index: int, name=NAME, found_name=FOUND_NAME):
def assert_limit(limit: DataFrame, index: int, name=FOUND_NAME, found_name=FOUND_NAME):
assert_names(limit, index, name, found_name)

min_lon = limit['lonmin'][index]
Expand All @@ -270,12 +268,12 @@ def assert_limit(limit: DataFrame, index: int, name=NAME, found_name=FOUND_NAME)
assert GEO_RECT_MAX_LAT == max_lat


def assert_centroid(centroid: DataFrame, index: int, name=NAME, found_name=FOUND_NAME, lon=CENTROID_LON, lat=CENTROID_LAT):
def assert_centroid(centroid: DataFrame, index: int, name=FOUND_NAME, found_name=FOUND_NAME, lon=CENTROID_LON, lat=CENTROID_LAT):
assert_names(centroid, index, name, found_name)
assert_point(centroid, index, lon, lat)


def assert_boundary(boundary: DataFrame, index: int, points: List[GJPoint], name=NAME, found_name=FOUND_NAME):
def assert_boundary(boundary: DataFrame, index: int, points: List[GJPoint], name=FOUND_NAME, found_name=FOUND_NAME):
assert_names(boundary, index, name, found_name)
for i, point in enumerate(points):
assert_point(boundary, index + i, lon(point), lat(point))
Expand All @@ -286,10 +284,10 @@ def assert_point(df: DataFrame, index: int, lon: float, lat: float):
assert lat == df[DF_LAT][index]

def feature_to_answer(feature: GeocodedFeature) -> Answer:
return Answer(feature.query, [feature])
return Answer([feature])

def features_to_answers(features: List[GeocodedFeature]) -> List[Answer]:
return [Answer(feature.query, [feature]) for feature in features]
return [Answer([feature]) for feature in features]

def features_to_queries(features: List[GeocodedFeature]) -> List[RegionQuery]:
return [RegionQuery(feature.query) for feature in features]
return [RegionQuery(feature.name) for feature in features]
1 change: 0 additions & 1 deletion python-package/test/geo_data/gis/assertions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


def assert_geocoded(expected: GeocodedFeature, actual: GeocodedFeature):
assert expected.query == actual.query
assert expected.id == actual.id
assert expected.name == actual.name
assert_point(expected.centroid, actual.centroid)
Expand Down
12 changes: 6 additions & 6 deletions python-package/test/geo_data/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ def test_regions_with_highlights(mock_geocoding):
None # progress_callback
)

FOO_FEATURE = FeatureBuilder().set_query('foo').set_name('fooname').set_id('fooid').build_geocoded()
BAR_FEATURE = FeatureBuilder().set_query('bar').set_name('barname').set_id('barid').build_geocoded()
FOO_FEATURE = FeatureBuilder().set_name('fooname').set_id('fooid').build_geocoded()
BAR_FEATURE = FeatureBuilder().set_name('barname').set_id('barid').build_geocoded()

FOO = Answer('foo', [FeatureBuilder().set_query('foo').set_name('fooname').set_id('fooid').build_geocoded()])
BAR = Answer('foo', [FeatureBuilder().set_query('foo').set_name('barname').set_id('barid').build_geocoded()])
FOO = Answer([FeatureBuilder().set_name('fooname').set_id('fooid').build_geocoded()])
BAR = Answer([FeatureBuilder().set_name('barname').set_id('barid').build_geocoded()])

@pytest.mark.parametrize('location,expected', [
# none
Expand Down Expand Up @@ -153,15 +153,15 @@ def test_regions_with_highlights(mock_geocoding):

# mix of strings and regions
([
'foo',
FOO_FEATURE.name,
Regions(
level_kind=LEVEL_KIND,
queries=features_to_queries([BAR_FEATURE]),
answers=features_to_answers([BAR_FEATURE])
)
],
[
MapRegion.with_name(FOO.query),
MapRegion.with_name(FOO_FEATURE.name),
MapRegion.scope([feature_id(BAR)])
]
)
Expand Down
3 changes: 1 addition & 2 deletions python-package/test/geo_data/test_georect.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,9 @@ def make_rect(lon_min: float, lon_max: float) -> GeoRect:
def data_frame(r: GeoRect):
return LimitsGeoDataFrame().to_data_frame(
answers=[
Answer(NAME, [
Answer([
FeatureBuilder() \
.set_id(ID) \
.set_query(NAME) \
.set_name(FOUND_NAME) \
.set_limit(r) \
.build_geocoded()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ def test_reverse_geocoding_of_nothing():


@pytest.mark.skipif(TURN_OFF_INTERACTION_TEST, reason='Need proper server ip')
@pytest.mark.skip
def test_only_one_sevastopol():
sevastopol = geodata.regions_xy(SEVASTOPOL_LON, SEVASTOPOL_LAT, 'city')

Expand Down
36 changes: 16 additions & 20 deletions python-package/test/geo_data/test_map_regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
RESOLUTION = 12


def assert_region_df(region_object, df, index=0):
assert region_object.query == df[DF_REQUEST][index]
def assert_region_df(region_object: FeatureBuilder, df, index=0):
assert region_object.name == df[DF_REQUEST][index]
assert region_object.id == df[DF_ID][index]
assert region_object.name == df[DF_FOUND_NAME][index]

Expand All @@ -42,17 +42,17 @@ def setup(self):
self.foo_id = 'foo_id'
self.foo_query = 'foo'
self.foo_name = 'Foo'
self.foo = FeatureBuilder().set_query(self.foo_query).set_id(self.foo_id).set_name(self.foo_name)
self.foo: FeatureBuilder = FeatureBuilder().set_query(self.foo_query).set_id(self.foo_id).set_name(self.foo_name)

self.bar_id = 'bar_id'
self.bar_query = 'bar'
self.bar_name = 'Bar'
self.bar = FeatureBuilder().set_query(self.bar_query).set_id(self.bar_id).set_name(self.bar_name)
self.bar: FeatureBuilder = FeatureBuilder().set_query(self.bar_query).set_id(self.bar_id).set_name(self.bar_name)

self.baz_id = 'baz_id'
self.baz_query = 'baz'
self.baz_name = 'Baz'
self.baz = FeatureBuilder().set_query(self.baz_query).set_id(self.baz_id).set_name(self.baz_name)
self.baz: FeatureBuilder = FeatureBuilder().set_query(self.baz_query).set_id(self.baz_id).set_name(self.baz_name)

@mock.patch.object(GeocodingService, 'do_request')
def test_boundaries(self, mock_request):
Expand Down Expand Up @@ -140,9 +140,9 @@ def test_exploding_answers_to_data_frame_take_request_from_feature_name(self, mo
level_kind=LevelKind.city,
queries=[RegionQuery(request=None)],
answers=[
Answer('', [
FeatureBuilder().set_id(foo_id).set_query('').set_name(foo_name).build_geocoded(),
FeatureBuilder().set_id(bar_id).set_query('').set_name(bar_name).build_geocoded()
Answer([
FeatureBuilder().set_id(foo_id).set_name(foo_name).build_geocoded(),
FeatureBuilder().set_id(bar_id).set_name(bar_name).build_geocoded()
])
]
)
Expand Down Expand Up @@ -181,9 +181,9 @@ def test_direct_answers_take_request_from_query(self, mock_request):
RegionQuery(request='bazz'),
],
answers=[
Answer('', [self.foo.set_query('').build_geocoded()]),
Answer('', [self.bar.set_query('').build_geocoded()]),
Answer('', [self.baz.set_query('').build_geocoded()]),
Answer([self.foo.set_query('').build_geocoded()]),
Answer([self.bar.set_query('').build_geocoded()]),
Answer([self.baz.set_query('').build_geocoded()]),
]
)

Expand Down Expand Up @@ -220,17 +220,17 @@ def test_df_rows_duplication_should_be_processed_correctly(self, mock_request):
level_kind=LevelKind.city,
queries=[RegionQuery('foo'), RegionQuery('bar'), RegionQuery('foo')],
answers=[
Answer('', [self.foo.build_geocoded()]),
Answer('', [self.bar.build_geocoded()]),
Answer('', [self.foo.build_geocoded()])
Answer([self.foo.build_geocoded()]),
Answer([self.bar.build_geocoded()]),
Answer([self.foo.build_geocoded()])
]
)

mock_request.return_value = make_success_response() \
.set_answers(
[
Answer(foo_id, [self.foo.set_query(foo_id).set_centroid(GeoPoint(0, 1)).build_geocoded()]),
Answer(bar_id, [self.bar.set_query(bar_id).set_centroid(GeoPoint(0, 1)).build_geocoded()])
Answer([self.foo.set_query(foo_id).set_centroid(GeoPoint(0, 1)).build_geocoded()]),
Answer([self.bar.set_query(bar_id).set_centroid(GeoPoint(0, 1)).build_geocoded()])
]
).build()

Expand All @@ -255,13 +255,11 @@ def test_plot_should_have_geometries_when_regions_in_map_parameter(self, mock_re
.set_geocoded_features(
[
FeatureBuilder() \
.set_query(USA_REQUEST) \
.set_id(USA_ID) \
.set_name(USA_NAME) \
.set_boundary(GeoPoint(0, 1))
.build_geocoded(),
FeatureBuilder() \
.set_query(RUSSIA_REQUEST) \
.set_id(RUSSIA_ID) \
.set_name(RUSSIA_NAME) \
.set_boundary(GeoPoint(0, 1))
Expand All @@ -285,14 +283,12 @@ def test_plot_should_have_geometries_when_regions_in_map_parameter(self, mock_re

def make_regions(self) -> Regions:
usa = FeatureBuilder() \
.set_query(USA_REQUEST) \
.set_name(USA_NAME) \
.set_id(USA_ID) \
.set_highlights(USA_HIGHLIGHTS) \
.build_geocoded()

russia = FeatureBuilder() \
.set_query(RUSSIA_REQUEST) \
.set_name(RUSSIA_NAME) \
.set_id(RUSSIA_ID) \
.set_highlights(RUSSIA_HIGHLIGHTS) \
Expand Down
Loading