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

access ports by alias #444

Closed
joamatab opened this issue Jul 30, 2024 · 5 comments
Closed

access ports by alias #444

joamatab opened this issue Jul 30, 2024 · 5 comments

Comments

@joamatab
Copy link
Collaborator

Some times ref.ports['o1'] we have different port_names ref.ports['in0']

can we add something like?

ref.ports_by_alias['o1']

@95-martin-orion
Copy link

On a related note, it would be convenient for Ports to implement get, similar to dict.get.

@sebastian-goeldi
Copy link
Collaborator

@joamatab what I was thinking of is to do the following:

ref.ports.copy(rename_function) to give you a new Ports object. Now, the problem is that this will first apply the transformation of the instance. But I assume you want the naming scheme applied to the initial cell ports and not the transformed instance ports? In that case this will take a bit longer.

@sebastian-goeldi
Copy link
Collaborator

@95-martin-orion what would be the use case for a get? Sure it's not hard to implement, but I would like to know what would be the use case, as I struggle to see where that could ever be useful.

@sebastian-goeldi
Copy link
Collaborator

This has been implemented in the method mentioned above

@95-martin-orion
Copy link

@95-martin-orion what would be the use case for a get? Sure it's not hard to implement, but I would like to know what would be the use case, as I struggle to see where that could ever be useful.

This is primarily a consistency request: Ports already implements most of the functionality of dict, but not having get means that functions which operate on dicts will sometimes fail if applied to Ports. (I had an explicit example when I originally requested this, but I just got back from a month of vacation and can't recall where I left off...)

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

3 participants