-
Notifications
You must be signed in to change notification settings - Fork 78
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
Handle set_index properly in to_adjlist #511
Conversation
Codecov Report
@@ Coverage Diff @@
## master #511 +/- ##
========================================
+ Coverage 78.7% 78.8% +0.1%
========================================
Files 122 122
Lines 13182 13225 +43
========================================
+ Hits 10371 10417 +46
+ Misses 2811 2808 -3
|
idxs = np.array(list(self.neighbors.keys())) | ||
focal_ix = idxs[focal_ix] | ||
neighbor_ix = idxs[neighbor_ix] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to do this if there are no custom ids set. I would add
self.ids = ids
to the W.__init__
and then have this done conditionally after
if self.ids:
...
You can potentially also use the ids directly here but that does not matter much
if self.ids:
ids = np.asarray(self.ids)
focal_ix = ids.take(focal_ix)
neighbor_ix = ids.take(neighbor_ix)
Using keys from neighbours is probably safer option anyway.
martin's review echos my last two comments in #507, so do we also want to expose the ids attribute and only conditionally updated the adjlist when they dont match? (as a part of this PR?) |
I'd surely do that (as above) |
since we're getting rid of id_order (and id2i), we need to at least store the ids, otherwise conversion to wsp will lose the indices since we need to store them anyway, we might as well make it a public attribute. Might be a little more transparent for users instead of hitting w.neighbors.keys |
Okay, nothing against that. |
or--when converting to WSP, we could stash w.neighbors.keys as a private attribute, then use that when going back |
It seems safer to have an attribute always available than that. |
yeah agree. And looking a bit more closely, we use |
Co-authored-by: Martin Fleischmann <martin@martinfleischmann.net>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets go ahead and merge this. I've got another branch that includes the enhancements we discussed in this thread, but touches a bunch of other stuff to get rid of id_order
, so lets get this in and i can rebase that for review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@knaaptime can you ensure in the follow-up that the remapping here is done only if needed, ie. if ids are set?
yeah but it'll be in a separate pr from this branch as that one does away with id_order |
xref #507