Skip to content
This repository was archived by the owner on May 31, 2025. It is now read-only.

add EdgeList.__contains__#754

Closed
eric-wieser wants to merge 1 commit intoros:indigo-develfrom
eric-wieser:patch-2
Closed

add EdgeList.__contains__#754
eric-wieser wants to merge 1 commit intoros:indigo-develfrom
eric-wieser:patch-2

Conversation

@eric-wieser
Copy link
Copy Markdown
Contributor

Python dictionaries support indexing by tuples

@eric-wieser
Copy link
Copy Markdown
Contributor Author

Obviously has is public api, so can't be removed entirely

self.end = end
self.label = label
self.key = "%s|%s"%(self.start, self.label)
self.key = (self.start, self.label)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These slots are public API of an edge and therefore can't change their value like this.

Same for rkey below.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the value of rkey itself is considered public api, not just the value of the expression edges_by_start[rkey]? Darn.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An Edge is basically like a struct. All member are public and likely being used by user land code..

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Darn, I can't really argue with the fact that people might be relying on this. Is | a valid character in node or edge names? (ie, can I frame this as a bug, in which case breaking reliance of a bug is perhaps more ok)

Or should I just rebase this PR to just be the __contains__ above?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, | is not a valid character in node or edge names. So it is safe to be used as a separator.

Yes, please update the PR - and squash the commits on this branch. The __contains__ is certainly the significant of this PR. The slightly easier implementation of __iter__ as well as the set initializations below are more cosmetic but you can keep those.

@dirk-thomas
Copy link
Copy Markdown
Member

@ros-pull-request-builder retest this please

@dirk-thomas
Copy link
Copy Markdown
Member

Please rebase the patch against current indigo-devel since it seems to contain an old patch which results in a syntax error.

@eric-wieser
Copy link
Copy Markdown
Contributor Author

Looks like you did a rewrite of published history there! Corrected now

@eric-wieser eric-wieser changed the title Cleanup to rosgraph Deprecate EdgeList.has in favor of EdgeList.__contains__ Jun 20, 2016
@dirk-thomas dirk-thomas changed the title Deprecate EdgeList.has in favor of EdgeList.__contains__ add EdgeList.__contains__ Jun 27, 2016
@dirk-thomas
Copy link
Copy Markdown
Member

dirk-thomas commented Jun 27, 2016

Thanks for the patch. I have applied a modified version to the kinetic-devel branch: 5de058a Since the has method is not actually deprecated I removed the comment. I also skipped the cleanup changes.

@eric-wieser
Copy link
Copy Markdown
Contributor Author

Since the has method is not actually deprecated

Part of this pull request was me requesting that it should be, in the same way that dict.has_key is. not assuming that it was.

If you think it shouldn't be, then that's fine - it's not my call to make.

Thanks for the merge!

@dirk-thomas
Copy link
Copy Markdown
Member

Personally I do agree with you that cleaning up the API is nice. But based on the amount of code using this API it is not worth "forcing" the people to update it. Sorry.

@eric-wieser
Copy link
Copy Markdown
Contributor Author

eric-wieser commented Jun 28, 2016

But based on the amount of code using this API it is not worth "forcing" the people to update it. Sorry.

Deprecation doesn't ever need to lead to forcing people to update it - my goal was to stop anyone ever using .has in new code.

Also, this strikes me as a rather internal API, so I'd be surprised if that much code actually uses it anyway.

At any rate, I half-assed this, and if I was going for deprecation should probably have included a DeprecationWarning, so rejecting the rest of the patch is the right thing to do

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants