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

geary does hard typechecking of the weights object instead of ducktyping #45

Open
ljwolf opened this issue Nov 15, 2018 · 4 comments
Open

Comments

@ljwolf
Copy link
Member

ljwolf commented Nov 15, 2018

In line 103, we simply disbar folks from passing a spatial weights matrix, even if it's API-compatible and can be used in the function. This means that, for instance, we can't pass a weights matrix from libpysal into pysal.esda.geary.Geary, since (post-conversion) this will demand weights from pysal itself. This happens in reverse for weights from pysal being sent to esda.geary.Geary.

I understand the interest in giving user-friendly errors in case they pass the wrong things to the wrong arguments, but I think that more ducktyping would help our library be quite a bit more flexible without demanding users either keep to the sub- or meta-packages.

@sjsrey
Copy link
Member

sjsrey commented Nov 15, 2018

Good catch.

I agree that ducktyping these type of out-of-date conventions (now that we have refactored the library) is the way to go.

@sjsrey
Copy link
Member

sjsrey commented Jul 13, 2019

Is this still an issue, since now we import form libpysal to check the parameter class?

@ljwolf
Copy link
Member Author

ljwolf commented Jul 13, 2019

yes, it is.

if you install esda for advanced cutting/edge functionality, but use pysal weights constructors, you're not able to use geary anymore.

I really feel we need to trust ducktyping and not typecheck on the input of w.

@ljwolf
Copy link
Member Author

ljwolf commented Jul 13, 2019

We could even write an as_weights() function that:

  • checks if the w looks like an existing libpysal/pysal w and passes through
  • checks if the w is a sparse matrix or a numpy dense matrix, casts that to a weights
  • checks if the w is a networkx object, and then converts that using weights.from_networkx

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

No branches or pull requests

2 participants