Skip to content

Commit

Permalink
fix: change pop to indexing to get list element #203 (#204)
Browse files Browse the repository at this point in the history
Co-authored-by: Mattijn van Hoek <[email protected]>
  • Loading branch information
aspyk and mattijn authored Oct 11, 2023
1 parent e1b50aa commit a6f9dc4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions tests/test_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,13 +481,17 @@ def test_extract_read_geojson_from_json_dict():
def test_extract_read_multiple_gdf_object_name():
world = geopandas.read_file("tests/files_shapefile/static_natural_earth.gpkg")
world = world[["CONTINENT", "geometry", "POP_EST"]]
continents = world.dissolve(by="CONTINENT", aggfunc="sum")
continents_sum = world.dissolve(by="CONTINENT", aggfunc="sum")
continents_mean = world.dissolve(by="CONTINENT", aggfunc="mean")

topo = Extract(
data=[world, continents], options={"object_name": ["world", "continents"]}
data=[world, continents_sum, continents_mean],
options={"object_name": ["world", "continents_sum", "continents_mean"]},
).to_dict()

assert len(topo["objects"]) == len(world) + len(continents)
assert len(topo["objects"]) == (
len(world) + len(continents_sum) + len(continents_mean)
)


def test_extract_read_multiple_gjson_object_name():
Expand Down
2 changes: 1 addition & 1 deletion topojson/core/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ def _extract_list(self, geom):
subgeom["__geom_name"] = self.options.object_name[ix]
geom[ix] = dict(enumerate(subgeom.to_dict(orient="records"), start))
for ix in range(1, len(geom)):
geom[0].update(geom.pop(ix))
geom[0].update(geom[ix])
data = geom[0]
self._is_multi_geom = True
else:
Expand Down

0 comments on commit a6f9dc4

Please sign in to comment.