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
add slice to __getitem__ for Node(Data)View #4086
Conversation
This look good to me. |
This certainly seems like a usability improvement! My knee-jerk reaction was that this might be a pretty significant API change (I'm really not familiar with the current |
I started writing this before @rossbar commented, so this is redundant. I am going to leave here just for the record. @rossbar Would you have time to look at this in the next couple of days? I have some general concerns about introducing new "convenience-oriented" API, but don't have specific thoughts about this PR yet. I believe @MridulS mentioned recently that this is a frequently requested from new users. (I may be misremembering, so please correct me if so.) I don't know if it is appropriate for this change, but maybe we should consider this for our first (new feature/API) NXEP: If it seems like a good idea to create a NXEP for this, maybe you can work with @MridulS to draft it. Mridul will have much more experience with the code base and working with new users than you, but you may have more experience with NXEPs (since I basically copied the NEP process). It would be good for us to gain experience with NXEPs. Hopefully, we will have several as we move closer to NX 3.0 and it would be good for us to see if there is anything we need to improve about the process sooner rather than later. It will also be helpful to have a couple of examples for future contributors to look at. |
Oh yes, definitely. Now that I think about it, this will lead to
significant API changes so we should have a more formal design doc rather
than just PRs. I’ll start up a NXEP for this (or if anyone else wants to
do that please go ahead).
…On Wed, 22 Jul 2020 at 00:23, Jarrod Millman ***@***.***> wrote:
@MridulS <https://github.com/MridulS> It looks like @rossbar
<https://github.com/rossbar> and I are both wondering whether it would
make sense to create a NXEP for this. Among other things, that would allow
us to record use cases and would serve as useful design documentation going
forward. What are your thoughts?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4086 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABI5RFC4ST6Q44SBBDTSPRLR4XP2PANCNFSM4O6VY7BA>
.
|
The NXEP process is very similar to the PEP process and should be near identical to the NEP and SKIP process. Since it looks like you may be the first person to try this out for NX, please don't hesitate to ask questions about the format and process. If things are too cumbersome or don't make sense, we should use this opportunity to refine the NXEP process. |
I agree with this, and this will be even stranger for G.edges as G.edges[0, 1] will be an attr dict while G.edges[0:1] will be a list. While working on the NXEP I had a wild-ish idea of copying pandas |
But, maybe we should call it G.nodes.slice(10)
G.nodes.slice(1:2:20)
G.nodes.slice(-10:) |
I occurs to me that users probably don't want to process "the first 10 edges". I think this fixes the primary motivating use-case -- are there other compelling use-cases? |
I like Dan's suggestion about adding a It doesn't save any characters:
And converting an iterable to a list using |
One thing about a >>> with nx.printoptions(num_elem=5):
... G.nodes() is more convenient than >>> list(G.nodes())[:5] and is certainly less flexible in any case (what if a user wanted every other node?). |
@dschult I started playing around with returning slice lists when the user explicitly asks for it. I have done this for
Node(Data)View
right now, would love to get some feedback and thoughts about this design before going further with this.The following code will be valid if we have slices in
Node(Data)View
.