New upstream version 0.6.2
Bas Couwenberg
4 years ago
0 | 0 | Changes |
1 | 1 | ======= |
2 | 2 | |
3 | Version 0.6.1 (July 11, 2019) | |
4 | ----------------------------- | |
3 | ||
4 | Version 0.6.2 (November 18, 2019) | |
5 | --------------------------------- | |
6 | ||
7 | Small bug-fix release fixing a few regressions: | |
8 | ||
9 | - Fix a regression in passing an array of RRB(A) tuples to the ``.plot()`` | |
10 | method (#1178, #1211). | |
11 | - Fix the ``bounds`` and ``total_bounds`` attributes for empty GeoSeries, which | |
12 | also fixes the repr of an empty or all-NA GeoSeries (#1184, #1195). | |
13 | - Fix filtering of a GeoDataFrame to preserve the index type when ending up | |
14 | with an empty result (#1190). | |
15 | ||
16 | ||
17 | Version 0.6.1 (October 12, 2019) | |
18 | -------------------------------- | |
5 | 19 | |
6 | 20 | Small bug-fix release fixing a few regressions: |
7 | 21 |
7 | 7 | # ----------------------------------------------------------------------------- |
8 | 8 | |
9 | 9 | PANDAS_GE_024 = str(pd.__version__) >= LooseVersion("0.24.0") |
10 | PANDAS_GE_025 = str(pd.__version__) >= LooseVersion("0.25.0") | |
10 | 11 | |
11 | 12 | |
12 | 13 | # ----------------------------------------------------------------------------- |
21 | 21 | # setup.py/versioneer.py will grep for the variable names, so they must |
22 | 22 | # each be defined on a line of their own. _version.py will just call |
23 | 23 | # get_keywords(). |
24 | git_refnames = " (tag: v0.6.1)" | |
25 | git_full = "7df43d1375fee9174eb9314567c2464ed2d7e7a1" | |
24 | git_refnames = " (tag: v0.6.2, 0.6.x)" | |
25 | git_full = "34fe94357b8131afb49da76b1e5b14d9477f9e37" | |
26 | 26 | keywords = {"refnames": git_refnames, "full": git_full} |
27 | 27 | return keywords |
28 | 28 |
731 | 731 | |
732 | 732 | @property |
733 | 733 | def bounds(self): |
734 | # ensure that for empty arrays, the result has the correct shape | |
735 | if len(self) == 0: | |
736 | return np.empty((0, 4), dtype="float64") | |
734 | 737 | # need to explicitly check for empty (in addition to missing) geometries, |
735 | 738 | # as those return an empty tuple, not resulting in a 2D array |
736 | 739 | bounds = np.array( |
745 | 748 | |
746 | 749 | @property |
747 | 750 | def total_bounds(self): |
751 | if len(self) == 0: | |
752 | # numpy 'min' cannot handle empty arrays | |
753 | # TODO with numpy >= 1.15, the 'initial' argument can be used | |
754 | return np.array([np.nan, np.nan, np.nan, np.nan]) | |
748 | 755 | b = self.bounds |
749 | 756 | return np.array( |
750 | 757 | ( |
71 | 71 | # TODO do we want to raise / return normal DataFrame in this case? |
72 | 72 | if geometry is None and "geometry" in self.columns: |
73 | 73 | # only if we have actual geometry values -> call set_geometry |
74 | index = self.index | |
74 | 75 | try: |
75 | 76 | self["geometry"] = _ensure_geometry(self["geometry"].values) |
76 | 77 | except TypeError: |
77 | 78 | pass |
78 | 79 | else: |
80 | if self.index is not index: | |
81 | # With pandas < 1.0 and an empty frame (no rows), the index | |
82 | # gets reset to a default RangeIndex -> set back the original | |
83 | # index if needed | |
84 | self.index = index | |
79 | 85 | geometry = "geometry" |
80 | 86 | |
81 | 87 | if geometry is not None: |
172 | 178 | |
173 | 179 | # Check that we are using a listlike of geometries |
174 | 180 | level = _ensure_geometry(level) |
181 | index = frame.index | |
175 | 182 | frame[geo_column_name] = level |
183 | if frame.index is not index and len(frame.index) == len(index): | |
184 | # With pandas < 1.0 and an empty frame (no rows), the index gets reset | |
185 | # to a default RangeIndex -> set back the original index if needed | |
186 | frame.index = index | |
176 | 187 | frame._geometry_column_name = geo_column_name |
177 | 188 | frame.crs = crs |
178 | 189 | frame._invalidate_sindex() |
89 | 89 | "The descartes package is required for plotting polygons in geopandas." |
90 | 90 | ) |
91 | 91 | from matplotlib.collections import PatchCollection |
92 | from matplotlib.colors import is_color_like | |
92 | 93 | |
93 | 94 | geoms, multiindex = _flatten_multi_geoms(geoms, range(len(geoms))) |
94 | 95 | if values is not None: |
95 | values = np.take(values, multiindex) | |
96 | values = np.take(values, multiindex, axis=0) | |
96 | 97 | |
97 | 98 | # PatchCollection does not accept some kwargs. |
98 | 99 | if "markersize" in kwargs: |
99 | 100 | del kwargs["markersize"] |
100 | 101 | if color is not None: |
101 | kwargs["color"] = color | |
102 | if pd.api.types.is_list_like(color): | |
103 | kwargs["color"] = np.take(color, multiindex) | |
102 | if is_color_like(color): | |
103 | kwargs["color"] = color | |
104 | elif pd.api.types.is_list_like(color): | |
105 | kwargs["color"] = np.take(color, multiindex, axis=0) | |
104 | 106 | else: |
105 | kwargs["color"] = color | |
107 | raise TypeError( | |
108 | "Color attribute has to be a single color or sequence of colors." | |
109 | ) | |
110 | ||
106 | 111 | else: |
107 | 112 | for att in ["facecolor", "edgecolor"]: |
108 | 113 | if att in kwargs: |
109 | if pd.api.types.is_list_like(kwargs[att]): | |
110 | kwargs[att] = np.take(kwargs[att], multiindex) | |
114 | if not is_color_like(kwargs[att]): | |
115 | if pd.api.types.is_list_like(kwargs[att]): | |
116 | kwargs[att] = np.take(kwargs[att], multiindex, axis=0) | |
117 | elif kwargs[att] is not None: | |
118 | raise TypeError( | |
119 | "Color attribute has to be a single color or sequence " | |
120 | "of colors." | |
121 | ) | |
111 | 122 | |
112 | 123 | collection = PatchCollection([PolygonPatch(poly) for poly in geoms], **kwargs) |
113 | 124 | |
151 | 162 | |
152 | 163 | """ |
153 | 164 | from matplotlib.collections import LineCollection |
165 | from matplotlib.colors import is_color_like | |
154 | 166 | |
155 | 167 | geoms, multiindex = _flatten_multi_geoms(geoms, range(len(geoms))) |
156 | 168 | if values is not None: |
157 | values = np.take(values, multiindex) | |
169 | values = np.take(values, multiindex, axis=0) | |
158 | 170 | |
159 | 171 | # LineCollection does not accept some kwargs. |
160 | 172 | if "markersize" in kwargs: |
162 | 174 | |
163 | 175 | # color=None gives black instead of default color cycle |
164 | 176 | if color is not None: |
165 | if pd.api.types.is_list_like(color): | |
166 | kwargs["color"] = np.take(color, multiindex) | |
177 | if is_color_like(color): | |
178 | kwargs["color"] = color | |
179 | elif pd.api.types.is_list_like(color): | |
180 | kwargs["color"] = np.take(color, multiindex, axis=0) | |
167 | 181 | else: |
168 | kwargs["color"] = color | |
182 | raise TypeError( | |
183 | "Color attribute has to be a single color or sequence of colors." | |
184 | ) | |
169 | 185 | |
170 | 186 | segments = [np.array(linestring)[:, :2] for linestring in geoms] |
171 | 187 | collection = LineCollection(segments, **kwargs) |
214 | 230 | ------- |
215 | 231 | collection : matplotlib.collections.Collection that was plotted |
216 | 232 | """ |
233 | from matplotlib.colors import is_color_like | |
234 | ||
217 | 235 | if values is not None and color is not None: |
218 | 236 | raise ValueError("Can only specify one of 'values' and 'color' kwargs") |
219 | 237 | |
220 | 238 | geoms, multiindex = _flatten_multi_geoms(geoms, range(len(geoms))) |
221 | 239 | if values is not None: |
222 | values = np.take(values, multiindex) | |
240 | values = np.take(values, multiindex, axis=0) | |
223 | 241 | |
224 | 242 | x = [p.x for p in geoms] |
225 | 243 | y = [p.y for p in geoms] |
231 | 249 | kwargs["s"] = markersize |
232 | 250 | |
233 | 251 | if color is not None: |
234 | if pd.api.types.is_list_like(color): | |
235 | color = np.take(color, multiindex) | |
252 | if not is_color_like(color): | |
253 | if pd.api.types.is_list_like(color): | |
254 | color = np.take(color, multiindex, axis=0) | |
255 | else: | |
256 | raise TypeError( | |
257 | "Color attribute has to be a single color or sequence of colors." | |
258 | ) | |
236 | 259 | |
237 | 260 | if "norm" not in kwargs: |
238 | 261 | collection = ax.scatter( |
8 | 8 | import shapely.geometry |
9 | 9 | from shapely.geometry.base import CAP_STYLE, JOIN_STYLE |
10 | 10 | import shapely.wkb |
11 | from shapely._buildcfg import geos_version | |
11 | 12 | |
12 | 13 | import geopandas |
13 | 14 | from geopandas.array import ( |
393 | 394 | ) |
394 | 395 | def test_unary_predicates(attr): |
395 | 396 | na_value = False |
396 | if attr == "is_simple": | |
397 | # poly.is_simple raises an error for empty polygon | |
397 | if attr == "is_simple" and geos_version < (3, 8): | |
398 | # poly.is_simple raises an error for empty polygon for GEOS < 3.8 | |
398 | 399 | with pytest.raises(Exception): |
399 | 400 | T.is_simple |
400 | 401 | vals = triangle_no_missing |
615 | 616 | assert result.dtype == "float64" |
616 | 617 | np.testing.assert_allclose(result, np.array([[np.nan] * 4])) |
617 | 618 | |
619 | # empty array (https://github.com/geopandas/geopandas/issues/1195) | |
620 | E = from_shapely([]) | |
621 | result = E.bounds | |
622 | assert result.shape == (0, 4) | |
623 | assert result.dtype == "float64" | |
624 | ||
625 | ||
626 | def test_total_bounds(): | |
627 | result = T.total_bounds | |
628 | bounds = np.array( | |
629 | [t.bounds if not (t is None or t.is_empty) else [np.nan] * 4 for t in triangles] | |
630 | ) | |
631 | expected = np.array( | |
632 | [ | |
633 | bounds[:, 0].min(), # minx | |
634 | bounds[:, 1].min(), # miny | |
635 | bounds[:, 2].max(), # maxx | |
636 | bounds[:, 3].max(), # maxy | |
637 | ] | |
638 | ) | |
639 | np.testing.assert_allclose(result, expected) | |
640 | ||
641 | # additional check for empty array or one empty / missing | |
642 | for geoms in [[], [None], [shapely.geometry.Polygon()]]: | |
643 | E = from_shapely(geoms) | |
644 | result = E.total_bounds | |
645 | assert result.ndim == 1 | |
646 | assert result.dtype == "float64" | |
647 | np.testing.assert_allclose(result, np.array([np.nan] * 4)) | |
648 | ||
618 | 649 | |
619 | 650 | def test_getitem(): |
620 | 651 | points = [shapely.geometry.Point(i, i) for i in range(10)] |
285 | 285 | for i, r in df.iterrows(): |
286 | 286 | assert i == r["geometry"].x |
287 | 287 | assert i == r["geometry"].y |
288 | ||
289 | def test_set_geometry_empty(self): | |
290 | df = pd.DataFrame(columns=["a", "geometry"], index=pd.DatetimeIndex([])) | |
291 | result = df.set_geometry("geometry") | |
292 | assert isinstance(result, GeoDataFrame) | |
293 | assert isinstance(result.index, pd.DatetimeIndex) | |
288 | 294 | |
289 | 295 | def test_align(self): |
290 | 296 | df = self.df2 |
298 | 298 | result = gdf.bounds |
299 | 299 | assert_frame_equal(expected, result) |
300 | 300 | |
301 | def test_bounds_empty(self): | |
302 | # test bounds of empty GeoSeries | |
303 | # https://github.com/geopandas/geopandas/issues/1195 | |
304 | s = GeoSeries([]) | |
305 | result = s.bounds | |
306 | expected = DataFrame( | |
307 | columns=["minx", "miny", "maxx", "maxy"], index=s.index, dtype="float64" | |
308 | ) | |
309 | assert_frame_equal(result, expected) | |
310 | ||
301 | 311 | def test_unary_union(self): |
302 | 312 | p1 = self.t1 |
303 | 313 | p2 = Polygon([(2, 0), (3, 0), (3, 1)]) |
11 | 11 | |
12 | 12 | import geopandas |
13 | 13 | from geopandas import GeoDataFrame, GeoSeries |
14 | from geopandas._compat import PANDAS_GE_024 | |
14 | from geopandas._compat import PANDAS_GE_024, PANDAS_GE_025 | |
15 | 15 | from geopandas.array import from_shapely |
16 | 16 | |
17 | from geopandas.tests.util import assert_geoseries_equal | |
17 | from geopandas.testing import assert_geodataframe_equal, assert_geoseries_equal | |
18 | 18 | from pandas.util.testing import assert_frame_equal, assert_series_equal |
19 | 19 | import pytest |
20 | 20 | |
38 | 38 | def test_repr(s, df): |
39 | 39 | assert "POINT" in repr(s) |
40 | 40 | assert "POINT" in repr(df) |
41 | assert "POINT" in df._repr_html_() | |
41 | 42 | |
42 | 43 | |
43 | 44 | @pytest.mark.skipif( |
61 | 62 | |
62 | 63 | geopandas.options.display_precision = 9 |
63 | 64 | assert "POINT (10.123456789 50.123456789)" in repr(s1) |
65 | ||
66 | ||
67 | def test_repr_all_missing(): | |
68 | # https://github.com/geopandas/geopandas/issues/1195 | |
69 | s = GeoSeries([None, None, None]) | |
70 | assert "None" in repr(s) | |
71 | df = GeoDataFrame({"a": [1, 2, 3], "geometry": s}) | |
72 | assert "None" in repr(df) | |
73 | assert "geometry" in df._repr_html_() | |
74 | ||
75 | ||
76 | def test_repr_empty(): | |
77 | # https://github.com/geopandas/geopandas/issues/1195 | |
78 | s = GeoSeries([]) | |
79 | if PANDAS_GE_025: | |
80 | # repr with correct name fixed in pandas 0.25 | |
81 | assert repr(s) == "GeoSeries([], dtype: geometry)" | |
82 | else: | |
83 | assert repr(s) == "Series([], dtype: geometry)" | |
84 | df = GeoDataFrame({"a": [], "geometry": s}) | |
85 | assert "Empty GeoDataFrame" in repr(df) | |
86 | # https://github.com/geopandas/geopandas/issues/1184 | |
87 | assert "geometry" in df._repr_html_() | |
64 | 88 | |
65 | 89 | |
66 | 90 | def test_indexing(s, df): |
118 | 142 | |
119 | 143 | # TODO df.reindex(columns=['value1', 'value2']) still returns GeoDataFrame, |
120 | 144 | # should it return DataFrame instead ? |
145 | ||
146 | ||
147 | def test_take(s, df): | |
148 | inds = np.array([0, 2]) | |
149 | ||
150 | # GeoSeries take | |
151 | result = s.take(inds) | |
152 | expected = s.iloc[[0, 2]] | |
153 | assert isinstance(result, GeoSeries) | |
154 | assert_geoseries_equal(result, expected) | |
155 | ||
156 | # GeoDataFrame take axis 0 | |
157 | result = df.take(inds, axis=0) | |
158 | expected = df.iloc[[0, 2], :] | |
159 | assert isinstance(result, GeoDataFrame) | |
160 | assert_geodataframe_equal(result, expected) | |
161 | ||
162 | # GeoDataFrame take axis 1 | |
163 | df = df.reindex(columns=["value1", "value2", "geometry"]) # ensure consistent order | |
164 | result = df.take(inds, axis=1) | |
165 | expected = df[["value1", "geometry"]] | |
166 | assert isinstance(result, GeoDataFrame) | |
167 | assert_geodataframe_equal(result, expected) | |
168 | ||
169 | result = df.take(np.array([0, 1]), axis=1) | |
170 | expected = df[["value1", "value2"]] | |
171 | assert isinstance(result, pd.DataFrame) | |
172 | assert_frame_equal(result, expected) | |
173 | ||
174 | ||
175 | def test_take_empty(s, df): | |
176 | # ensure that index type is preserved in an empty take | |
177 | # https://github.com/geopandas/geopandas/issues/1190 | |
178 | inds = np.array([], dtype="int64") | |
179 | ||
180 | # use non-default index | |
181 | df.index = pd.date_range("2012-01-01", periods=len(df)) | |
182 | ||
183 | result = df.take(inds, axis=0) | |
184 | assert isinstance(result, GeoDataFrame) | |
185 | assert result.shape == (0, 3) | |
186 | assert isinstance(result.index, pd.DatetimeIndex) | |
187 | ||
188 | # the original bug report was an empty boolean mask | |
189 | for result in [df.loc[df["value1"] > 100], df[df["value1"] > 100]]: | |
190 | assert isinstance(result, GeoDataFrame) | |
191 | assert result.shape == (0, 3) | |
192 | assert isinstance(result.index, pd.DatetimeIndex) | |
121 | 193 | |
122 | 194 | |
123 | 195 | def test_assignment(s, df): |
117 | 117 | |
118 | 118 | ax = self.df.plot(color="green") |
119 | 119 | _check_colors(self.N, ax.collections[0].get_facecolors(), ["green"] * self.N) |
120 | ||
121 | # check rgba tuple GH1178 | |
122 | ax = self.df.plot(color=(0.5, 0.5, 0.5)) | |
123 | _check_colors( | |
124 | self.N, ax.collections[0].get_facecolors(), [(0.5, 0.5, 0.5)] * self.N | |
125 | ) | |
126 | ax = self.df.plot(color=(0.5, 0.5, 0.5, 0.5)) | |
127 | _check_colors( | |
128 | self.N, ax.collections[0].get_facecolors(), [(0.5, 0.5, 0.5, 0.5)] * self.N | |
129 | ) | |
130 | with pytest.raises(TypeError): | |
131 | self.df.plot(color="not color") | |
120 | 132 | |
121 | 133 | with warnings.catch_warnings(record=True) as _: # don't print warning |
122 | 134 | # 'color' overrides 'column' |
267 | 279 | ax = self.df.plot(color="green") |
268 | 280 | _check_colors(self.N, ax.collections[0].get_colors(), ["green"] * self.N) |
269 | 281 | |
282 | # check rgba tuple GH1178 | |
283 | ax = self.df.plot(color=(0.5, 0.5, 0.5, 0.5)) | |
284 | _check_colors( | |
285 | self.N, ax.collections[0].get_colors(), [(0.5, 0.5, 0.5, 0.5)] * self.N | |
286 | ) | |
287 | ax = self.df.plot(color=(0.5, 0.5, 0.5, 0.5)) | |
288 | _check_colors( | |
289 | self.N, ax.collections[0].get_colors(), [(0.5, 0.5, 0.5, 0.5)] * self.N | |
290 | ) | |
291 | with pytest.raises(TypeError): | |
292 | self.df.plot(color="not color") | |
293 | ||
270 | 294 | with warnings.catch_warnings(record=True) as _: # don't print warning |
271 | 295 | # 'color' overrides 'column' |
272 | 296 | ax = self.df.plot(column="values", color="green") |
353 | 377 | _check_colors(2, ax.collections[0].get_facecolors(), ["green"] * 2) |
354 | 378 | _check_colors(2, ax.collections[0].get_edgecolors(), ["k"] * 2) |
355 | 379 | |
380 | # check rgba tuple GH1178 | |
381 | ax = self.df.plot(color=(0.5, 0.5, 0.5)) | |
382 | _check_colors(2, ax.collections[0].get_facecolors(), [(0.5, 0.5, 0.5)] * 2) | |
383 | ax = self.df.plot(color=(0.5, 0.5, 0.5, 0.5)) | |
384 | _check_colors(2, ax.collections[0].get_facecolors(), [(0.5, 0.5, 0.5, 0.5)] * 2) | |
385 | with pytest.raises(TypeError): | |
386 | self.df.plot(color="not color") | |
387 | ||
356 | 388 | with warnings.catch_warnings(record=True) as _: # don't print warning |
357 | 389 | # 'color' overrides 'values' |
358 | 390 | ax = self.df.plot(column="values", color="green") |
402 | 434 | ax = self.polys.plot(facecolor="g", edgecolor="r", alpha=0.4) |
403 | 435 | _check_colors(2, ax.collections[0].get_facecolors(), ["g"] * 2, alpha=0.4) |
404 | 436 | _check_colors(2, ax.collections[0].get_edgecolors(), ["r"] * 2, alpha=0.4) |
437 | ||
438 | # check rgba tuple GH1178 for face and edge | |
439 | ax = self.df.plot(facecolor=(0.5, 0.5, 0.5), edgecolor=(0.4, 0.5, 0.6)) | |
440 | _check_colors(2, ax.collections[0].get_facecolors(), [(0.5, 0.5, 0.5)] * 2) | |
441 | _check_colors(2, ax.collections[0].get_edgecolors(), [(0.4, 0.5, 0.6)] * 2) | |
442 | ||
443 | ax = self.df.plot( | |
444 | facecolor=(0.5, 0.5, 0.5, 0.5), edgecolor=(0.4, 0.5, 0.6, 0.5) | |
445 | ) | |
446 | _check_colors(2, ax.collections[0].get_facecolors(), [(0.5, 0.5, 0.5, 0.5)] * 2) | |
447 | _check_colors(2, ax.collections[0].get_edgecolors(), [(0.4, 0.5, 0.6, 0.5)] * 2) | |
405 | 448 | |
406 | 449 | def test_legend_kwargs(self): |
407 | 450 | |
666 | 709 | _check_colors(self.N, coll.get_edgecolors(), ["r", "g", "b"]) |
667 | 710 | ax.cla() |
668 | 711 | |
712 | coll = plot_point_collection( | |
713 | ax, | |
714 | self.points, | |
715 | color=[(0.5, 0.5, 0.5, 0.5), (0.1, 0.2, 0.3, 0.5), (0.4, 0.5, 0.6, 0.5)], | |
716 | ) | |
717 | _check_colors( | |
718 | self.N, | |
719 | coll.get_facecolors(), | |
720 | [(0.5, 0.5, 0.5, 0.5), (0.1, 0.2, 0.3, 0.5), (0.4, 0.5, 0.6, 0.5)], | |
721 | ) | |
722 | _check_colors( | |
723 | self.N, | |
724 | coll.get_edgecolors(), | |
725 | [(0.5, 0.5, 0.5, 0.5), (0.1, 0.2, 0.3, 0.5), (0.4, 0.5, 0.6, 0.5)], | |
726 | ) | |
727 | ax.cla() | |
728 | ||
729 | # not a color | |
730 | with pytest.raises(TypeError): | |
731 | plot_point_collection(ax, self.points, color="not color") | |
732 | ||
669 | 733 | def test_points_values(self): |
670 | 734 | from geopandas.plotting import plot_point_collection |
671 | 735 | |
709 | 773 | _check_colors(self.N, coll.get_colors(), ["r", "g", "b"]) |
710 | 774 | ax.cla() |
711 | 775 | |
776 | coll = plot_linestring_collection( | |
777 | ax, | |
778 | self.lines, | |
779 | color=[(0.5, 0.5, 0.5, 0.5), (0.1, 0.2, 0.3, 0.5), (0.4, 0.5, 0.6, 0.5)], | |
780 | ) | |
781 | _check_colors( | |
782 | self.N, | |
783 | coll.get_colors(), | |
784 | [(0.5, 0.5, 0.5, 0.5), (0.1, 0.2, 0.3, 0.5), (0.4, 0.5, 0.6, 0.5)], | |
785 | ) | |
786 | ax.cla() | |
787 | ||
712 | 788 | # pass through of kwargs |
713 | 789 | coll = plot_linestring_collection(ax, self.lines, linestyle="--", linewidth=1) |
714 | 790 | exp_ls = _style_to_linestring_onoffseq("dashed", 1) |
717 | 793 | assert res_ls[1] == exp_ls[1] |
718 | 794 | ax.cla() |
719 | 795 | |
796 | # not a color | |
797 | with pytest.raises(TypeError): | |
798 | plot_linestring_collection(ax, self.lines, color="not color") | |
799 | ||
720 | 800 | def test_linestrings_values(self): |
721 | 801 | from geopandas.plotting import plot_linestring_collection |
722 | 802 | |
773 | 853 | _check_colors(self.N, coll.get_edgecolor(), ["g", "b", "r"]) |
774 | 854 | ax.cla() |
775 | 855 | |
856 | coll = plot_polygon_collection( | |
857 | ax, | |
858 | self.polygons, | |
859 | color=[(0.5, 0.5, 0.5, 0.5), (0.1, 0.2, 0.3, 0.5), (0.4, 0.5, 0.6, 0.5)], | |
860 | ) | |
861 | _check_colors( | |
862 | self.N, | |
863 | coll.get_facecolor(), | |
864 | [(0.5, 0.5, 0.5, 0.5), (0.1, 0.2, 0.3, 0.5), (0.4, 0.5, 0.6, 0.5)], | |
865 | ) | |
866 | _check_colors( | |
867 | self.N, | |
868 | coll.get_edgecolor(), | |
869 | [(0.5, 0.5, 0.5, 0.5), (0.1, 0.2, 0.3, 0.5), (0.4, 0.5, 0.6, 0.5)], | |
870 | ) | |
871 | ax.cla() | |
872 | ||
776 | 873 | # only setting facecolor keeps default for edgecolor |
777 | 874 | coll = plot_polygon_collection(ax, self.polygons, facecolor="g") |
778 | 875 | _check_colors(self.N, coll.get_facecolor(), ["g"] * self.N) |
784 | 881 | _check_colors(self.N, coll.get_facecolor(), ["g"] * self.N) |
785 | 882 | _check_colors(self.N, coll.get_edgecolor(), ["r"] * self.N) |
786 | 883 | ax.cla() |
884 | ||
885 | # not a color | |
886 | with pytest.raises(TypeError): | |
887 | plot_polygon_collection(ax, self.polygons, color="not color") | |
787 | 888 | |
788 | 889 | def test_polygons_values(self): |
789 | 890 | from geopandas.plotting import plot_polygon_collection |