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

propagate relabelling for gabriel weights #35

Merged
merged 2 commits into from
Nov 3, 2022
Merged

Conversation

ljwolf
Copy link

@ljwolf ljwolf commented Nov 3, 2022

Hey,

This solves the test bench for the Delaunay-based graphs, in the sense that ids are retained and keept aligned with the input dataframe. Everything prints the same:

import geopandas
from libpysal import weights, examples
examples.load_example("south.shp") # I can't locate south if I don't load it first, even if it's downloaded?
south = geopandas.read_file(examples.get_path("south.shp"))
south = south.set_geometry(south.centroid)

print(south.FIPS.iloc[:5].tolist())
for ids_ in ('FIPS', south.FIPS):
    wdel = weights.Delaunay.from_dataframe(south, ids=ids_)
    print(wdel.id_order[:5])
    wgab = weights.Gabriel.from_dataframe(south, ids=ids_)
    print(wgab.id_order[:5])
    wrn = weights.Relative_Neighborhood.from_dataframe(south, ids=ids_)
    print(wrn.id_order[:5])

this is what I mean about "sorting by default." I don't think that, if the user provides ids='FIPS', we should silently return a mis-aligned weights object from from_dataframe(). We can do this independently of the parent W class.

@martinfleis martinfleis merged commit 91240dc into martinfleis:ids Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants