|
1 | 1 | import uuid |
2 | 2 |
|
3 | 3 | import geopandas as gpd |
| 4 | +import libpysal |
4 | 5 | import numpy as np |
5 | 6 | import pandas as pd |
6 | 7 | import pytest |
|
14 | 15 | import momepy as mm |
15 | 16 |
|
16 | 17 | SHPLY_GE_210 = Version(shapely.__version__) >= Version("2.1.0") |
| 18 | +LPS_G_4_13_0 = Version(libpysal.__version__) > Version("4.13.0") |
17 | 19 |
|
18 | 20 |
|
19 | 21 | class TestElements: |
@@ -285,22 +287,35 @@ def test_get_nearest_node_missing(self): |
285 | 287 | def test_buffered_limit(self): |
286 | 288 | limit = mm.buffered_limit(self.df_buildings, 50) |
287 | 289 | assert limit.geom_type == "Polygon" |
288 | | - assert pytest.approx(limit.area) == 366525.967849688 |
| 290 | + exp = 366525.967849688 |
| 291 | + assert exp == pytest.approx(limit.area) |
289 | 292 |
|
290 | 293 | def test_buffered_limit_adaptive(self): |
291 | 294 | limit = mm.buffered_limit(self.df_buildings, "adaptive") |
292 | 295 | assert limit.geom_type == "Polygon" |
293 | | - assert pytest.approx(limit.area) == 355819.18954170 |
| 296 | + if LPS_G_4_13_0: |
| 297 | + exp = 347096.5835217 |
| 298 | + else: |
| 299 | + exp = 355819.1895417 |
| 300 | + assert exp == pytest.approx(limit.area) |
294 | 301 |
|
295 | 302 | limit = mm.buffered_limit(self.df_buildings, "adaptive", max_buffer=30) |
296 | 303 | assert limit.geom_type == "Polygon" |
297 | | - assert pytest.approx(limit.area) == 304200.301833294 |
| 304 | + if LPS_G_4_13_0: |
| 305 | + exp = 304712.451361391 |
| 306 | + else: |
| 307 | + exp = 304200.301833294 |
| 308 | + assert exp == pytest.approx(limit.area) |
298 | 309 |
|
299 | 310 | limit = mm.buffered_limit( |
300 | 311 | self.df_buildings, "adaptive", min_buffer=30, max_buffer=300 |
301 | 312 | ) |
302 | 313 | assert limit.geom_type == "Polygon" |
303 | | - assert pytest.approx(limit.area) == 357671.831894244 |
| 314 | + if LPS_G_4_13_0: |
| 315 | + exp = 348777.778371144 |
| 316 | + else: |
| 317 | + exp = 357671.831894244 |
| 318 | + assert exp == pytest.approx(limit.area) |
304 | 319 |
|
305 | 320 | def test_buffered_limit_error(self): |
306 | 321 | with pytest.raises( |
|
0 commit comments