mggg / maup

The geospatial toolkit for redistricting data.
https://maup.readthedocs.io/en/latest/
MIT License
65 stars 23 forks source link

Add UserWarning when assign fails to assign #35

Open InnovativeInventor opened 3 years ago

InnovativeInventor commented 3 years ago

TODO: checkup on the behavior of assign when a geometry in the source is completely untouched by any target geometry

InnovativeInventor commented 3 years ago

Update: maup will be NaN/undefined when this occurs. E.g.:

import geopandas as gpd
from shapely.geometry import Polygon
source = gpd.GeoSeries([
    Polygon([(0,0), (1,0), (1,1), (0,1)]),
    Polygon([(1,0), (2,0), (2,1), (1,1)])
])
target = gpd.GeoSeries([
    Polygon([(0,0), (1,0), (1,1), (0,1)]),
])
>>> maup.assign(source, target)
0    0.0
1    NaN
dtype: float64
>>> maup.assign(target, source)
0    0
dtype: int64

​I am going to make maup throw a user warning when either of these two ^ things occur.